Skip to content

Commit 9fa4a1f

Browse files
committed
update usecases and tutorial for release
1 parent a1b3791 commit 9fa4a1f

File tree

4 files changed

+67
-9
lines changed

4 files changed

+67
-9
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,9 @@ DTALite uses arrays rather than STL containers to store columns. These arrays ar
8888
32. Fully optimize the C++ routing engine (v0.9.1)
8989
33. Use the UE result as routing decisions for simulation (v0.9.1)
9090
34. Optimize the column generation module with faster and better UE convergency (v0.9.2)
91-
35. Resolve the potential issue on traversing the last through node in path engine (v0.9.2)
92-
36. Fix the bug on loading columns where link path and node paths are not in the proper order (v0.9.2)
91+
35. Fix the bug on updating the total system travel time (v0.9.2)
92+
36. Resolve the potential issue on traversing the last through node in path engine (v0.9.2)
93+
37. Fix the bug on loading columns where link path and node paths are not in the proper order (v0.9.2)
9394

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

@@ -103,7 +104,7 @@ You are encouraged to join our [Discord Channel](https://discord.gg/JGFMta7kxZ)
103104

104105
## How to Cite
105106

106-
Li, P. and Zhou, X. (2023, February 11). *Path4GMNS*. Retrieved from https://github.com/jdlph/Path4GMNS
107+
Li, P. and Zhou, X. (2023, March 14). *Path4GMNS*. Retrieved from https://github.com/jdlph/Path4GMNS
107108

108109
## References
109110
Lu, C. C., Mahmassani, H. S., Zhou, X. (2009). Equivalent gap function-based reformulation and solution algorithm for the dynamic user equilibrium problem. Transportation Research Part B: Methodological, 43, 345-364.

docs/source/usecases.md

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,14 @@ print('shortest path (link id) of agent, '
154154
pg.output_agent_paths(network)
155155
```
156156

157-
v0.7.2 or higher features finding agent paths under a specific mode defined in settings.yaml. The following example demonstrates this new functionality under mode walk (i.e., w).
157+
v0.7.2 or higher features finding agent paths under a specific mode defined in settings.yml. The following example demonstrates this new functionality under mode walk (i.e., w).
158158
```python
159159
import path4gmns as pg
160160

161-
network = pg.read_network(load_demand=True)
161+
network = pg.read_network()
162+
pg.read_zones(network)
163+
pg.load_demand(network)
164+
162165
network.find_path_for_agents()
163166

164167
# or equivalently network.find_path_for_agents('walk')
@@ -502,7 +505,7 @@ simulation:
502505
resolution: 6
503506
```
504507
505-
perform_column_generation() must be called in the first place to set up path for each agent before simulation.
508+
perform_column_generation() shall be called in the first place to set up path for each agent before simulation.
506509
507510
```Python
508511
import path4gmns as pg
@@ -522,6 +525,26 @@ print('writing agent trajectories')
522525
pg.output_agent_trajectory(network)
523526
```
524527

528+
If you have agent.csv (i.e.columns) from a previous run or DTALite, you can bypass perform_column_generation() and directly load it to conduct simulation.
529+
530+
531+
```python
532+
import path4gmns as pg
533+
534+
network = pg.read_network()
535+
pg.read_zones(network)
536+
pg.load_demand(network)
537+
538+
# load existing UE result
539+
pg.load_columns(network)
540+
# DTA
541+
pg.perform_simple_simulation(network)
542+
print('complete dynamic simulation.\n')
543+
544+
print('writing agent trajectories')
545+
pg.output_agent_trajectory(network)
546+
```
547+
525548
The original implementation introduced in v0.9.0 (that each agent follows the shortest path from origin to destination) has been disabled. If you are still interested in traffic simulation using shortest paths, it can be achieved by setting column_gen_num as 1 and column_update_num as 0 illustrated below.
526549

527550
```Python

tests/demo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,12 +220,12 @@ def test_loading_synthesized_zones_demand():
220220
def test_simulation():
221221
network = pg.read_network(load_demand=True)
222222

223-
# network.find_path_for_agents()
224-
225223
column_gen_num = 10
226224
column_update_num = 10
227225
pg.perform_column_generation(column_gen_num, column_update_num, network)
228226

227+
# you can bypass the above perform_column_generation() and call
228+
# load_columns(network) if you have agent.csv
229229
# pg.load_columns(network)
230230
pg.perform_simple_simulation(network, 'uniform')
231231
print('complete simple simulation.\n')

tests/tutorial.ipynb

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@
178178
]
179179
},
180180
{
181+
"attachments": {},
181182
"cell_type": "markdown",
182183
"id": "stuffed-roman",
183184
"metadata": {},
@@ -186,7 +187,7 @@
186187
"\n",
187188
"Agents are disaggregated demand using the aggregated travel demand between each OD pair, which is specified in demand.csv. Individual agents will be automatically set up via find_path_for_agents() on its first call.\n",
188189
"\n",
189-
"You will need both **demand.csv** and **zone.csv** to proceed. As our sample data sets **DO NOT have zone.csv**, please go through the following step to synthesize zones and OD demand matrix in the first place. Note that it will overwrite any existing zone.csv and demand.csv if you have them."
190+
"You will need both **demand.csv** and **zone.csv** to proceed. As our sample data sets **DO NOT have zone.csv**, please go through the following step to synthesize zones and OD demand matrix in the first place. Note that it will **OVERWRITE** any existing zone.csv and demand.csv if you have them."
190191
]
191192
},
192193
{
@@ -574,6 +575,39 @@
574575
"pg.output_agent_trajectory(network)"
575576
]
576577
},
578+
{
579+
"attachments": {},
580+
"cell_type": "markdown",
581+
"id": "56045828",
582+
"metadata": {},
583+
"source": [
584+
"If you have agent.csv (i.e., columns) from a previous run or DTALite, you can bypass perform_column_generation() and directly load it to conduct simulation."
585+
]
586+
},
587+
{
588+
"cell_type": "code",
589+
"execution_count": null,
590+
"id": "2653b889",
591+
"metadata": {},
592+
"outputs": [],
593+
"source": [
594+
"\n",
595+
"import path4gmns as pg\n",
596+
"\n",
597+
"network = pg.read_network()\n",
598+
"pg.read_zones(network)\n",
599+
"pg.load_demand(network)\n",
600+
"\n",
601+
"# load existing UE result\n",
602+
"pg.load_columns(network)\n",
603+
"# DTA\n",
604+
"pg.perform_simple_simulation(network)\n",
605+
"print('complete dynamic simulation.\\n')\n",
606+
"\n",
607+
"print('writing agent trajectories')\n",
608+
"pg.output_agent_trajectory(network)\n"
609+
]
610+
},
577611
{
578612
"cell_type": "markdown",
579613
"id": "signed-marsh",

0 commit comments

Comments
 (0)