drop firm attr a_lst_product/_disrupted
This commit is contained in:
18
firm.py
18
firm.py
@@ -13,8 +13,6 @@ class FirmAgent(ap.Agent):
|
||||
self.type_region = type_region
|
||||
self.ori_size = revenue_log
|
||||
self.size = revenue_log
|
||||
self.a_lst_product = a_lst_product
|
||||
self.a_lst_product_disrupted = ap.AgentList(self.model, [])
|
||||
self.dct_prod_up_prod_stat = {}
|
||||
self.dct_prod_capacity = {}
|
||||
|
||||
@@ -41,7 +39,7 @@ class FirmAgent(ap.Agent):
|
||||
}
|
||||
|
||||
# init extra capacity (self para)
|
||||
for product in self.a_lst_product:
|
||||
for product in a_lst_product:
|
||||
# init extra capacity based on discrete uniform distribution
|
||||
assert self.str_cap_limit_prob_type in ['uniform', 'normal'], \
|
||||
"cap_limit_prob_type other than uniform, normal"
|
||||
@@ -107,8 +105,7 @@ class FirmAgent(ap.Agent):
|
||||
# select a list of candidate firm that has the product
|
||||
self.dct_cand_alt_supp_up_prod_disrupted[product] = \
|
||||
self.model.a_lst_total_firms.select([
|
||||
product in firm.a_lst_product
|
||||
and product not in firm.a_lst_product_disrupted
|
||||
firm.is_prod_in_current_normal(product)
|
||||
for firm in self.model.a_lst_total_firms
|
||||
])
|
||||
if self.dct_cand_alt_supp_up_prod_disrupted[product]:
|
||||
@@ -163,7 +160,7 @@ class FirmAgent(ap.Agent):
|
||||
f"{self.name} selct alt supply for {product.code} "
|
||||
f"from {select_alt_supply.name}"
|
||||
)
|
||||
assert product in select_alt_supply.a_lst_product, \
|
||||
assert select_alt_supply.is_prod_in_current_normal(product), \
|
||||
f"{select_alt_supply} \
|
||||
does not produce requested product {product}"
|
||||
|
||||
@@ -286,3 +283,12 @@ class FirmAgent(ap.Agent):
|
||||
|
||||
def get_firm_network_node(self):
|
||||
return self.firm_network.positions[self]
|
||||
|
||||
def is_prod_in_current_normal(self, prod):
|
||||
if prod in self.dct_prod_up_prod_stat.keys():
|
||||
if self.dct_prod_up_prod_stat[prod]['status'][-1][0] == 'N':
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
else:
|
||||
return False
|
||||
|
||||
Reference in New Issue
Block a user