diff --git a/conf_experiment.yaml b/conf_experiment.yaml index 012f9a9..5566629 100644 --- a/conf_experiment.yaml +++ b/conf_experiment.yaml @@ -5,6 +5,8 @@ meta_seed: 0 test: # only for test scenarios n_sample: 1 + n_iter: 100 not_test: # normal scenarios n_sample: 50 + n_iter: 100 diff --git a/controller_db.py b/controller_db.py index 896c938..550a28c 100644 --- a/controller_db.py +++ b/controller_db.py @@ -134,6 +134,7 @@ class ControllerDB: idx_scenario=idx_scenario, idx_init_removal=idx_init_removal, n_sample=int(self.dct_parameter['n_sample']), + n_iter=int(self.dct_parameter['n_iter']), dct_lst_init_disrupt_firm_prod=dct_lst_init_disrupt_firm_prod, g_bom=g_bom, n_max_trial=n_max_trial, diff --git a/model.py b/model.py index 8c06bfd..1ffbb89 100644 --- a/model.py +++ b/model.py @@ -12,7 +12,8 @@ class Model(ap.Model): def setup(self): # self para self.sample = self.p.sample - self.int_stop_times, self.int_stop_t = 0, None + self.int_stop_ts = 0 + self.int_n_iter = int(self.p.n_iter) self.product_network = None # agentpy network self.firm_network = None # agentpy network self.firm_prod_network = None # networkx @@ -365,9 +366,12 @@ class Model(ap.Model): continue break else: - self.int_stop_times = self.t + self.int_stop_ts = self.t self.stop() + if self.t == self.int_n_iter: + self.stop() + def step(self): print('\n', '=' * 20, 'step', self.t, '=' * 20) @@ -445,7 +449,7 @@ class Model(ap.Model): # db_session.commit() # self.sample.is_done_flag = 1 # self.sample.computer_name = platform.node() - # self.sample.stop_t = self.int_stop_times + # self.sample.stop_t = self.int_stop_ts # db_session.commit() def draw_network(self):