revenue reduce

This commit is contained in:
2023-06-18 20:27:23 +08:00
parent b0b3cac73e
commit 1d8f319adb
5 changed files with 43 additions and 11 deletions

View File

@@ -300,7 +300,7 @@ class Model(ap.Model):
for path in lst_shortest_path]) \
/ len(lst_shortest_path)
drs = n2n_betweenness / \
(len(lst_cand) * di_supp_firm.revenue_log)
(len(lst_cand) * di_supp_firm.size)
dct_drs[di_supp_code] = drs
dct_drs = dict(sorted(
dct_drs.items(), key=lambda kv: kv[1], reverse=True))
@@ -352,6 +352,18 @@ class Model(ap.Model):
# self.int_stop_times = self.t
# self.stop()
# reduce the size of removed firm
for firm in self.a_lst_total_firms:
for prod in firm.dct_prod_up_prod_stat.keys():
status, ts = firm.dct_prod_up_prod_stat[prod]['status'][-1]
if status == 'R':
firm.size -= \
firm.ori_size / len(firm.a_lst_product) / self.drop_t
print(self.t, firm.name, prod.code, firm.size)
if self.t - ts + 1 == self.drop_t:
firm.dct_prod_up_prod_stat[
prod]['status'].append(('N', self.t))
if self.t > 0:
for firm in self.a_lst_total_firms:
for prod in firm.dct_prod_up_prod_stat.keys():
@@ -462,14 +474,14 @@ class Model(ap.Model):
# mark disrupted firm as removed based conditionally
lost_percent = n_up_product_removed / len(
product.a_predecessors())
lst_size = self.a_lst_total_firms.revenue_log
lst_size = [firm.revenue_log for firm
lst_size = self.a_lst_total_firms.size
lst_size = [firm.size for firm
in self.a_lst_total_firms
if product in firm.a_lst_product
and product
not in firm.a_lst_product_removed
]
std_size = (firm.revenue_log - min(lst_size) +
std_size = (firm.size - min(lst_size) +
1) / (max(lst_size) - min(lst_size) + 1)
prob_remove = 1 - std_size * (1 - lost_percent)
# damp prod