drop firm attr a_lst_product/_disrupted

This commit is contained in:
HaoYizhi 2023-06-18 22:41:26 +08:00
parent 11abfa5ce8
commit ae5bebb1f3
5 changed files with 12 additions and 9 deletions

Binary file not shown.

Binary file not shown.

View File

@ -82,8 +82,8 @@ class ControllerDB:
# list_dct = [{'140': ['1.4.5.1']}]
# list_dct = [{'133': ['1.4.4.1']}]
# list_dct = [{'2': ['1.1.3']}]
# list_dct = [{'135': ['1.3.2.1']}]
list_dct = [{'79': ['2.1.3.4']}]
list_dct = [{'135': ['1.3.2.1']}]
# list_dct = [{'79': ['2.1.3.4']}]
# list_dct = [{'99': ['1.3.3']}]
# list_dct = [{'41': ['1.4.5']}]

View File

@ -287,9 +287,9 @@ class Model(ap.Model):
self.a_lst_total_firms.select(
[firm.code == di_supp_node['Firm_Code']
for firm in self.a_lst_total_firms])[0]
lst_cand = self.model.a_lst_total_firms.select([
lst_cand = self.a_lst_total_firms.select([
firm.is_prod_in_current_normal(di_supp_prod)
for firm in self.model.a_lst_total_firms
for firm in self.a_lst_total_firms
])
n2n_betweenness = \
sum([True if di_supp_code in path else False
@ -418,7 +418,7 @@ class Model(ap.Model):
for product in firm.dct_prod_up_prod_stat.keys():
status = firm.dct_prod_up_prod_stat[product]['status'][-1][0]
if status == 'A':
print(firm.name, 'affected product: ', product.code)
print(firm.name, 'affected product:', product.code)
n_up_product_lost = \
sum([not stat for stat in
firm.dct_prod_up_prod_stat[
@ -428,10 +428,13 @@ class Model(ap.Model):
else:
lost_percent = n_up_product_lost / len(
product.a_predecessors())
lst_size = self.a_lst_total_firms.size
lst_size = [firm.size for firm
in self.a_lst_total_firms
if firm.is_prod_in_current_normal(product)]
# firm (affected) + other firm (same product, normal)
lst_firm = [firm]
lst_firm += \
[firm for firm
in self.a_lst_total_firms
if firm.is_prod_in_current_normal(product)]
lst_size = [firm.size for firm in lst_firm]
std_size = (firm.size - min(lst_size) +
1) / (max(lst_size) - min(lst_size) + 1)
prob_disrupt = 1 - std_size * (1 - lost_percent)