Skip to content

Commit 958e914

Browse files
committed
do not include path geometry info by default
- change the default value of output_geometry in output_columns() from True to False; - update the tutorial and use cases accordingly; - add docstring to find_ue_fw() in fw.py; - change the version number from v0.9.10 to v0.10.0 in README.md and conf.py; - add find_ue_fw() to the API doc; - update pytest.yml to install pyyaml before running tests.
1 parent bbac5ff commit 958e914

File tree

10 files changed

+57
-20
lines changed

10 files changed

+57
-20
lines changed

.github/workflows/pytest.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ jobs:
2525
pip install -e .
2626
pip install pytest
2727
pip install requests
28+
pip install pyyaml
2829
- name: Run Pytest
2930
run: |
3031
pytest tests/

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
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.10-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.10.0-brightgreen)](https://img.shields.io/badge/release-v0.8.2-brightgreen) ![Read the Docs](https://img.shields.io/readthedocs/path4gmns)
44
[![](https://dcbadge.limes.pink/api/server/https://discord.gg/JGFMta7kxZ?style=flat)](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,
77

88
1. finding (static) shortest path between two nodes,
9-
2. performing path-based User-Equilibrium (UE) traffic assignment,
9+
2. performing either path-based or link-based User-Equilibrium (UE) traffic assignment,
1010
3. conducting dynamic traffic assignment (DTA) after UE.
1111
4. evaluating multimodal accessibility and equity,
1212
5. making the Origin-Destination (OD) demand matrix estimation (ODME),
13-
6. synthesizing zones and Origin-Destination (OD) demand.
13+
6. synthesizing zones and OD demand.
1414

1515
Path4GMNS also serves as an API to the C++-based [DTALite](https://github.com/jdlph/DTALite) to conduct various multimodal traffic assignments including,
1616
* Link-based UE,
@@ -29,13 +29,13 @@ Path4GMNS also serves as an API to the C++-based [DTALite](https://github.com/jd
2929
We highly recommend that you go through the above [Tutorial](https://github.com/jdlph/Path4GMNS/blob/master/tutorial/tutorial.ipynb), no matter you are one of the existing users or new to Path4GMNS.
3030

3131
## Installation
32-
Path4GMNS has been published on [PyPI](https://pypi.org/project/path4gmns/0.9.10/), and can be installed using
32+
Path4GMNS has been published on [PyPI](https://pypi.org/project/path4gmns/0.10.0/), and can be installed using
3333
```
3434
$ pip install path4gmns
3535
```
3636

3737
> [!IMPORTANT]
38-
> v0.9.10 comes with bug fix on [find_shortest_path()](https://github.com/jdlph/Path4GMNS/issues/58), new functionality on obtaining the shortest path tree, and performance improvement on the UE module. Please **discard all old versions**.
38+
> v0.10.0 introduces the link-based UE that adopts the Frank-Wolfe algorithm with line search. As it does not preserve any paths, each iteration runs faster than the path-based procedure with less memory footprint. Please **discard all old versions**.
3939
4040
> [!WARNING]
4141
> find_shortest_path() computes the shortest path per travel time rather than distance for v0.9.9.post1 and any earlier versions. See [Issue #58](https://github.com/jdlph/Path4GMNS/issues/58) for details. v0.9.10 offers the correct implementation with the flexibility to switch between time and distance.

docs/source/api.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,12 @@ path4gmns.conduct_odme
3131
path4gmns.colgen
3232
================
3333
.. autofunction:: path4gmns.colgen.find_ue
34-
34+
35+
36+
path4gmns.fw
37+
============
38+
.. autofunction:: path4gmns.fw.find_ue_fw
39+
3540

3641
path4gmns.io
3742
============

docs/source/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
author = 'Dr. Peiheng Li and Dr. Xuesong (Simon) Zhou'
2929

3030
# The full version, including alpha/beta/rc tags
31-
release = 'v0.9.10.post1'
31+
release = 'v0.10.0'
3232

3333

3434
# -- General configuration ---------------------------------------------------
@@ -76,4 +76,4 @@
7676
# Add any paths that contain custom static files (such as style sheets) here,
7777
# relative to this directory. They are copied after the builtin static files,
7878
# so a file named "default.css" will overwrite the builtin "default.css".
79-
html_static_path = ['_static']
79+
html_static_path = ['_static']

docs/source/index.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ applications in transportation (e.g., activity-based demand modeling).
1515
Path4GMNS supports, in short,
1616

1717
1. finding (static) shortest path between two nodes,
18-
2. performing path-based User-Equilibrium (UE) traffic assignment,
18+
2. performing either path-based or link-based User-Equilibrium (UE) traffic assignment,
1919
3. conducting dynamic traffic assignment (DTA) after UE.
2020
4. evaluating multimodal accessibility and equity,
2121
5. making the Origin-Destination (OD) demand matrix estimation (ODME),
22-
6. synthesizing zones and Origin-Destination (OD) demand.
22+
6. synthesizing zones and OD demand.
2323

2424
Path4GMNS also serves as an API to the C++-based
2525
`DTALite <https://github.com/jdlph/DTALite>`_ to conduct various multimodal

docs/source/installation.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
Installation
33
============
44

5-
Path4GMNS has been published on `PyPI <https://pypi.org/project/path4gmns/0.9.10/>`_, and can be installed using
5+
Path4GMNS has been published on `PyPI <https://pypi.org/project/path4gmns/0.10.0/>`_, and can be installed using
66

77
.. code-block:: bash
88
99
$ pip install path4gmns
1010
11-
If you need a specific version of Path4GMNS, say, 0.9.10,
11+
If you need a specific version of Path4GMNS, say, 0.10.0,
1212

1313
.. code-block:: bash
1414
15-
$ pip install path4gmns==0.9.10
15+
$ pip install path4gmns==0.10.0
1616
1717
1818
Dependency

docs/source/usecases.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ print(f'shortest path (node id) from node 1 to node 2: {sp_tree_node[2]}')
123123
# retrieve the shortest path from the source node (i.e., node 1) to node 3
124124
print(f'shortest path (node id) from node 1 to node 3: {sp_tree_node[3]}')
125125

126-
# get shortest path tree (in link sequences) from node 1
126+
# get shortest path tree (in link sequences) from node 1
127127
# cost is measured by distance (in miles)
128128
sp_tree_link = network.get_shortest_path_tree(1, seq_type='link', cost_type='distance')
129129
# retrieve the shortest path from the source node (i.e., node 1) to node 2
@@ -213,8 +213,8 @@ column_upd_num = 20
213213
rel_gap = pg.find_ue(network, column_gen_num, column_upd_num, rel_gap_tolerance = 0.001)
214214
print(f'the final relative UE gap is {rel_gap:.4%}')
215215

216-
# if you do not want to include geometry info in the output file,
217-
# use pg.output_columns(network, False)
216+
# if you want to include path geometry info in the output file,
217+
# use pg.output_columns(network, True)
218218
pg.output_columns(network)
219219
pg.output_link_performance(network)
220220
```

path4gmns/fw.py

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,37 @@ def _init_sys_tt(demand_period_count):
172172

173173

174174
def find_ue_fw(ui, max_iter = 40, rel_gap_tolerance=1e-04):
175+
""" find user equilibrium (UE) with the Frank-Wolfe Algorithm
176+
177+
WARNING
178+
-------
179+
It does not preserve any paths/columns during the assignment process.
180+
If you need paths/columns (in route_assignment.csv), please use the
181+
path-based UE module: find_ue().
182+
183+
Parameters
184+
----------
185+
ui
186+
network object generated by pg.read_network()
187+
188+
max_iter
189+
maximum number of iterations to be performed on finding UE. Default is 40.
190+
191+
rel_gap_tolerance
192+
target relative gap. find_ue_fw() stops when either max_iter or
193+
rel_gap_tolerance is reached.
194+
195+
Returns
196+
-------
197+
rel_gap
198+
relative GAP to measure the UE convergency
199+
200+
Note
201+
----
202+
You will need to call output_link_performance() toget the assignment
203+
results, i.e., volumes and other link attributes on each link (in
204+
link_performance.csv).
205+
"""
175206
# base assignment
176207
A = ui._base_assignment
177208
# set up SPNetwork
@@ -181,7 +212,7 @@ def find_ue_fw(ui, max_iter = 40, rel_gap_tolerance=1e-04):
181212
links = A.get_links()
182213
demand_period_count = A.get_demand_period_count()
183214

184-
print('find user equilibrium (UE) using Frank-Wolfe Algorithm\n')
215+
print('find user equilibrium (UE) using the Frank-Wolfe Algorithm\n')
185216
st = time()
186217

187218
# initialization

path4gmns/io.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,7 @@ def load_columns(ui, input_dir='.'):
866866
update_links_using_columns(ui)
867867

868868

869-
def output_columns(ui, output_geometry=True, output_dir='.'):
869+
def output_columns(ui, output_geometry=False, output_dir='.'):
870870
with open(output_dir+'/route_assignment.csv', 'w', newline='') as fp:
871871
base = ui._base_assignment
872872

tutorial/tutorial.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,8 @@
346346
"rel_gap = pg.find_ue(network, column_gen_num, column_upd_num, rel_gap_tolerance = 0.001)\n",
347347
"print(f'the final relative UE gap is {rel_gap:.4%}')\n",
348348
"\n",
349-
"# if you do not want to include geometry info in the output file,\n",
350-
"# use pg.output_columns(network, False)\n",
349+
"# if you want to include path geometry info in the output file,\n",
350+
"# use pg.output_columns(network, True)\n",
351351
"pg.output_columns(network)\n",
352352
"pg.output_link_performance(network)"
353353
]

0 commit comments

Comments
 (0)