format
This commit is contained in:
14
model.py
14
model.py
@@ -59,7 +59,8 @@ class Model(ap.Model):
|
||||
size / sum(lst_succ_firm_size)
|
||||
for size in lst_succ_firm_size
|
||||
]
|
||||
# select multiple successors based on relative size of this firm
|
||||
# select multiple successors
|
||||
# based on relative size of this firm
|
||||
lst_same_prod_firm = Firm['Code'][Firm[product_code] ==
|
||||
1].to_list()
|
||||
lst_same_prod_firm_size = [
|
||||
@@ -202,7 +203,8 @@ class Model(ap.Model):
|
||||
if n_up_product_removed == 0:
|
||||
continue
|
||||
else:
|
||||
# update a_lst_product_disrupted / dct_lst_disrupt_firm_prod
|
||||
# update a_lst_product_disrupted
|
||||
# update dct_lst_disrupt_firm_prod
|
||||
if product not in firm.a_lst_product_disrupted:
|
||||
firm.a_lst_product_disrupted.append(product)
|
||||
if firm in self.dct_lst_disrupt_firm_prod.keys():
|
||||
@@ -212,7 +214,8 @@ class Model(ap.Model):
|
||||
self.dct_lst_disrupt_firm_prod[
|
||||
firm] = ap.AgentList(
|
||||
self.model, [product])
|
||||
# update a_lst_product_removed / dct_list_remove_firm_prod
|
||||
# update a_lst_product_removed
|
||||
# update dct_list_remove_firm_prod
|
||||
# mark disrupted firm as removed based conditionally
|
||||
lost_percent = n_up_product_removed / len(
|
||||
product.a_predecessors())
|
||||
@@ -220,8 +223,9 @@ class Model(ap.Model):
|
||||
std_size = (firm.revenue_log - min(lst_size) +
|
||||
1) / (max(lst_size) - min(lst_size) + 1)
|
||||
prod_remove = 1 - std_size * (1 - lost_percent)
|
||||
if self.nprandom.choice(
|
||||
[True, False], p=[prod_remove, 1 - prod_remove]):
|
||||
if self.nprandom.choice([True, False],
|
||||
p=[prod_remove,
|
||||
1 - prod_remove]):
|
||||
firm.a_lst_product_removed.append(product)
|
||||
if firm in self.dct_lst_remove_firm_prod.keys():
|
||||
self.dct_lst_remove_firm_prod[firm].append(
|
||||
|
||||
Reference in New Issue
Block a user