set maximun interation limit: para n_iter

This commit is contained in:
HaoYizhi 2023-07-02 15:17:58 +08:00
parent 695bfb409c
commit afc74765ad
3 changed files with 10 additions and 3 deletions

View File

@ -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

View File

@ -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,

View File

@ -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,7 +366,10 @@ 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):
@ -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):