Skip to content

Commit 44fb500

Browse files
authored
Merge pull request #602 from HSLdevcom/fix/improve_validation
Validate connectors
2 parents 1e3f810 + 93db790 commit 44fb500

File tree

6 files changed

+19
-14
lines changed

6 files changed

+19
-14
lines changed

Scripts/assignment/emme_assignment.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -478,11 +478,9 @@ def calc_noise(self) -> pandas.Series:
478478
link = morning_network.link(link.i_node, link.j_node)
479479
rlink = link.reverse_link
480480
if reverse_traffic > 0:
481-
speed = (60 * 2 * link.length
482-
/ (link["@car_time_aht"]+rlink["@car_time_aht"]))
481+
speed = (60 * 2 * link.length/(link["@car_time_aht"]+rlink["@car_time_aht"])) if rlink["@car_time_aht"] > 0.0 else 50.0
483482
else:
484-
speed = (0.3*(60*link.length/link["@car_time_aht"])
485-
+ 0.7*link.data2)
483+
speed = (0.3*(60*link.length/link["@car_time_aht"]) + 0.7*link.data2) if link["@car_time_aht"] > 0.0 else 50.0
486484
speed = max(speed, 50.0)
487485

488486
# Calculate start noise

Scripts/helmet_validate_inputfiles.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,10 @@ def main(args):
183183
# Check if emmebank has scenarios with different zone numbers
184184
scenarios_with_different_zones = 0
185185
for scen in emmebank.scenarios():
186-
if scen.zone_numbers != zone_numbers:
186+
compared_zone_numbers = scen.zone_numbers
187+
if compared_zone_numbers < 1: # Skip empty scenarios
188+
continue
189+
if compared_zone_numbers != zone_numbers:
187190
scenarios_with_different_zones += 1
188191
if scenarios_with_different_zones > 0:
189192
log.warn(f"{scenarios_with_different_zones} Scenarios with different zones found in EMME bank! Matrices will not be compatible between scenarios with different zones.")

Scripts/parameters/assignment.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
"hmaf": (800000, 800500),
9898
"hrjasf": (801000, 801500),
9999
"htpaf": (802000, 806000),
100-
"hpaf": (810000, 816000),
100+
"htpaf": (810000, 816000),
101101
}
102102
vdf_temp = ("(put(60/ul2)*(1+{}*put((volau+volad)/{})/"
103103
+ "(ul1-get(2))))*(get(2).le.put(ul1*{}))*length+(get(2).gt."

Scripts/tests/test_data/Network/base_network_test.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ a 310493 25474182 6682152 0 0 49 C
547547
a 310494 25474153 6682117 0 0 49 C
548548
a 310495 25474593 6681914 0 0 49 C
549549
a 310496 25474577 6681880 0 0 49 C
550-
a 321079 25433589.837194 6698120.349799 0 20 428 O
550+
a 321079 25433589.837194 6698120.349799 0 20 444 O
551551
a 321090 25428709.603729 6696148.266151 0 20 734 O
552552
a 321091 25421975.1812 6698283.299535 0 20 734 O
553553
a 321092 25414689.484996 6697591.407689 0 20 734 O
@@ -635,7 +635,7 @@ a 6291 179244 1.1744 hcvkyaf 99 1.0 99 1000 100 .469970
635635
a 19071 300018 2.0896 hcvkaf 99 1.0 99 0 0 0
636636
a 34102 321095 10.3859 hcvkyasf 98 1.0 99 1000 100 0
637637
a 34500 200843 .097100 hcvkyasf 87 1.0 99 1000 100 27.4636
638-
a 35039 224410 .118611 hcvkyaf 140 1.0 5 900 36 0
638+
a 35039 224410 .118611 hcvkyaf 84 1.0 5 900 36 0
639639
a 40222 40226 .133000 hcvkybgde 129 1.0 2 1850 81 45.9068
640640
a 40223 197014 1.0117 hcvkybgde 124 3.0 1 1700 97 201.129
641641
a 40224 50074 .359200 hcvkybgde 124 3.0 1 1700 97 189.548
@@ -1480,7 +1480,7 @@ a 223753 238903 .093600 hcvkybgdeaf 134 2.0 3 1250 54 89.3543
14801480
a 223753 321597 .297300 hcvkybgdeaf 134 2.0 3 1250 54 66.3284
14811481
a 224389 238904 .064800 hcvkybgdeaf 134 2.0 3 1250 54 66.3284
14821482
a 224389 321597 .162600 hcvkybgdeaf 134 2.0 3 1250 54 82.6334
1483-
a 224410 35039 .118611 hcvkyaf 140 1.0 5 900 36 0
1483+
a 224410 35039 .118611 hcvkyaf 84 1.0 5 900 36 0
14841484
a 224410 197084 .040100 hcvkybgdeaf 134 3.0 3 1250 54 89.632
14851485
a 224410 238903 .077100 hcvkybgdeaf 134 2.0 3 1250 54 71.5573
14861486
a 224410 801035 .090100 haf 70 1.0 0 0 0 0

Scripts/utils/calc_noise.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,9 @@ def calc_noise(self, link):
4949
link = self.morning_network.link(link.i_node, link.j_node)
5050
rlink = link.reverse_link
5151
if reverse_traffic > 0:
52-
speed = (60 * 2 * link.length
53-
/ (link[self.car_morning]+rlink[self.car_morning]))
52+
speed = (60 * 2 * link.length/(link[self.car_morning]+rlink[self.car_morning])) if rlink[self.car_morning] > 0 else 50.0
5453
else:
55-
speed = (0.3*(60*link.length/link[self.car_morning])
56-
+ 0.7*link.data2)
54+
speed = (0.3*(60*link.length/link[self.car_morning]) + 0.7*link.data2) if link[self.car_morning] > 0 else 50.0
5755
speed = max(speed, 50.0)
5856

5957
# Calculate start noise

Scripts/utils/validate_network.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,13 @@ def validate(network, fares=None):
139139
timeperiod, link.id)
140140
log.error(msg)
141141
raise ValueError(msg)
142-
142+
143+
if (link.i_node.is_centroid or link.j_node.is_centroid) and link.type not in param.connector_link_types:
144+
msg = "Link {} is a connector and must be one of the connector link types: {}".format(
145+
link.id, param.connector_link_types)
146+
log.error(msg)
147+
raise ValueError(msg)
148+
143149
if link.i_node.is_centroid and link.j_node.is_centroid:
144150
msg = "Link {} is leading directly from centroid node {} to centroid node {}. This is not allowed.".format(link.id,link.i_node.number,link.j_node.number)
145151
log.error(msg)

0 commit comments

Comments
 (0)