diff --git a/__pycache__/controller_db.cpython-38.pyc b/__pycache__/controller_db.cpython-38.pyc index f446f0c..d282dbe 100644 Binary files a/__pycache__/controller_db.cpython-38.pyc and b/__pycache__/controller_db.cpython-38.pyc differ diff --git a/__pycache__/firm.cpython-38.pyc b/__pycache__/firm.cpython-38.pyc index da4039e..7e83b77 100644 Binary files a/__pycache__/firm.cpython-38.pyc and b/__pycache__/firm.cpython-38.pyc differ diff --git a/__pycache__/model.cpython-38.pyc b/__pycache__/model.cpython-38.pyc index f1db79e..91c1e07 100644 Binary files a/__pycache__/model.cpython-38.pyc and b/__pycache__/model.cpython-38.pyc differ diff --git a/controller_db.py b/controller_db.py index f7a1c01..9512bf1 100644 --- a/controller_db.py +++ b/controller_db.py @@ -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']}] diff --git a/model.py b/model.py index 49f551f..132ca26 100644 --- a/model.py +++ b/model.py @@ -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)