Skip to content

Commit 48ebf03

Browse files
committed
fix potential issues of calling DTALite
- move setup of _dtalite_engine and _dtalitemm_engine within their callers respectively to avoid the execution of DTALite on the initial loading of Path4GMNS and generation of the log files; - remove input_dir from the arg list of _emit_log() but add log_file with its default value as 'log_main.txt', update run_DTALite() accordingly; - update README and docs.
1 parent 403be24 commit 48ebf03

File tree

6 files changed

+36
-34
lines changed

6 files changed

+36
-34
lines changed

README.md

Lines changed: 14 additions & 12 deletions
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.6-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.7-brightgreen)](https://img.shields.io/badge/release-v0.8.2-brightgreen) ![Read the Docs](https://img.shields.io/readthedocs/path4gmns)
44

55
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,
66

@@ -19,15 +19,16 @@ Path4GMNS also serves as an API to the C++-based [DTALite](https://github.com/jd
1919
![Architecture](/docs/source/imgs/architecture.png)
2020

2121
## Installation
22-
Path4GMNS has been published on [PyPI](https://pypi.org/project/path4gmns/0.9.6/), and can be installed using
22+
Path4GMNS has been published on [PyPI](https://pypi.org/project/path4gmns/0.9.7/), and can be installed using
2323
```
2424
$ pip install path4gmns
2525
```
2626

27-
v0.9.6 improves the assignment results by eliminating ultra-low-volume paths and computes the final UE convergency after the postprocessing. Please **update to or install the latest version** and **discard all old versions**.
27+
v0.9.7 serves as a hotfix over v0.9.5 and v0.9.6 on emitting DTALite log and synthesizing zone and demand. Please **update to or install the latest version** and **discard all old versions**.
2828

2929
> [!WARNING]
3030
> Any versions prior to v0.9.4 will generate INCORRECT simulation results.
31+
> Calling DTALite and [synthesizing zones and OD demand are not functioning for v0.9.5 and v0.9.6](https://github.com/jdlph/Path4GMNS/issues/41).
3132
3233
### Dependency
3334
The Python modules are written in **Python 3.x**, which is the minimum requirement to explore the most of Path4GMNS. Some of its functions require further run-time support, which we will go through along with the corresponding **[Use Cases](https://path4gmns.readthedocs.io/en/latest/)**.
@@ -36,6 +37,14 @@ The Python modules are written in **Python 3.x**, which is the minimum requireme
3637

3738
We highly recommend that you go through this **[Tutorial](https://github.com/jdlph/Path4GMNS/tree/dev/tests/tutorial.ipynb)** written in Jupyter notebook with step-by-step demonstration using the latest version, no matter you are one of the existing users or new to Path4GMNS. Its documentation is available on **[readthedocs](https://path4gmns.readthedocs.io/en/latest/)**.
3839

40+
## Please Contribute
41+
42+
Any contributions are welcomed including advise new applications of Path4GMNS, enhance documentation and [docstrings](https://docs.python-guide.org/writing/documentation/#writing-docstrings) in the source code, refactor and/or optimize the source code, report and/or resolve potential issues/bugs, suggest and/or add new functionalities, etc.
43+
44+
Path4GMNS has a very simple workflow setup, i.e., **master for release (on both GitHub and PyPI)** and **dev for development**. If you would like to work directly on the source code (and probably the documentation), please make sure that **the destination branch of your pull request is dev**, i.e., all potential changes/updates shall go to the dev branch before merging into master for release.
45+
46+
You are encouraged to join our [Discord Channel](https://discord.gg/JGFMta7kxZ) for the latest update and more discussions.
47+
3948
## Implementation Notes
4049

4150
The column generation scheme in Path4GMNS is an equivalent **single-processing implementation** as its [DTALite](https://github.com/jdlph/DTALite/tree/main/src_cpp) multiprocessing counterpart. **Note that** the results (i.e., column pool and trajectory for each agent) from Path4GMNS and DTALite are comparable but likely not identical as the shortest paths are usually not unique and subjected to implementations. This difference shall be subtle and the link performances shall be consistent if the iterations of column generation and column update are both large enough. You can always compare the results (i.e., link_performance.csv) from Path4GMNS and DTALite given the same network and demand.
@@ -102,20 +111,13 @@ DTALite uses arrays rather than STL containers to store columns. These arrays ar
102111
48. Eliminate ultra-low-volume columns from assignment (v0.9.6)
103112
49. Calculate and print out the final UE convergency after the postprocessing (v0.9.6)
104113
50. Embed and support the latest [DTALite](https://github.com/asu-trans-ai-lab/DTALite) in addition to the existing [classic version](https://github.com/jdlph/DTALite) (v0.9.6)
114+
51. Complete update 47 introduced in v0.9.5 (v0.9.7)
105115

106116
Detailed update information can be found in [Releases](https://github.com/jdlph/Path4GMNS/releases).
107117

108-
## Please Contribute
109-
110-
Any contributions are welcomed including advise new applications of Path4GMNS, enhance documentation (this guideline and [docstrings](https://docs.python-guide.org/writing/documentation/#writing-docstrings) in the source code), refactor and/or optimize the source code, report and/or resolve potential issues/bugs, suggest and/or add new functionalities, etc.
111-
112-
Path4GMNS has a very simple workflow setup, i.e., **master for release (on both GitHub and PyPI)** and **dev for development**. If you would like to work directly on the source code (and probably the documentation), please make sure that **the destination branch of your pull request is dev**, i.e., all potential changes/updates shall go to the dev branch before merging into master for release.
113-
114-
You are encouraged to join our [Discord Channel](https://discord.gg/JGFMta7kxZ) for the latest update and more discussions.
115-
116118
## How to Cite
117119

118-
Li, P. and Zhou, X. (2023, September 7). *Path4GMNS*. Retrieved from https://github.com/jdlph/Path4GMNS
120+
Li, P. and Zhou, X. (2023, September 13). *Path4GMNS*. Retrieved from https://github.com/jdlph/Path4GMNS
119121

120122
## References
121123
Lu, C. C., Mahmassani, H. S., Zhou, X. (2009). [Equivalent gap function-based reformulation and solution algorithm for the dynamic user equilibrium problem](https://www.sciencedirect.com/science/article/abs/pii/S0191261508000829). Transportation Research Part B: Methodological, 43, 345-364.

docs/source/api.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ path4gmns.colgen
2424
path4gmns.dtaapi
2525
================
2626
.. autofunction:: path4gmns.dtaapi.perform_network_assignment_DTALite
27+
.. autofunction:: path4gmns.dtaapi.run_DTALite
2728

2829

2930
path4gmns.simulation

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
author = 'Dr. Peiheng Li and Dr. Xuesong (Simon) Zhou'
2727

2828
# The full version, including alpha/beta/rc tags
29-
release = 'v0.9.6'
29+
release = 'v0.9.7'
3030

3131

3232
# -- General configuration ---------------------------------------------------

docs/source/installation.rst

Lines changed: 6 additions & 6 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.6/>`_, and can be installed using
5+
Path4GMNS has been published on `PyPI <https://pypi.org/project/path4gmns/0.9.7/>`_, 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.6,
11+
If you need a specific version of Path4GMNS, say, 0.9.7,
1212

1313
.. code-block:: bash
1414
15-
$ pip install path4gmns==0.9.6
15+
$ pip install path4gmns==0.9.7
1616
1717
1818
Dependency
@@ -55,7 +55,7 @@ As CMAKE_BUILD_TYPE will be IGNORED for IDE (Integrated Development Environment)
5555
# from the root directory of PATH4GMNS
5656
$ python setup.py sdist bdist_wheel
5757
$ cd dist
58-
# or python -m pip install path4gmns-0.9.6.tar.gz
59-
$ python -m pip instal pypath4gmns-0.9.6-py3-none-any.whl
58+
# or python -m pip install path4gmns-0.9.7.tar.gz
59+
$ python -m pip instal pypath4gmns-0.9.7-py3-none-any.whl
6060
61-
Here, 0.9.6 is the version number. Replace it with the one specified in setup.py.
61+
Here, 0.9.7 is the version number. Replace it with the one specified in setup.py.

docs/source/usecases.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ pg.output_link_performance(network)
160160

161161
### In Case of Special Events
162162

163-
A special event often comes with capacity reduction over affected links, which is now supported in v0.8.4. You can introduce one special event for each demand period in settings.yml as below.
163+
A special event often comes with capacity reduction over affected links, which is now supported in v0.8.4 or higher. You can introduce one special event for each demand period in settings.yml as below.
164164

165165
```yaml
166166
demand_periods:
@@ -407,7 +407,7 @@ Traffic simulation is to capture/mimic the traffic evolution over time through s
407407

408408
The traffic simulation module in Path4GMNS is a mesoscopic simulator using the point queue model and the routing decision of each individual agent (as disaggregated demand). The routing decisions are from the UE traffic assignment.
409409

410-
The demand loading profile with respect to the departure times of all agents is either constant (start time of the selected demand period) or random (within the selected demand period). The future release will introduce a linear or piece-wise linear loading profile. v0.9.0 only supports one demand period, which must be specified in settings.yml and be corresponding to one from the list of demand_periods. The default simulation resolution is 6 seconds. In other words, a simulation interval is 6 seconds.
410+
The demand loading profile with respect to the departure times of all agents is either constant (start time of the selected demand period) or random (within the selected demand period). The future release will introduce a linear or piece-wise linear loading profile. Path4GMNS only supports one demand period, which must be specified in settings.yml and be corresponding to one from the list of demand_periods. If you need the multi-demand-period support, please use DTALite or [TransOMS](https://github.com/jdlph/TransOMS). The default simulation resolution is 6 seconds. In other words, a simulation interval is 6 seconds.
411411

412412
```yaml
413413
agents:

path4gmns/dtaapi.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,9 @@
2727
raise Exception('Please build the shared library compatible to your OS\
2828
using source files')
2929

30-
_dtalite_engine = ctypes.cdll.LoadLibrary(_dtalite_dll)
31-
_dtalitemm_engine = ctypes.cdll.LoadLibrary(_dtalitemm_dll)
3230

33-
34-
_dtalite_engine.network_assignment.argtypes = [ctypes.c_int,
35-
ctypes.c_int,
36-
ctypes.c_int]
37-
38-
39-
def _emit_log(input_dir='.'):
40-
with open(input_dir + '/log_DTA.txt', 'r') as fp:
31+
def _emit_log(log_file='log_main.txt'):
32+
with open(log_file, 'r') as fp:
4133
for line in fp:
4234
print(line)
4335

@@ -97,6 +89,12 @@ def perform_network_assignment_DTALite(assignment_mode,
9789
assert(column_gen_num>=0)
9890
assert(column_update_num>=0)
9991

92+
_dtalite_engine = ctypes.cdll.LoadLibrary(_dtalite_dll)
93+
_dtalite_engine.network_assignment.argtypes = [ctypes.c_int,
94+
ctypes.c_int,
95+
ctypes.c_int]
96+
97+
10098
print('\nDTALite run starts\n')
10199

102100
if _os.startswith('Windows'):
@@ -141,8 +139,8 @@ def perform_network_assignment_DTALite(assignment_mode,
141139
def run_DTALite():
142140
""" Python interface to call the latest DTALite
143141
144-
This version of DTALite includes all-new Logbook, enhanced scenarios
145-
handling, improved I/O functionality, and so on.
142+
This version of DTALite includes all-new Logbook, enhanced scenario handling,
143+
improved I/O functionality, and so on.
146144
147145
Its source code can be found at https://github.com/asu-trans-ai-lab/DTALite.
148146
@@ -162,10 +160,11 @@ def run_DTALite():
162160
Run it only with data sets from
163161
https://github.com/asu-trans-ai-lab/DTALite/tree/main/dataset_v1.
164162
"""
163+
_dtalitemm_engine = ctypes.cdll.LoadLibrary(_dtalitemm_dll)
165164
print('\nDTALite run starts\n')
166165

167166
proc_dta = Process(target=_dtalitemm_engine.DTALiteAPI())
168-
proc_print = Process(target=_emit_log)
167+
proc_print = Process(target=_emit_log, args='log_DTA.txt')
169168

170169
proc_dta.start()
171170
proc_dta.join()

0 commit comments

Comments
 (0)