Skip to content

Commit 29c9cf3

Browse files
Jens Westjohpiip
andauthored
Add last iteration when reaching gap threshold (#396)
Co-authored-by: Johanna Piipponen <johanna.piipponen@wsp.com>
1 parent c893ccc commit 29c9cf3

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Scripts/helmet.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ def main(args):
9494
impedance = model.assign_base_demand(
9595
args.use_fixed_transit_cost, iterations==0)
9696
log_extra["status"]["state"] = "running"
97-
for i in range(1, iterations + 1):
97+
i = 1
98+
while i <= iterations:
9899
log_extra["status"]["current"] = i
99100
try:
100101
log.info("Starting iteration {}".format(i), extra=log_extra)
@@ -109,11 +110,11 @@ def main(args):
109110
"Fatal error occured, simulation aborted.", extra=log_extra)
110111
break
111112
gap = model.convergence.iloc[-1, :] # Last iteration convergence
112-
if gap["max_gap"] < args.max_gap or gap["rel_gap"] < args.rel_gap:
113-
log_extra["status"]['state'] = 'finished'
114-
break
115113
if i == iterations:
116114
log_extra["status"]['state'] = 'finished'
115+
elif gap["max_gap"] < args.max_gap or gap["rel_gap"] < args.rel_gap:
116+
iterations = i + 1
117+
i += 1
117118
# delete emme strategy files for scenarios
118119
if args.del_strat_files:
119120
dbase_path = os.path.join(os.path.dirname(emme_project_path), "database")

0 commit comments

Comments
 (0)