Skip to content

Commit cf49553

Browse files
committed
polish source code and docs for release
- rename arg work_dir to input_dir in read_demand(); - call read_demand() in test_find_shortest_path_for_agents() which is essential to set up agents; - terminate test_find_shortest_path_for_agents() if there are no agents; - fix bug in test_odme() on calling read_measurements(); - disable test_multimodal_dtalite() which will crash the testing process as run_DTALite() requires a different settings.yml; - update docstrings for run_DTALite(); - conduct minor changes to docstrings for perform_column_generation() and perform_network_assignment(); - replace deprecated perform_column_generation() with find_ue() in usecases.md; - update Public API for colgen and io; - change version number from v0.9.8 to v0.9.9.
1 parent 8e87888 commit cf49553

File tree

9 files changed

+43
-37
lines changed

9 files changed

+43
-37
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Path4GMNS
22
[![platform](https://img.shields.io/badge/platform-Windows%20%7C%20macOS%20%7C%20Linux-red)](https://img.shields.io/badge/platform-Windows%20%7C%20macOS%20%7C%20Linux-red)
3-
[![Downloads](https://static.pepy.tech/badge/path4gmns)](https://pepy.tech/project/path4gmns) [![GitHub release](https://img.shields.io/badge/release-v0.9.8-brightgreen)](https://img.shields.io/badge/release-v0.8.2-brightgreen) ![Read the Docs](https://img.shields.io/readthedocs/path4gmns)
3+
[![Downloads](https://static.pepy.tech/badge/path4gmns)](https://pepy.tech/project/path4gmns) [![GitHub release](https://img.shields.io/badge/release-v0.9.9-brightgreen)](https://img.shields.io/badge/release-v0.8.2-brightgreen) ![Read the Docs](https://img.shields.io/readthedocs/path4gmns)
44
[![](https://dcbadge.vercel.app/api/server/JGFMta7kxZ?style=flast)](https://discord.gg/JGFMta7kxZ)
55

66
Path4GMNS is an open-source, cross-platform, lightweight, and fast Python path engine for networks encoded in [GMNS](https://github.com/zephyr-data-specs/GMNS). Besides finding static shortest paths for simple analyses, its main functionality is to provide an efficient and flexible framework for column-based (path-based) modeling and applications in transportation (e.g., activity-based demand modeling). Path4GMNS supports, in short,

docs/source/api.rst

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,23 @@ path4gmns.conduct_odme
2828

2929
path4gmns.colgen
3030
================
31+
.. autofunction:: path4gmns.colgen.find_ue
3132
.. autofunction:: path4gmns.colgen.perform_column_generation
3233
.. autofunction:: path4gmns.colgen.perform_network_assignment
3334

3435

3536
path4gmns.io
3637
============
37-
.. autofunction:: path4gmns.utils.read_network
38-
.. autofunction:: path4gmns.utils.read_zones
39-
.. autofunction:: path4gmns.utils.load_demand
40-
.. autofunction:: path4gmns.utils.load_columns
41-
.. autofunction:: path4gmns.utils.output_link_performance
42-
.. autofunction:: path4gmns.utils.output_agent_paths
43-
.. autofunction:: path4gmns.utils.output_zones
44-
.. autofunction:: path4gmns.utils.output_synthetic_zones
45-
.. autofunction:: path4gmns.utils.output_synthetic_demand
38+
.. autofunction:: path4gmns.io.read_demand
39+
.. autofunction:: path4gmns.io.read_measurements
40+
.. autofunction:: path4gmns.io.read_network
41+
.. autofunction:: path4gmns.io.load_demand
42+
.. autofunction:: path4gmns.io.load_columns
43+
.. autofunction:: path4gmns.io.output_link_performance
44+
.. autofunction:: path4gmns.io.output_agent_paths
45+
.. autofunction:: path4gmns.io.output_agent_trajectory
46+
.. autofunction:: path4gmns.io.output_synthetic_zones
47+
.. autofunction:: path4gmns.io.output_synthetic_demand
4648

4749

4850
path4gmns.simulation

docs/source/usecases.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -363,10 +363,10 @@ network.get_accessible_links(1, 15, 'w', time_dependent=True, demand_period_id=1
363363

364364
Transportation equity is accessibility with respect to different demographics. Path4GMNS provides the following simple info and statistics on equity given a time budget and a segmentation of zones (e.g., zones can be grouped into a set of bins according to income level and each zone will have a unique bin index). The current implementation takes bin index of each zone from node.csv under column "bin_index" (via node-to-zone mapping), which is error prone. As a zone might have more than one node, it may encounter inconsistent bin indices over a set of nodes corresponding to the same zone. In case of that, the first bin index encountered for each zone in loading node.csv is always used for evaluation. 0 is taken as default if column "bin_index" or the value of an entry is missing.
365365

366-
1. accessible zones.
367-
2. min accessibility. Each zone has a list of accessible zones given a time budget and a transportation mode. This metric refers to the zone with the minimum number of accessible zones. This number and the zone ID will both be output. Note that there could be multiple zones with the same minimum number of accessible zones and only the first zone will be in the output.
368-
3. max accessibility.
369-
4. mean accessibility. The average number of accessible zones over a bin of zones (corresponding to a specific demographic) given a time budget and a transportation mode.
366+
1. **accessible zones**.
367+
2. **min accessibility**. Each zone has a list of accessible zones given a time budget and a transportation mode. This metric refers to the zone with the minimum number of accessible zones. This number and the zone ID will both be output. Note that there could be multiple zones with the same minimum number of accessible zones and only the first zone will be in the output.
368+
3. **max accessibility**.
369+
4. **mean accessibility**. The average number of accessible zones over a bin of zones (corresponding to a specific demographic) given a time budget and a transportation mode.
370370

371371
They can be obtained via Path4GMNS of v0.8.3 or higher in a way very similar to the process of evaluating accessibility.
372372

@@ -426,7 +426,7 @@ simulation:
426426
resolution: 6
427427
```
428428
429-
perform_column_generation() shall be called in the first place to set up path for each agent before simulation.
429+
find_ue() shall be called in the first place to set up path for each agent before simulation.
430430
431431
```Python
432432
import path4gmns as pg
@@ -445,7 +445,7 @@ print('writing agent trajectories')
445445
pg.output_agent_trajectory(network)
446446
```
447447

448-
If you have route_assignment.csv (i.e.columns) from a previous run or DTALite, you can bypass perform_column_generation() and directly load it to conduct simulation.
448+
If you have route_assignment.csv (i.e.columns) from a previous run or DTALite, you can bypass find_ue() and directly load it to conduct simulation.
449449

450450
```python
451451
import path4gmns as pg

path4gmns/colgen.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,7 @@ def perform_column_generation(column_gen_num, column_update_num, ui):
300300
----
301301
You will need to call output_columns() and output_link_performance() to
302302
get the assignment results, i.e., paths/columns (in route_assignment.csv) and
303-
assigned volumes and other link attributes on each link (in l
304-
ink_performance.csv)
303+
assigned volumes and other link attributes on each link (in link_performance.csv)
305304
"""
306305
# make sure iteration numbers are both non-negative
307306
assert(column_gen_num>=0)
@@ -355,7 +354,7 @@ def update_links_using_columns(network):
355354

356355

357356
def perform_network_assignment(assignment_mode, column_gen_num, column_update_num, ui):
358-
"""DEPRECATED Column Generation API
357+
"""DEPRECATED Column Generation API. Use find_ue() instead!
359358
360359
Keep it here as legacy support for existing users who already get used to it
361360
"""

path4gmns/dtaapi.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def run_DTALite():
144144
This version of DTALite includes all-new Logbook, enhanced scenario handling,
145145
improved I/O functionality, and so on.
146146
147-
Its source code can be found at https://github.com/asu-trans-ai-lab/DTALite.
147+
Its source code can be found at https://github.com/asu-trans-ai-lab/DTALite/tree/feature/multimodal.
148148
149149
Parameters
150150
----------
@@ -156,11 +156,10 @@ def run_DTALite():
156156
157157
Note
158158
----
159-
It is compatible with the classic DTALite and the corresponding data sets
160-
from https://github.com/jdlph/Path4GMNS/tree/dev/data.
159+
It is NOT compatible with the classic DTALite (i.e., perform_network_assignment_DTALite()).
161160
162-
Additional data set can be found at
163-
https://github.com/asu-trans-ai-lab/DTALite/tree/main/data.
161+
Only use the following data set from
162+
https://github.com/asu-trans-ai-lab/DTALite/tree/feature/multimodal/data.
164163
165164
Please run the script calling this API using system terminal rather than
166165
Python console for proper logging.

path4gmns/io.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
'output_columns',
2323
'output_link_performance',
2424
'output_agent_paths',
25+
'output_agent_trajectory,'
2526
'output_synthetic_zones',
26-
'output_synthetic_demand',
27-
'output_agent_trajectory'
27+
'output_synthetic_demand'
2828
]
2929

3030

@@ -1395,7 +1395,7 @@ def read_measurements(ui, input_dir='.'):
13951395
print(f'the number of valid measurements is {record_no}\n')
13961396

13971397

1398-
def read_demand(ui, use_synthetic_data = False, save_synthetic_data=True, work_dir='.'):
1398+
def read_demand(ui, use_synthetic_data = False, save_synthetic_data=True, input_dir='.'):
13991399
""" a dedicated API to read demand and zone information """
14001400
A = ui._base_assignment
14011401

@@ -1417,7 +1417,7 @@ def read_demand(ui, use_synthetic_data = False, save_synthetic_data=True, work_d
14171417
try:
14181418
at = A.get_agent_type_id(d.get_agent_type_str())
14191419
dp = A.get_demand_period_id(d.get_period())
1420-
_read_demand(work_dir,
1420+
_read_demand(input_dir,
14211421
d.get_file_name(),
14221422
at,
14231423
dp,
@@ -1447,7 +1447,7 @@ def read_demand(ui, use_synthetic_data = False, save_synthetic_data=True, work_d
14471447
dp = A.get_demand_period_id(d.get_period())
14481448
_read_zones(ui)
14491449
_read_demand(
1450-
work_dir, filename, at, dp, A.network.zones, A.column_pool
1450+
input_dir, filename, at, dp, A.network.zones, A.column_pool
14511451
)
14521452
# early termination to load only one synthetic demand file
14531453
return
@@ -1465,5 +1465,5 @@ def read_demand(ui, use_synthetic_data = False, save_synthetic_data=True, work_d
14651465
print('data synthesis is complete!')
14661466

14671467
if save_synthetic_data:
1468-
output_synthetic_zones(ui, work_dir)
1469-
output_synthetic_demand(ui, work_dir)
1468+
output_synthetic_zones(ui, input_dir)
1469+
output_synthetic_demand(ui, input_dir)

tests/test_dtalite.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ def test_classic_dtalite(sample_data_dir, mode = 1):
1616
chdir(ORIG_DIR)
1717

1818

19-
def test_multimodal_dtalite(sample_data_dir):
20-
chdir(sample_data_dir)
19+
# disable it from now on (10/16/24) as run_DTALite() requires a different
20+
# settings.yml
21+
# def test_multimodal_dtalite(sample_data_dir):
22+
# chdir(sample_data_dir)
2123

22-
run_DTALite()
24+
# run_DTALite()
2325

24-
chdir(ORIG_DIR)
26+
# chdir(ORIG_DIR)

tests/test_odme.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def test_odme(sample_data_dir, tmp_output_dir):
1919
column_update_num = 20
2020
find_ue(network, column_gen_num, column_update_num)
2121

22-
read_measurements(input_dir=sample_data_dir)
22+
read_measurements(network, input_dir=sample_data_dir)
2323
# ODME
2424
odme_update_num = 20
2525
conduct_odme(network, odme_update_num)

tests/test_sp.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from os.path import isfile
22
from random import randint
33

4-
from path4gmns.io import output_agent_paths, read_network
4+
from path4gmns.io import output_agent_paths, read_demand, read_network
55

66

77
def test_routing_engine(sample_data_dir):
@@ -29,12 +29,16 @@ def test_find_shortest_path(sample_data_dir):
2929
def test_find_shortest_path_for_agents(sample_data_dir, tmp_output_dir):
3030
""" find_path_for_agents has been DEPRECATED """
3131
network = read_network(input_dir=sample_data_dir)
32+
read_demand(network, input_dir=sample_data_dir)
3233

3334
# find agent paths under a specific mode defined in settings.yaml,
3435
# say, a (i.e., auto)
3536
# network.find_path_for_agents('a') or network.find_path_for_agents('auto')
3637
network.find_path_for_agents()
3738

39+
if network.get_agent_num() == 0:
40+
return
41+
3842
agent_id = randint(0, network.get_agent_num() - 1)
3943
# origin node id of agent
4044
network.get_agent_orig_node_id(agent_id)

0 commit comments

Comments
 (0)