rename 3 status into (Normal / Disrupted / Removed)

This commit is contained in:
2023-07-02 15:03:51 +08:00
parent baf60ffd76
commit c348f3eb9c
6 changed files with 18 additions and 18 deletions

14
firm.py
View File

@@ -35,7 +35,7 @@ class FirmAgent(ap.Agent):
# init dct_prod_up_prod_stat (self para)
for prod in a_lst_product:
self.dct_prod_up_prod_stat[prod] = {
# (Normal / Affected / Removed, time step)
# (Normal / Disrupted / Removed, time step)
'status': [('N', -1)], # ts -1 denotes initialization
# have or have no supply
'supply': dict.fromkeys(prod.a_predecessors(), True)
@@ -62,8 +62,8 @@ class FirmAgent(ap.Agent):
# print(firm_agent.name, extra_cap)
self.dct_prod_capacity[product] = extra_cap
def remove_edge_to_cus_affect_cus_up_prod(self, disrupted_prod):
# para remove_product is the product that self got disrupted
def remove_edge_to_cus_disrupt_cus_up_prod(self, disrupted_prod):
# para disrupted_prod is the product that self got disrupted
lst_out_edge = list(
self.firm_network.graph.out_edges(
self.firm_network.positions[self], keys=True, data='Product'))
@@ -95,8 +95,8 @@ class FirmAgent(ap.Agent):
customer.dct_prod_up_prod_stat[
prod]['supply'][disrupted_prod] = False
customer.dct_prod_up_prod_stat[
prod]['status'].append(('A', self.model.t))
print(self.name, disrupted_prod.code, 'affect',
prod]['status'].append(('D', self.model.t))
print(self.name, disrupted_prod.code, 'disrupt',
customer.name, prod.code)
def seek_alt_supply(self, product):
@@ -134,9 +134,9 @@ class FirmAgent(ap.Agent):
# select based on size or not
if self.is_prf_size:
lst_size = \
[size for size in
[firm.size_stat[-1][0] for firm in
self.dct_cand_alt_supp_up_prod_disrupted[
product].size_stat[-1][0]]
product]]
lst_prob = [size / sum(lst_size)
for size in lst_size]
select_alt_supply = self.model.nprandom.choice(