update the status of firm in clean_before_time_step + remove_edge_to_cus_disrupt_cus_up_prod update disrupted status instead of append + proactive find candidate that is not a current supplier for the same product
This commit is contained in:
11
model.py
11
model.py
@@ -311,9 +311,16 @@ class Model(ap.Model):
|
||||
[product.code == di_supp_node['Product_Code']
|
||||
for product in self.a_lst_total_products])[0]
|
||||
# find a dfferent firm can produce the same product
|
||||
# and is not a current supplier for the same product
|
||||
lst_current_supp_code = \
|
||||
[self.firm_prod_network.nodes[code]['Firm_Code']
|
||||
for code in self.firm_prod_network.predecessors(
|
||||
pro_firm_prod_code)
|
||||
if self.firm_prod_network.nodes[code][
|
||||
'Product_Code'] == di_supp_prod.code]
|
||||
lst_cand = self.model.a_lst_total_firms.select([
|
||||
firm.is_prod_in_current_normal(di_supp_prod)
|
||||
and firm.code != di_supp_node['Firm_Code']
|
||||
and firm.code not in lst_current_supp_code
|
||||
for firm in self.model.a_lst_total_firms
|
||||
])
|
||||
if len(lst_cand) > 0:
|
||||
@@ -388,6 +395,8 @@ class Model(ap.Model):
|
||||
# remove edge to customer and disrupt customer up product
|
||||
for firm in self.a_lst_total_firms:
|
||||
for prod in firm.dct_prod_up_prod_stat.keys():
|
||||
# repetition of disrupted firm that last for multiple ts is ok,
|
||||
# as their edge has already been removed
|
||||
status, ts = firm.dct_prod_up_prod_stat[prod]['status'][-1]
|
||||
if status == 'D' and ts == self.t-1:
|
||||
firm.remove_edge_to_cus_disrupt_cus_up_prod(prod)
|
||||
|
||||
Reference in New Issue
Block a user