set maximun interation limit: para n_iter
This commit is contained in:
parent
695bfb409c
commit
afc74765ad
|
@ -5,6 +5,8 @@ meta_seed: 0
|
||||||
|
|
||||||
test: # only for test scenarios
|
test: # only for test scenarios
|
||||||
n_sample: 1
|
n_sample: 1
|
||||||
|
n_iter: 100
|
||||||
|
|
||||||
not_test: # normal scenarios
|
not_test: # normal scenarios
|
||||||
n_sample: 50
|
n_sample: 50
|
||||||
|
n_iter: 100
|
||||||
|
|
|
@ -134,6 +134,7 @@ class ControllerDB:
|
||||||
idx_scenario=idx_scenario,
|
idx_scenario=idx_scenario,
|
||||||
idx_init_removal=idx_init_removal,
|
idx_init_removal=idx_init_removal,
|
||||||
n_sample=int(self.dct_parameter['n_sample']),
|
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,
|
dct_lst_init_disrupt_firm_prod=dct_lst_init_disrupt_firm_prod,
|
||||||
g_bom=g_bom,
|
g_bom=g_bom,
|
||||||
n_max_trial=n_max_trial,
|
n_max_trial=n_max_trial,
|
||||||
|
|
10
model.py
10
model.py
|
@ -12,7 +12,8 @@ class Model(ap.Model):
|
||||||
def setup(self):
|
def setup(self):
|
||||||
# self para
|
# self para
|
||||||
self.sample = self.p.sample
|
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.product_network = None # agentpy network
|
||||||
self.firm_network = None # agentpy network
|
self.firm_network = None # agentpy network
|
||||||
self.firm_prod_network = None # networkx
|
self.firm_prod_network = None # networkx
|
||||||
|
@ -365,9 +366,12 @@ class Model(ap.Model):
|
||||||
continue
|
continue
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
self.int_stop_times = self.t
|
self.int_stop_ts = self.t
|
||||||
self.stop()
|
self.stop()
|
||||||
|
|
||||||
|
if self.t == self.int_n_iter:
|
||||||
|
self.stop()
|
||||||
|
|
||||||
def step(self):
|
def step(self):
|
||||||
print('\n', '=' * 20, 'step', self.t, '=' * 20)
|
print('\n', '=' * 20, 'step', self.t, '=' * 20)
|
||||||
|
|
||||||
|
@ -445,7 +449,7 @@ class Model(ap.Model):
|
||||||
# db_session.commit()
|
# db_session.commit()
|
||||||
# self.sample.is_done_flag = 1
|
# self.sample.is_done_flag = 1
|
||||||
# self.sample.computer_name = platform.node()
|
# 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()
|
# db_session.commit()
|
||||||
|
|
||||||
def draw_network(self):
|
def draw_network(self):
|
||||||
|
|
Loading…
Reference in New Issue