UXsim
UXsim: lightweight mesoscopic traffic flow simulator in pure Python - Published in JOSS (2025)
Science Score: 100.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 21 DOI reference(s) in README and JOSS metadata -
✓Academic publication links
Links to: arxiv.org, joss.theoj.org -
✓Committers with academic emails
1 of 4 committers (25.0%) from academic institutions -
○Institutional organization owner
-
✓JOSS paper metadata
Published in Journal of Open Source Software
Keywords
Keywords from Contributors
Repository
Vehicular traffic flow simulator in road network, written in pure Python
Basic Info
- Host: GitHub
- Owner: toruseo
- License: mit
- Language: Python
- Default Branch: main
- Homepage: https://toruseo.jp/UXsim/docs/
- Size: 312 MB
Statistics
- Stars: 194
- Watchers: 1
- Forks: 73
- Open Issues: 8
- Releases: 31
Topics
Metadata Files
README.jp.md
UXsim: Python製のマクロ・メソ交通流シミュレータ
UXsimはPython製のオープンソース・フリーなマクロ・メソ交通流シミュレータです. これは,都市規模のような大局的な自動車交通とその渋滞を再現する交通シミュレーションであり,交通工学分野で標準的なモデルにより道路ネットワークの動的交通流を計算するものです. UXsimは単純,軽量,柔軟であるため,研究・教育上の目的に適することを意図していますが,それ以外の目的にも自由に使用可能です.
興味がある方は以下をご覧ください:
- Jupyter NotebookデモまたはGoogle Colabデモ:インタラクティブなデモとチュートリアル
- 詳細ページ(チュートリアル,仕様):チュートリアル,シミュレーションメカニズム,モジュール/関数の仕様に関する詳細なドキュメント
主な機能・特徴
- 標準的なネットワーク交通流モデルの,単純かつ容易に使えるPython実装
- マクロ交通流シミュレーション:30秒で都市の6万台の車両をシミュレート.あるいは,設定次第で40秒で都市圏の100万台のシミュレーションも可能
- 動的交通量配分:ネットワーク構造と時間帯別OD需要が与えられているときに,動的なネットワーク交通流を計算
- 学術/専門的交通研究で一般的に使用される理論的に有効なモデル
- タクシー/シェアモビリティ,信号制御,道路課金などの交通制御/管理スキームの実装
- シミュレーション結果の基本的な分析と
pandas.DataFrame,CSVへのエクスポート Matplotlibを使用したシミュレーション結果の可視化.インタラクティブなGUIも利用可能- 純Pythonであることを活かした高度なカスタマイズ性.
PyTorchを用いた深層強化学習による交通制御など,他のPythonベースのフレームワークとも直接連携可能 - メインコードの
uxsim.pyは約2300行のコードのみ.ユーザーが簡単に理解しカスタマイズできます
計算例
大規模ネットワーク
10km x 10kmのグリッドネットワーク内を2時間で約6万台が通行する様子.計算時間は通常のデスクトップPCで約30秒.
リンク交通状況(リンクの線が太いと車両台数が多く,色が暗いと速度が遅い)と一部車両の軌跡:
上記ネットワークのある回廊上の車両軌跡図:

