log status of every firm product in every time step + mysql
This commit is contained in:
11
firm.py
11
firm.py
@@ -29,14 +29,14 @@ class FirmAgent(ap.Agent):
|
||||
self.flt_crit_supplier = float(self.p.crit_supplier)
|
||||
|
||||
# init size_stat (self para)
|
||||
# (size, time step), ts -1 denotes initialization
|
||||
self.size_stat.append((revenue_log, -1))
|
||||
# (size, time step)
|
||||
self.size_stat.append((revenue_log, 0))
|
||||
|
||||
# init dct_prod_up_prod_stat (self para)
|
||||
for prod in a_lst_product:
|
||||
self.dct_prod_up_prod_stat[prod] = {
|
||||
# (Normal / Disrupted / Removed, time step)
|
||||
'status': [('N', -1)], # ts -1 denotes initialization
|
||||
'status': [('N', 0)],
|
||||
# have or have no supply
|
||||
'supply': dict.fromkeys(prod.a_predecessors(), True)
|
||||
}
|
||||
@@ -294,6 +294,11 @@ 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 = \
|
||||
|
||||
Reference in New Issue
Block a user