update the status of firm in clean_before_time_step + remove_edge_to_cus_disrupt_cus_up_prod update disrupted status instead of append + proactive find candidate that is not a current supplier for the same product
This commit is contained in:
19
firm.py
19
firm.py
@@ -94,8 +94,11 @@ class FirmAgent(ap.Agent):
|
||||
prod]['supply'].keys():
|
||||
customer.dct_prod_up_prod_stat[
|
||||
prod]['supply'][disrupted_prod] = False
|
||||
customer.dct_prod_up_prod_stat[
|
||||
prod]['status'].append(('D', self.model.t))
|
||||
status, _ = customer.dct_prod_up_prod_stat[
|
||||
prod]['status'][-1]
|
||||
if status != 'D':
|
||||
customer.dct_prod_up_prod_stat[
|
||||
prod]['status'].append(('D', self.model.t))
|
||||
print(self.name, disrupted_prod.code, 'disrupt',
|
||||
customer.name, prod.code)
|
||||
|
||||
@@ -294,17 +297,19 @@ class FirmAgent(ap.Agent):
|
||||
|
||||
def clean_before_trial(self):
|
||||
self.dct_request_prod_from_firm = {}
|
||||
for prod in self.dct_prod_up_prod_stat.keys():
|
||||
status, ts = self.dct_prod_up_prod_stat[prod]['status'][-1]
|
||||
if ts != self.model.t:
|
||||
self.dct_prod_up_prod_stat[prod]['status'].append(
|
||||
(status, self.model.t))
|
||||
|
||||
def clean_before_time_step(self):
|
||||
self.dct_n_trial_up_prod_disrupted = \
|
||||
dict.fromkeys(self.dct_n_trial_up_prod_disrupted.keys(), 0)
|
||||
self.dct_cand_alt_supp_up_prod_disrupted = {}
|
||||
|
||||
# update the status of firm
|
||||
for prod in self.dct_prod_up_prod_stat.keys():
|
||||
status, ts = self.dct_prod_up_prod_stat[prod]['status'][-1]
|
||||
if ts != self.model.t:
|
||||
self.dct_prod_up_prod_stat[prod]['status'].append(
|
||||
(status, self.model.t))
|
||||
|
||||
def get_firm_network_node(self):
|
||||
return self.firm_network.positions[self]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user