深層強化学習(AI)による信号制御
信号制御をPyTorchの深層強化学習によって効率化する例です. 下の左図は単純な固定時間の信号の場合で,交通需要がネットワーク容量を上回りグリッドロックが生じています. 右図は深層強化学習を適用した場合で,需要レベルが同じであるのに関わらず効率的な交通が実現しています. このコードはJupyter Notebookにもまとめてあります.
シミュレーション結果可視化GUI
https://github.com/toruseo/UXsim/assets/34780089/ec780a33-d9ba-4068-a005-0b06127196d9
インストール
Python 3.9以降に対応しています.
pipを使用
最も簡単な方法は,PyPIからpipを使用してインストールすることです.
pip install uxsim
condaを使用
conda-forgeチャンネルからcondaを使用してインストールすることもできます:
conda install uxsim
詳細についてはこちらをご覧ください.
上級ユーザー向けの代替方法(クリックして表示)
### カスタム設定でpipを使用 GitHubバージョンをインストールするには,`pip`も使用できます: ``` pip install -U -e git+https://github.com/toruseo/uxsim@main#egg=uxsim ``` または,このリポジトリの他の(開発中の)ブランチや自分のフォークでも: ``` pip install -U -e git+https://github.com/YOUR_FORK/uxsim@YOUR_BRANCH#egg=uxsim ``` ### 手動インストール このGithubリポジトリから`uxsim`ディレクトリをダウンロードするか,[最新リリース](https://github.com/toruseo/UXsim/releases/latest/download/uxsim.zip)からダウンロードして,以下のようにローカルディレクトリに配置します: ``` your_project_directory/ ├── uxsim/ # uxsimディレクトリ │ ├── uxsim.py # UXsimのメインコード.必要に応じてカスタマイズ可能 │ └── ... # uxsim内の他のファイルやディレクトリ ├── your_simulation_code.py # 自作コード(必要なら) ├── your_simulation_notebook.ipynb # 自作Jupyterノートブック(必要なら) ├── ... # 必要に応じて他のファイルも置ける ``` この方法で,UXsimを自分の好みに合わせて柔軟にカスタマイズできます.使用法
単純な例として,Y字型の合流ネットワークのシミュレーションシナリオを以下に示します: ```python from uxsim import *
シミュレーション本体の定義
単位は全て秒とメートル
W = World( name="", # シナリオ名 deltan=5, # 車両集計単位 tmax=1200, # シミュレーション時間 printmode=1, savemode=1, showmode=0, # オプション randomseed=0 # ランダムシード )
シナリオ定義
ノードの作成
W.addNode(name="orig1", x=0, y=0) W.addNode("orig2", 0, 2) W.addNode("merge", 1, 1) W.addNode("dest", 2, 1)
ノード間のリンクの作成
W.addLink(name="link1", startnode="orig1", endnode="merge", length=1000, freeflowspeed=20, numberoflanes=1) W.addLink("link2", "orig2", "merge", length=1000, freeflowspeed=20, numberoflanes=1) W.addLink("link3", "merge", "dest", length=1000, freeflowspeed=20, numberoflanes=1)
ノード間のOD交通需要の作成
W.adddemand(orig="orig1", dest="dest", tstart=0, tend=1000, flow=0.45) W.adddemand("orig2", "dest", 400, 1000, 0.6)
シミュレーション実行
W.exec_simulation()
結果表示
W.analyzer.printsimplestats()
ネットワーク交通状態のスナップショット可視化
W.analyzer.network(100, detailed=1, networkfontsize=12) W.analyzer.network(600, detailed=1, networkfontsize=12) W.analyzer.network(800, detailed=1, networkfontsize=12) ```
これは以下の結果を出力します:
simulation setting:
scenario name:
simulation duration: 1200 s
number of vehicles: 810 veh
total road length: 3000 m
time discret. width: 5 s
platoon size: 5 veh
number of timesteps: 240
number of platoons: 162
number of links: 3
number of nodes: 4
setup time: 0.00 s
simulating...
time| # of vehicles| ave speed| computation time
0 s| 0 vehs| 0.0 m/s| 0.00 s
600 s| 130 vehs| 13.7 m/s| 0.03 s
1195 s| 75 vehs| 12.3 m/s| 0.06 s
simulation finished
results:
average speed: 11.6 m/s
number of completed trips: 735 / 810
average travel time of trips: 162.6 s
average delay of trips: 62.6 s
delay ratio: 0.385
さらなる情報
UXsimについてさらに学ぶには,以下をご覧ください:
- Jupyter NotebookデモまたはGoogle Colabデモ:インタラクティブなデモ
- デモと例:Jupyter NotebookとPythonコードを使用した様々な例
- UXsim技術資料:チュートリアル,シミュレーションメカニズム,モジュール/関数の仕様に関する詳細なドキュメント
- arXivプレプリント:科学的な概要
- Qiita記事:わかりやすい概要
主なファイル構成
uxsimディレクトリ: UXsim本体のパッケージuxsim/uxsim.py: UXsimのメインコード
demos_and_examplesディレクトリ: チュートリアルや使用例datディレクトリ: サンプルシナリオファイル
使用条件・ライセンス
UXsimはMIT Licenseのもとで公開しています. 出典を明記すれば自由に使用できます.
使用された成果を発表される際は,参考文献として以下を引用してください:
- Toru Seo. UXsim: lightweight mesoscopic traffic flow simulator in pure Python. Journal of Open Source Software, Vol. 10, No. 106, p. 7617, 2025.
より詳細な説明が必要であれば以下も引用してください: - 瀬尾亨. マクロ交通流シミュレーション:数学的基礎理論とPythonによる実装. コロナ社, 2023. - Toru Seo. UXsim: An open source macroscopic and mesoscopic traffic simulator in Python-a technical overview. arXiv preprint arXiv: 2309.17114, 2023.
UXsimを使用した研究はGithubのwikiページにまとめられています.自由に編集してください.
更新と質問・議論
コード更新のcontributionは大歓迎です! 貢献ガイドラインをご覧ください.
質問や提案がある場合は,IssuesまたはDiscussionsページに投稿してください(言語は英語または日本語).
私(瀬尾亨)は仕事の合間にこのプロジェクトに取り組んでいます. 反応が遅れる可能性があることをご了承ください.
謝辞
UXsimは交通流理論と関連分野の様々な研究成果に基づいています.この分野を進展させてきた研究コミュニティに感謝いたします. 特に,UXsimは以下の研究成果を直接利用しています:
- Newellの単純追従モデルとその拡張版Xモデル
- Incremental Node Modelとそのメソスコピック版
- Dynamic User Optimum型経路選択モデル
関連リンク
Owner
- Name: Toru Seo
- Login: toruseo
- Kind: user
- Location: Tokyo, Japan
- Company: Tokyo Institute of Technology
- Website: https://toruseo.github.io/
- Repositories: 2
- Profile: https://github.com/toruseo
JOSS Publication
UXsim: lightweight mesoscopic traffic flow simulator in pure Python
Authors
Tags
transportation traffic flow civil engineering simulationCitation (CITATION.cff)
cff-version: "1.2.0"
authors:
- family-names: Seo
given-names: Toru
orcid: "https://orcid.org/0000-0001-9767-7218"
doi: 10.5281/zenodo.14799163
message: If you use this software, please cite our article in the
Journal of Open Source Software.
preferred-citation:
authors:
- family-names: Seo
given-names: Toru
orcid: "https://orcid.org/0000-0001-9767-7218"
date-published: 2025-02-06
doi: 10.21105/joss.07617
issn: 2475-9066
issue: 106
journal: Journal of Open Source Software
publisher:
name: Open Journals
start: 7617
title: "UXsim: lightweight mesoscopic traffic flow simulator in pure
Python"
type: article
url: "https://joss.theoj.org/papers/10.21105/joss.07617"
volume: 10
title: "UXsim: lightweight mesoscopic traffic flow simulator in pure
Python"
GitHub Events
Total
- Create event: 25
- Release event: 10
- Issues event: 32
- Watch event: 63
- Delete event: 13
- Issue comment event: 61
- Push event: 181
- Pull request review event: 4
- Gollum event: 8
- Pull request event: 102
- Fork event: 17
Last Year
- Create event: 25
- Release event: 10
- Issues event: 32
- Watch event: 63
- Delete event: 13
- Issue comment event: 61
- Push event: 181
- Pull request review event: 4
- Gollum event: 8
- Pull request event: 102
- Fork event: 17
Committers
Last synced: 5 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Toru Seo | 3****o | 390 |
| Ewout ter Hoeven | E****n@s****l | 12 |
| dependabot[bot] | 4****] | 5 |
| bruh | 1****h@g****m | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 4 months ago
All Time
- Total issues: 48
- Total pull requests: 288
- Average time to close issues: 30 days
- Average time to close pull requests: 2 days
- Total issue authors: 6
- Total pull request authors: 6
- Average comments per issue: 3.02
- Average comments per pull request: 0.57
- Merged pull requests: 241
- Bot issues: 0
- Bot pull requests: 19
Past Year
- Issues: 22
- Pull requests: 141
- Average time to close issues: 25 days
- Average time to close pull requests: 4 days
- Issue authors: 5
- Pull request authors: 6
- Average comments per issue: 1.86
- Average comments per pull request: 0.79
- Merged pull requests: 111
- Bot issues: 0
- Bot pull requests: 17
Top Authors
Issue Authors
- toruseo (22)
- EwoutH (21)
- Nitnelav (2)
- Bolin-Z (1)
- apiszcz (1)
- araiari (1)
Pull Request Authors
- toruseo (223)
- EwoutH (39)
- dependabot[bot] (19)
- fxjung (4)
- TheBruh141 (2)
- Copilot (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- pypi 690 last-month
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 31
- Total maintainers: 1
pypi.org: uxsim
UXsim: traffic flow simulator
- Homepage: https://github.com/toruseo/UXsim
- Documentation: https://toruseo.jp/UXsim/docs
- License: mit
-
Latest release: 1.9.1
published 4 months ago
