Skip to content

Commit 809627e

Browse files
committed
glob iteration specific relative gap
1 parent 90df1cc commit 809627e

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

tm2py/components/network/highway/highway_assign.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -297,13 +297,18 @@ def _get_assignment_spec(
297297
Emme specification for SOLA traffic assignment
298298
299299
"""
300-
relative_gap = self.config.relative_gap
301-
# if relative is a list, get the corresponding value for the current iteration
302-
if relative_gap and isinstance(relative_gap, list):
303-
if self.controller.iteration == 0:
304-
relative_gap = relative_gap[0]
305-
else:
306-
relative_gap = relative_gap[self.controller.iteration - 1]
300+
relative_gaps = self.config.relative_gaps
301+
# get the corresponding relative gap for the current iteration
302+
relative_gap = None
303+
if relative_gaps and isinstance(relative_gaps, tuple):
304+
for item in relative_gaps:
305+
if item["global_iteration"] == self.controller.iteration:
306+
relative_gap = item["relative_gap"]
307+
break
308+
if relative_gap is None:
309+
raise ValueError(
310+
f"RelativeGapConfig: Must specifify a value for global iteration {self.controller.iteration}"
311+
)
307312
max_iterations = self.config.max_iterations
308313
# NOTE: mazmazvol as background traffic in link.data1 ("ul1")
309314
base_spec = {

tm2py/config.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,7 @@ class HighwayConfig(ConfigItem):
924924
Properties:
925925
generic_highway_mode_code: single character unique mode ID for entire
926926
highway network (no excluded_links)
927-
relative_gap: target relative gap stopping criteria. specify a single value float
927+
relative_gaps: target relative gap stopping criteria. specify a single value float
928928
for all global iterations or a list with values for each global iteration.
929929
max_iterations: maximum iterations stopping criteria
930930
area_type_buffer_dist_miles: used to in calculation to categorize link @areatype
@@ -1350,12 +1350,12 @@ def maz_skim_period_exists(cls, value, values):
13501350
), "maz_to_maz -> skim_period -> name not found in time_periods list"
13511351
return value
13521352

1353-
@validator("highway_relative_gap")
1353+
@validator("highway")
13541354
def relative_gap_length(cls, value, values):
1355-
"""Validate highway.relative_gap is a list of the same length as global iterations."""
1355+
"""Validate highway.relative_gaps is a list of the same length as global iterations."""
13561356
if "end_iteration" in values:
13571357
assert (
1358-
len(value) == len(values["end_iteration"]+1),
1358+
len(value.relative_gaps) == len(values["end_iteration"]+1),
13591359
"relative_gap must be the same length as end_iteration+1",
13601360
)
13611361
return value

0 commit comments

Comments
 (0)