Skip to content

Commit

Permalink
Merge pull request #32 from toruseo/develop
Browse files Browse the repository at this point in the history
Add import from OSM [experimental], new demand setup functions
  • Loading branch information
toruseo authored Mar 14, 2024
2 parents 99537fd + aac4dc7 commit 4b66c47
Show file tree
Hide file tree
Showing 6 changed files with 1,379 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/run-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ jobs:
- name: Install uxsim and dependencies
run: pip install .
- name: Install pytest other dependencies
run: pip install pytest setuptools gymnasium torch
run: pip install pytest setuptools gymnasium torch osmnx
- name: Run examples with pytest
run: pytest demos_and_examples/test_examples.py --durations=0
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ your_project_directory/
│ ├── utils/ # Utility files of UXsim
│ ├── uxsim.py # The main code of UXsim. You can customize this as you wish
│ ├── utils.py # Utility funcsions of UXsim
│ └── ...
├── your_simulation_code.py # Your code
├── your_simulation_notebook.ipynb # Your Jupyter notebook
├── ...
│ └── ... # Other files in uxsim
├── your_simulation_code.py # Your code if nessesary
├── your_simulation_notebook.ipynb # Your Jupyter notebook if nessesary
├── ... # Other files if nessesary
```
In this way, you can flexibly customize UXsim by your own.

Expand Down Expand Up @@ -194,9 +194,15 @@ The right is with DRL control scenario, where traffic signal can be changed by o

## Future Plans

- multi-lane link
- Note: The current model assumes that all links are 1 lane, and the reaction time of all drivers are the same. This means that all links have more or less the same capacity. It is not possible to model multi-lane links that have 2 or 3 times the capacity of 1-lane links. This is a theoretical limitation.
- Workarounds for the current model:
- Create multiple links between same node pair; each link corresponds to each lane between the nodes. This is a reasonable solution. However, the analysis becomes tedious.
- Reduce `capacity_out` parameter of `Link`. In this way, we can place a bottleneck to the end of a link, so that capacities of links can vary significantly. However, it only reduce the capacity. Also, the jam propagation speed becomes too fast or slow.
- day-to-day dynamics
- taxi and shared mobility (i.e., vehicles travel through a network by passing through specific nodes that are dynamically updated)
- network import from OSMnx
- Done, but still experimental.
- basemap for visualization
- modern packaging

Expand All @@ -211,7 +217,7 @@ When publishing works based on from UXsim, please cite:

## Acknowledgments

UXsim is based on various works in traffic flow theory. We would like to acknowledge the contributions of the transportation research community in advancing the this field.
UXsim is based on various works in traffic flow theory. We would like to acknowledge the contributions of the research community in advancing this field.

## Related Links

Expand Down
440 changes: 440 additions & 0 deletions demos_and_examples/demo_notebook_04en_OpenStreetMap.ipynb

Large diffs are not rendered by default.

33 changes: 33 additions & 0 deletions demos_and_examples/example_16_import_from_OpenStreetMap.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from uxsim import *


W = World(
name="",
deltan=5,
tmax=7200,
print_mode=1, save_mode=1, show_mode=0,
random_seed=0
)

#Tokyo highway
nodes, links = OSMImporter.import_osm_data(north=35.817, south=35.570, east=139.881, west=139.583, custom_filter='["highway"~"motorway"]')
nodes, links = OSMImporter.osm_network_postprocessing(nodes, links, node_merge_threshold=0.005, node_merge_iteration=5, enforce_bidirectional=True) # merge threshold distance: 0.005 degree ~= 500 m. `enforce_bidirectional` makes all links bidirectional, so that network is not fragmented (but the original network topology is not preserved rigorously).
OSMImporter.osm_network_visualize(nodes, links, show_link_name=0)
OSMImporter.osm_network_to_World(W, nodes, links, default_jam_density=0.2, coef_degree_to_meter=111000)

# set demand to central Tokyo from surroundings
W.adddemand_area2area(139.70, 35.60, 0, 139.75, 35.68, 0.05, 0, 3600, volume=5000)
W.adddemand_area2area(139.65, 35.70, 0, 139.75, 35.68, 0.05, 0, 3600, volume=5000)
W.adddemand_area2area(139.75, 35.75, 0, 139.75, 35.68, 0.05, 0, 3600, volume=5000)
W.adddemand_area2area(139.85, 35.70, 0, 139.75, 35.68, 0.05, 0, 3600, volume=5000)

W.exec_simulation()

W.analyzer.print_simple_stats()
for t in list(range(0,W.TMAX,int(W.TMAX/6))):
W.analyzer.network(t, detailed=0, network_font_size=0, figsize=(6,6))

W.analyzer.network_anim(animation_speed_inverse=15, detailed=0, network_font_size=0)
W.analyzer.network_fancy(animation_speed_inverse=15, sample_ratio=0.1, interval=10, trace_length=5)

W.analyzer.output_data()
Loading

0 comments on commit 4b66c47

Please sign in to comment.