proactive strategy exp

This commit is contained in:
2023-06-05 16:01:20 +08:00
parent bc3c600be0
commit b55a313c95
11 changed files with 39 additions and 11 deletions

View File

@@ -25,6 +25,7 @@ class Model(ap.Model):
self.flt_netw_pref_cust_size = float(self.p.netw_pref_cust_size)
self.flt_cap_limit = int(self.p.cap_limit)
self.flt_diff_remove = float(self.p.diff_remove)
self.proactive_ratio = float(self.p.proactive_ratio)
# init graph bom
G_bom = nx.adjacency_graph(json.loads(self.p.g_bom))
@@ -172,7 +173,6 @@ class Model(ap.Model):
firm.a_lst_product_removed.append(product)
# proactive strategy
proactive_ratio = 1.0
# get all the firm prod affected
for firm, a_lst_product in self.dct_lst_remove_firm_prod.items():
for product in a_lst_product:
@@ -198,7 +198,7 @@ class Model(ap.Model):
[lst_affected[i] for i in
self.nprandom.choice(range(len(lst_affected)),
round(len(lst_affected) *
proactive_ratio))]
self.proactive_ratio))]
for firm_code, prod_code in lst_firm_proactive:
pro_firm_prod_code = \
@@ -266,11 +266,15 @@ class Model(ap.Model):
'Product': di_supp_prod.code
})
])
# print(f"proactive add {select_cand.code} to "
# f"{pro_firm.code} "
# f"for {di_supp_code} {di_supp_prod.code}")
# change capacity
select_cand.dct_prod_capacity[di_supp_prod] -= 1
break
# draw network
self.draw_network()
# self.draw_network()
def update(self):
self.a_lst_total_firms.clean_before_time_step()