Skip to content

Commit d0756cf

Browse files
committed
raise exception if no valid OD volumes
- column generation and finding paths for all agents require that valid OD volumes/demands. If the overall demand for connected OD pairs is ZERO, raise exception; - move explanation on zone degree to where _zone_degrees is declared.
1 parent 10ac721 commit d0756cf

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

path4gmns/utils.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919

2020

2121
# for precheck on connectivity of each OD pair
22+
# 0: isolated, has neither outgoing links nor incoming links
23+
# 1: has at least one outgoing link
24+
# 2: has at least one incoming link
25+
# 3: has both outgoing and incoming links
2226
_zone_degrees = []
2327

2428

@@ -409,10 +413,6 @@ def read_links(input_dir,
409413
links.append(link)
410414

411415
# set up zone degrees
412-
# 0: isolated, has neither outgoing links nor incoming links
413-
# 1: has at least one outgoing link
414-
# 2: has at least one incoming link
415-
# 3: has both outgoing and incoming links
416416
if load_demand:
417417
oz_id = from_node.get_zone_id()
418418
dz_id = to_node.get_zone_id()
@@ -477,7 +477,10 @@ def read_demand(input_dir,
477477

478478
total_agents += int(volume + 1)
479479

480-
print(f"the number of agents is {total_agents}")
480+
print(f"the number of agents is {total_agents}")
481+
482+
if total_agents == 0:
483+
raise Exception('NO VALID OD VOLUME!! DOUBLE CHECK YOUR demand.csv')
481484

482485

483486
def _auto_setup(assignment):

tests/demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,4 +165,4 @@ def demo_mode(mode):
165165

166166
if __name__=="__main__":
167167

168-
demo_mode(6)
168+
demo_mode(2)

0 commit comments

Comments
 (0)