TraffiSim 0.1.0__tar.gz → 0.1.1__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- traffisim-0.1.1/PKG-INFO +237 -0
- traffisim-0.1.1/TraffiSim.egg-info/PKG-INFO +237 -0
- traffisim-0.1.1/setup.py +37 -0
- traffisim-0.1.0/PKG-INFO +0 -21
- traffisim-0.1.0/TraffiSim.egg-info/PKG-INFO +0 -21
- traffisim-0.1.0/setup.py +0 -30
- {traffisim-0.1.0 → traffisim-0.1.1}/LICENSE +0 -0
- {traffisim-0.1.0 → traffisim-0.1.1}/README.md +0 -0
- {traffisim-0.1.0 → traffisim-0.1.1}/TraffiSim.egg-info/SOURCES.txt +0 -0
- {traffisim-0.1.0 → traffisim-0.1.1}/TraffiSim.egg-info/dependency_links.txt +0 -0
- {traffisim-0.1.0 → traffisim-0.1.1}/TraffiSim.egg-info/entry_points.txt +0 -0
- {traffisim-0.1.0 → traffisim-0.1.1}/TraffiSim.egg-info/requires.txt +0 -0
- {traffisim-0.1.0 → traffisim-0.1.1}/TraffiSim.egg-info/top_level.txt +0 -0
- {traffisim-0.1.0 → traffisim-0.1.1}/setup.cfg +0 -0
- {traffisim-0.1.0 → traffisim-0.1.1}/tests/test_basic.py +0 -0
- {traffisim-0.1.0 → traffisim-0.1.1}/traffisim/__init__.py +0 -0
- {traffisim-0.1.0 → traffisim-0.1.1}/traffisim/analyzer.py +0 -0
- {traffisim-0.1.0 → traffisim-0.1.1}/traffisim/intersection.py +0 -0
- {traffisim-0.1.0 → traffisim-0.1.1}/traffisim/models.py +0 -0
- {traffisim-0.1.0 → traffisim-0.1.1}/traffisim/rendering.py +0 -0
- {traffisim-0.1.0 → traffisim-0.1.1}/traffisim/run.py +0 -0
- {traffisim-0.1.0 → traffisim-0.1.1}/traffisim/utils.py +0 -0
traffisim-0.1.1/PKG-INFO
ADDED
@@ -0,0 +1,237 @@
|
|
1
|
+
Metadata-Version: 2.2
|
2
|
+
Name: TraffiSim
|
3
|
+
Version: 0.1.1
|
4
|
+
Summary: A modular intersection traffic simulator with IDM, MOBIL, and adaptive signals
|
5
|
+
Author: A. Sharan
|
6
|
+
Requires-Python: >=3.7
|
7
|
+
Description-Content-Type: text/markdown
|
8
|
+
License-File: LICENSE
|
9
|
+
Requires-Dist: pygame>=2.0.0
|
10
|
+
Provides-Extra: rendering
|
11
|
+
Requires-Dist: pygame>=2.0.0; extra == "rendering"
|
12
|
+
Provides-Extra: analysis
|
13
|
+
Requires-Dist: streamlit; extra == "analysis"
|
14
|
+
Requires-Dist: pandas; extra == "analysis"
|
15
|
+
Requires-Dist: plotly; extra == "analysis"
|
16
|
+
Requires-Dist: seaborn; extra == "analysis"
|
17
|
+
Requires-Dist: matplotlib; extra == "analysis"
|
18
|
+
Dynamic: author
|
19
|
+
Dynamic: description
|
20
|
+
Dynamic: description-content-type
|
21
|
+
Dynamic: provides-extra
|
22
|
+
Dynamic: requires-dist
|
23
|
+
Dynamic: requires-python
|
24
|
+
Dynamic: summary
|
25
|
+
|
26
|
+
# TraffiSim
|
27
|
+
TraffiSim is a Python-based intersection traffic simulator designed to capture various driving behaviors (including Indian driving styles and multi-lane configurations) that might not be fully addressed by large-scale simulators like SUMO. It uses the Intelligent Driver Model (IDM) for longitudinal control, MOBIL for lane changes, and supports both adaptive and fixed traffic signal strategies.
|
28
|
+
|
29
|
+
## Table of Contents
|
30
|
+
- [Why TraffiSim?](#why-traffisim)
|
31
|
+
- [Features](#features)
|
32
|
+
- [Technical Overview](#technical-overview)
|
33
|
+
- [Installation](#installation)
|
34
|
+
- [Usage](#usage)
|
35
|
+
- [Using in Python Scripts](#using-in-python-scripts)
|
36
|
+
- [Simulation Parameters](#simulation-parameters)
|
37
|
+
- [Customization](#customization)
|
38
|
+
- [Comparison to Other Tools (SUMO, etc.)](#comparison-to-other-tools-sumo-etc)
|
39
|
+
- [Limitations & Future Work](#limitations--future-work)
|
40
|
+
- [Contributing](#contributing)
|
41
|
+
- [License](#license)
|
42
|
+
|
43
|
+
## Why TraffiSim?
|
44
|
+
|
45
|
+
While powerful traffic simulators exist—such as SUMO, MATSim, and Aimsun—they are often complex to install, configure, and extend. In addition, many of these simulators do not provide country-specific behaviors (e.g., Indian driving styles with freer lateral movement, two-wheelers navigating queues side-by-side, etc.) out of the box.
|
46
|
+
|
47
|
+
TraffiSim was created to address these needs:
|
48
|
+
|
49
|
+
### India-Specific Queueing & Lateral Movement
|
50
|
+
- Incorporates concepts like India Mode for simulating two-wheelers and small vehicles weaving side-by-side in queues.
|
51
|
+
|
52
|
+
### Lightweight & Extensible
|
53
|
+
- Focuses on intersection-level simulation, making it easy to add new driving rules or tweak existing ones.
|
54
|
+
|
55
|
+
### Educational & Rapid Prototyping
|
56
|
+
- A simpler codebase suitable for teaching traffic engineering or quickly prototyping new signal control strategies.
|
57
|
+
|
58
|
+
## Features
|
59
|
+
- **Multiple Vehicle Types:** Cars, scooters, motorcycles, trucks, buses (with configurable parameters).
|
60
|
+
- **IDM & MOBIL:** Intelligent Driver Model for speed control, and MOBIL for lane-change decisions.
|
61
|
+
- **Adaptive or Fixed Signals:** Choose between a simple queue-based adaptive or a time-based fixed cycle strategy.
|
62
|
+
- **Multi-Lane Support:** Allows 1 to N lanes in each direction.
|
63
|
+
- **“India Mode”:** Enables side-by-side queueing for two-wheelers and small vehicles.
|
64
|
+
- **Optionally Simulate Full Routes:** Vehicles can vanish at the intersection center or continue to an exit point.
|
65
|
+
- **Pygame Visualization:** Observe your simulation in real-time or disable it for headless runs.
|
66
|
+
- **Data Collection:** Logs queue length, arrival rates, wait times, and more in CSV format for analysis.
|
67
|
+
## Technical Overview
|
68
|
+
TraffiSim’s code is organized into several Python modules:
|
69
|
+
|
70
|
+
**intersection.py**:
|
71
|
+
- Core logic for arrivals, queues, traffic lights, adaptive/fixed signal control, and data recording.
|
72
|
+
- Main class: `IntersectionSim`.
|
73
|
+
|
74
|
+
**models.py**:
|
75
|
+
- Vehicle-level logic, including IDM for longitudinal control, MOBIL for lane changing.
|
76
|
+
- Holds default parameters in `DEFAULT_VEHICLE_TYPES`.
|
77
|
+
|
78
|
+
**rendering.py**:
|
79
|
+
- Uses Pygame for drawing roads, vehicles, signals, and queue lines if `show_visuals=True`.
|
80
|
+
- Entirely optional (the simulator can run without visualization).
|
81
|
+
|
82
|
+
**run.py**:
|
83
|
+
- High-level function `run_multiple_simulations` that can be called multiple times with varying parameters.
|
84
|
+
- A minimal `main_cli()` function for a command-line interface.
|
85
|
+
|
86
|
+
**utils.py**:
|
87
|
+
- Simple helper functions for geometry (e.g., distance calculations) and exit point definitions.
|
88
|
+
|
89
|
+
The Intelligent Driver Model (IDM) controls acceleration based on the gap to the lead vehicle, desired speeds, and comfortable deceleration. MOBIL checks whether lane changes are beneficial and safe based on accelerations for the subject vehicle and adjacent vehicles.
|
90
|
+
|
91
|
+
## Installation
|
92
|
+
### A) From Source (Local Development)
|
93
|
+
|
94
|
+
Clone the repository:
|
95
|
+
```bash
|
96
|
+
git clone https://github.com/AHSharan/TraffiSim.git
|
97
|
+
cd TraffiSim
|
98
|
+
```
|
99
|
+
Install with pip:
|
100
|
+
```bash
|
101
|
+
pip install .
|
102
|
+
```
|
103
|
+
To include Pygame automatically, install the optional `[rendering]` extras:
|
104
|
+
```bash
|
105
|
+
pip install .[rendering]
|
106
|
+
```
|
107
|
+
|
108
|
+
### B) Installing from PyPI
|
109
|
+
You can install TraffiSim directly from the Python Package Index (PyPI):
|
110
|
+
```bash
|
111
|
+
pip install TraffiSim
|
112
|
+
```
|
113
|
+
If you want to include Pygame (used for visualization) right away, install the `[rendering]` extra:
|
114
|
+
```bash
|
115
|
+
pip install TraffiSim[rendering]
|
116
|
+
```
|
117
|
+
Note: If you only need to run headless simulations (no graphics), you don’t need the extra.
|
118
|
+
|
119
|
+
Once installed, verify by running:
|
120
|
+
```bash
|
121
|
+
traffisim-run
|
122
|
+
```
|
123
|
+
This will execute a default simulation with minimal parameters.
|
124
|
+
|
125
|
+
You can then use TraffiSim in your own Python scripts:
|
126
|
+
```python
|
127
|
+
from traffisim.run import run_multiple_simulations
|
128
|
+
|
129
|
+
run_multiple_simulations(
|
130
|
+
N_runs=1,
|
131
|
+
total_time=300,
|
132
|
+
multiple_lanes=True,
|
133
|
+
lane_count=3,
|
134
|
+
show_visuals=True, # True requires pygame
|
135
|
+
adaptive_signals=True,
|
136
|
+
)
|
137
|
+
```
|
138
|
+
|
139
|
+
## Usage
|
140
|
+
### Using in Python Scripts
|
141
|
+
You can run simulations programmatically:
|
142
|
+
```python
|
143
|
+
from traffisim.run import run_multiple_simulations
|
144
|
+
|
145
|
+
run_multiple_simulations(
|
146
|
+
N_runs=1,
|
147
|
+
junction_type="4way",
|
148
|
+
total_time=600,
|
149
|
+
show_visuals=True,
|
150
|
+
multiple_lanes=True,
|
151
|
+
lane_count=3,
|
152
|
+
adaptive_signals=True,
|
153
|
+
india_mode=True,
|
154
|
+
save_to_files=False
|
155
|
+
)
|
156
|
+
```
|
157
|
+
Or instantiate `IntersectionSim` directly:
|
158
|
+
```python
|
159
|
+
from traffisim.intersection import IntersectionSim
|
160
|
+
from traffisim.rendering import TrafficRenderer
|
161
|
+
|
162
|
+
sim = IntersectionSim(
|
163
|
+
junction_type="4way",
|
164
|
+
multiple_lanes=True,
|
165
|
+
lane_count=2,
|
166
|
+
total_time=300,
|
167
|
+
show_visuals=True,
|
168
|
+
renderer_class=TrafficRenderer,
|
169
|
+
india_mode=False,
|
170
|
+
adaptive_signals=True
|
171
|
+
)
|
172
|
+
sim.run()
|
173
|
+
```
|
174
|
+
|
175
|
+
## Simulation Parameters
|
176
|
+
Commonly adjusted parameters:
|
177
|
+
|
178
|
+
| Parameter | Default | Description |
|
179
|
+
|-----------------------|------------|-----------------------------------------------------------------------------|
|
180
|
+
| `junction_type` | "4way" | Intersection type: "4way" or "3way". |
|
181
|
+
| `multiple_lights` | False | Use a single traffic light vs. per-approach lights. |
|
182
|
+
| `total_time` | 300 | Number of simulation steps. |
|
183
|
+
| `sim_steps_per_sec` | 10 | Internal sub-step resolution (10 or 1). |
|
184
|
+
| `simulation_speed` | 30 | Frame rate in Pygame visualization. |
|
185
|
+
| `multiple_lanes` | False | Whether each approach has multiple lanes. |
|
186
|
+
| `lane_count` | 2 | Number of lanes per approach if multiple lanes are enabled. |
|
187
|
+
| `india_mode` | False | Allow side-by-side queue for two-wheelers or small vehicles. |
|
188
|
+
| `adaptive_signals` | True | Use a simple adaptive signal logic vs. fixed-cycle approach. |
|
189
|
+
| `simulate_full_route` | True | Vehicles continue from entry to exit points; if False, they vanish center. |
|
190
|
+
| `vehicle_distribution`| dict | Probability distribution for vehicle types (car, scooter, etc.). |
|
191
|
+
| `save_to_files` | True | Save simulation data to CSV. |
|
192
|
+
| `output_folder` | "simulation_outputs" | Directory for saving CSV outputs. |
|
193
|
+
|
194
|
+
## Customization
|
195
|
+
**New Vehicle Types**
|
196
|
+
Add entries in `DEFAULT_VEHICLE_TYPES` in `models.py` with parameters like `desired_speed`, `max_acceleration`, etc.
|
197
|
+
|
198
|
+
**Signal Logic**
|
199
|
+
Default adaptive logic chooses phases based on queue length. Edit `choose_new_green()` in `intersection.py`.
|
200
|
+
|
201
|
+
**Queue Behaviors (India Mode)**
|
202
|
+
For complex lateral movement, modify `reposition_queue()` in `intersection.py`.
|
203
|
+
|
204
|
+
**Saving & Analyzing Data**
|
205
|
+
Per-step data in `sim.per_timestep_data`; summary in `sim.get_results_dict()`. Customize columns or CSV writing in `run.py`.
|
206
|
+
|
207
|
+
## Comparison to Other Tools (SUMO, etc.)
|
208
|
+
**SUMO:**
|
209
|
+
- Large-scale, open-source traffic simulator.
|
210
|
+
- TraffiSim focuses on intersection-level details like 2D positioning for Indian driving patterns.
|
211
|
+
|
212
|
+
**MATSim / Aimsun:**
|
213
|
+
- Large or commercial simulators for multi-agent, city-scale traffic.
|
214
|
+
- TraffiSim is simpler and specialized for intersection-based experiments.
|
215
|
+
|
216
|
+
## Limitations & Future Work
|
217
|
+
- **Geometry:** Physical turn radii or collisions not deeply simulated.
|
218
|
+
- **No Traffic Signal Optimization:** Basic queue-based adaptive approach.
|
219
|
+
- **Single Intersection Focus:** Multi-intersection networks need extensions.
|
220
|
+
- **Performance:** High vehicle counts may impact performance.
|
221
|
+
|
222
|
+
## Contributing
|
223
|
+
Ideas for contribution include:
|
224
|
+
- Machine learning or optimization for signals
|
225
|
+
- More realistic India Mode dynamics
|
226
|
+
- Network-level expansions
|
227
|
+
- Additional vehicle classes (auto-rickshaws, e-bikes)
|
228
|
+
|
229
|
+
Submit pull requests or open issues on GitHub.
|
230
|
+
|
231
|
+
## License
|
232
|
+
TraffiSim is under the GNU License.
|
233
|
+
Feel free to use, modify, and distribute with attribution.
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
|
@@ -0,0 +1,237 @@
|
|
1
|
+
Metadata-Version: 2.2
|
2
|
+
Name: TraffiSim
|
3
|
+
Version: 0.1.1
|
4
|
+
Summary: A modular intersection traffic simulator with IDM, MOBIL, and adaptive signals
|
5
|
+
Author: A. Sharan
|
6
|
+
Requires-Python: >=3.7
|
7
|
+
Description-Content-Type: text/markdown
|
8
|
+
License-File: LICENSE
|
9
|
+
Requires-Dist: pygame>=2.0.0
|
10
|
+
Provides-Extra: rendering
|
11
|
+
Requires-Dist: pygame>=2.0.0; extra == "rendering"
|
12
|
+
Provides-Extra: analysis
|
13
|
+
Requires-Dist: streamlit; extra == "analysis"
|
14
|
+
Requires-Dist: pandas; extra == "analysis"
|
15
|
+
Requires-Dist: plotly; extra == "analysis"
|
16
|
+
Requires-Dist: seaborn; extra == "analysis"
|
17
|
+
Requires-Dist: matplotlib; extra == "analysis"
|
18
|
+
Dynamic: author
|
19
|
+
Dynamic: description
|
20
|
+
Dynamic: description-content-type
|
21
|
+
Dynamic: provides-extra
|
22
|
+
Dynamic: requires-dist
|
23
|
+
Dynamic: requires-python
|
24
|
+
Dynamic: summary
|
25
|
+
|
26
|
+
# TraffiSim
|
27
|
+
TraffiSim is a Python-based intersection traffic simulator designed to capture various driving behaviors (including Indian driving styles and multi-lane configurations) that might not be fully addressed by large-scale simulators like SUMO. It uses the Intelligent Driver Model (IDM) for longitudinal control, MOBIL for lane changes, and supports both adaptive and fixed traffic signal strategies.
|
28
|
+
|
29
|
+
## Table of Contents
|
30
|
+
- [Why TraffiSim?](#why-traffisim)
|
31
|
+
- [Features](#features)
|
32
|
+
- [Technical Overview](#technical-overview)
|
33
|
+
- [Installation](#installation)
|
34
|
+
- [Usage](#usage)
|
35
|
+
- [Using in Python Scripts](#using-in-python-scripts)
|
36
|
+
- [Simulation Parameters](#simulation-parameters)
|
37
|
+
- [Customization](#customization)
|
38
|
+
- [Comparison to Other Tools (SUMO, etc.)](#comparison-to-other-tools-sumo-etc)
|
39
|
+
- [Limitations & Future Work](#limitations--future-work)
|
40
|
+
- [Contributing](#contributing)
|
41
|
+
- [License](#license)
|
42
|
+
|
43
|
+
## Why TraffiSim?
|
44
|
+
|
45
|
+
While powerful traffic simulators exist—such as SUMO, MATSim, and Aimsun—they are often complex to install, configure, and extend. In addition, many of these simulators do not provide country-specific behaviors (e.g., Indian driving styles with freer lateral movement, two-wheelers navigating queues side-by-side, etc.) out of the box.
|
46
|
+
|
47
|
+
TraffiSim was created to address these needs:
|
48
|
+
|
49
|
+
### India-Specific Queueing & Lateral Movement
|
50
|
+
- Incorporates concepts like India Mode for simulating two-wheelers and small vehicles weaving side-by-side in queues.
|
51
|
+
|
52
|
+
### Lightweight & Extensible
|
53
|
+
- Focuses on intersection-level simulation, making it easy to add new driving rules or tweak existing ones.
|
54
|
+
|
55
|
+
### Educational & Rapid Prototyping
|
56
|
+
- A simpler codebase suitable for teaching traffic engineering or quickly prototyping new signal control strategies.
|
57
|
+
|
58
|
+
## Features
|
59
|
+
- **Multiple Vehicle Types:** Cars, scooters, motorcycles, trucks, buses (with configurable parameters).
|
60
|
+
- **IDM & MOBIL:** Intelligent Driver Model for speed control, and MOBIL for lane-change decisions.
|
61
|
+
- **Adaptive or Fixed Signals:** Choose between a simple queue-based adaptive or a time-based fixed cycle strategy.
|
62
|
+
- **Multi-Lane Support:** Allows 1 to N lanes in each direction.
|
63
|
+
- **“India Mode”:** Enables side-by-side queueing for two-wheelers and small vehicles.
|
64
|
+
- **Optionally Simulate Full Routes:** Vehicles can vanish at the intersection center or continue to an exit point.
|
65
|
+
- **Pygame Visualization:** Observe your simulation in real-time or disable it for headless runs.
|
66
|
+
- **Data Collection:** Logs queue length, arrival rates, wait times, and more in CSV format for analysis.
|
67
|
+
## Technical Overview
|
68
|
+
TraffiSim’s code is organized into several Python modules:
|
69
|
+
|
70
|
+
**intersection.py**:
|
71
|
+
- Core logic for arrivals, queues, traffic lights, adaptive/fixed signal control, and data recording.
|
72
|
+
- Main class: `IntersectionSim`.
|
73
|
+
|
74
|
+
**models.py**:
|
75
|
+
- Vehicle-level logic, including IDM for longitudinal control, MOBIL for lane changing.
|
76
|
+
- Holds default parameters in `DEFAULT_VEHICLE_TYPES`.
|
77
|
+
|
78
|
+
**rendering.py**:
|
79
|
+
- Uses Pygame for drawing roads, vehicles, signals, and queue lines if `show_visuals=True`.
|
80
|
+
- Entirely optional (the simulator can run without visualization).
|
81
|
+
|
82
|
+
**run.py**:
|
83
|
+
- High-level function `run_multiple_simulations` that can be called multiple times with varying parameters.
|
84
|
+
- A minimal `main_cli()` function for a command-line interface.
|
85
|
+
|
86
|
+
**utils.py**:
|
87
|
+
- Simple helper functions for geometry (e.g., distance calculations) and exit point definitions.
|
88
|
+
|
89
|
+
The Intelligent Driver Model (IDM) controls acceleration based on the gap to the lead vehicle, desired speeds, and comfortable deceleration. MOBIL checks whether lane changes are beneficial and safe based on accelerations for the subject vehicle and adjacent vehicles.
|
90
|
+
|
91
|
+
## Installation
|
92
|
+
### A) From Source (Local Development)
|
93
|
+
|
94
|
+
Clone the repository:
|
95
|
+
```bash
|
96
|
+
git clone https://github.com/AHSharan/TraffiSim.git
|
97
|
+
cd TraffiSim
|
98
|
+
```
|
99
|
+
Install with pip:
|
100
|
+
```bash
|
101
|
+
pip install .
|
102
|
+
```
|
103
|
+
To include Pygame automatically, install the optional `[rendering]` extras:
|
104
|
+
```bash
|
105
|
+
pip install .[rendering]
|
106
|
+
```
|
107
|
+
|
108
|
+
### B) Installing from PyPI
|
109
|
+
You can install TraffiSim directly from the Python Package Index (PyPI):
|
110
|
+
```bash
|
111
|
+
pip install TraffiSim
|
112
|
+
```
|
113
|
+
If you want to include Pygame (used for visualization) right away, install the `[rendering]` extra:
|
114
|
+
```bash
|
115
|
+
pip install TraffiSim[rendering]
|
116
|
+
```
|
117
|
+
Note: If you only need to run headless simulations (no graphics), you don’t need the extra.
|
118
|
+
|
119
|
+
Once installed, verify by running:
|
120
|
+
```bash
|
121
|
+
traffisim-run
|
122
|
+
```
|
123
|
+
This will execute a default simulation with minimal parameters.
|
124
|
+
|
125
|
+
You can then use TraffiSim in your own Python scripts:
|
126
|
+
```python
|
127
|
+
from traffisim.run import run_multiple_simulations
|
128
|
+
|
129
|
+
run_multiple_simulations(
|
130
|
+
N_runs=1,
|
131
|
+
total_time=300,
|
132
|
+
multiple_lanes=True,
|
133
|
+
lane_count=3,
|
134
|
+
show_visuals=True, # True requires pygame
|
135
|
+
adaptive_signals=True,
|
136
|
+
)
|
137
|
+
```
|
138
|
+
|
139
|
+
## Usage
|
140
|
+
### Using in Python Scripts
|
141
|
+
You can run simulations programmatically:
|
142
|
+
```python
|
143
|
+
from traffisim.run import run_multiple_simulations
|
144
|
+
|
145
|
+
run_multiple_simulations(
|
146
|
+
N_runs=1,
|
147
|
+
junction_type="4way",
|
148
|
+
total_time=600,
|
149
|
+
show_visuals=True,
|
150
|
+
multiple_lanes=True,
|
151
|
+
lane_count=3,
|
152
|
+
adaptive_signals=True,
|
153
|
+
india_mode=True,
|
154
|
+
save_to_files=False
|
155
|
+
)
|
156
|
+
```
|
157
|
+
Or instantiate `IntersectionSim` directly:
|
158
|
+
```python
|
159
|
+
from traffisim.intersection import IntersectionSim
|
160
|
+
from traffisim.rendering import TrafficRenderer
|
161
|
+
|
162
|
+
sim = IntersectionSim(
|
163
|
+
junction_type="4way",
|
164
|
+
multiple_lanes=True,
|
165
|
+
lane_count=2,
|
166
|
+
total_time=300,
|
167
|
+
show_visuals=True,
|
168
|
+
renderer_class=TrafficRenderer,
|
169
|
+
india_mode=False,
|
170
|
+
adaptive_signals=True
|
171
|
+
)
|
172
|
+
sim.run()
|
173
|
+
```
|
174
|
+
|
175
|
+
## Simulation Parameters
|
176
|
+
Commonly adjusted parameters:
|
177
|
+
|
178
|
+
| Parameter | Default | Description |
|
179
|
+
|-----------------------|------------|-----------------------------------------------------------------------------|
|
180
|
+
| `junction_type` | "4way" | Intersection type: "4way" or "3way". |
|
181
|
+
| `multiple_lights` | False | Use a single traffic light vs. per-approach lights. |
|
182
|
+
| `total_time` | 300 | Number of simulation steps. |
|
183
|
+
| `sim_steps_per_sec` | 10 | Internal sub-step resolution (10 or 1). |
|
184
|
+
| `simulation_speed` | 30 | Frame rate in Pygame visualization. |
|
185
|
+
| `multiple_lanes` | False | Whether each approach has multiple lanes. |
|
186
|
+
| `lane_count` | 2 | Number of lanes per approach if multiple lanes are enabled. |
|
187
|
+
| `india_mode` | False | Allow side-by-side queue for two-wheelers or small vehicles. |
|
188
|
+
| `adaptive_signals` | True | Use a simple adaptive signal logic vs. fixed-cycle approach. |
|
189
|
+
| `simulate_full_route` | True | Vehicles continue from entry to exit points; if False, they vanish center. |
|
190
|
+
| `vehicle_distribution`| dict | Probability distribution for vehicle types (car, scooter, etc.). |
|
191
|
+
| `save_to_files` | True | Save simulation data to CSV. |
|
192
|
+
| `output_folder` | "simulation_outputs" | Directory for saving CSV outputs. |
|
193
|
+
|
194
|
+
## Customization
|
195
|
+
**New Vehicle Types**
|
196
|
+
Add entries in `DEFAULT_VEHICLE_TYPES` in `models.py` with parameters like `desired_speed`, `max_acceleration`, etc.
|
197
|
+
|
198
|
+
**Signal Logic**
|
199
|
+
Default adaptive logic chooses phases based on queue length. Edit `choose_new_green()` in `intersection.py`.
|
200
|
+
|
201
|
+
**Queue Behaviors (India Mode)**
|
202
|
+
For complex lateral movement, modify `reposition_queue()` in `intersection.py`.
|
203
|
+
|
204
|
+
**Saving & Analyzing Data**
|
205
|
+
Per-step data in `sim.per_timestep_data`; summary in `sim.get_results_dict()`. Customize columns or CSV writing in `run.py`.
|
206
|
+
|
207
|
+
## Comparison to Other Tools (SUMO, etc.)
|
208
|
+
**SUMO:**
|
209
|
+
- Large-scale, open-source traffic simulator.
|
210
|
+
- TraffiSim focuses on intersection-level details like 2D positioning for Indian driving patterns.
|
211
|
+
|
212
|
+
**MATSim / Aimsun:**
|
213
|
+
- Large or commercial simulators for multi-agent, city-scale traffic.
|
214
|
+
- TraffiSim is simpler and specialized for intersection-based experiments.
|
215
|
+
|
216
|
+
## Limitations & Future Work
|
217
|
+
- **Geometry:** Physical turn radii or collisions not deeply simulated.
|
218
|
+
- **No Traffic Signal Optimization:** Basic queue-based adaptive approach.
|
219
|
+
- **Single Intersection Focus:** Multi-intersection networks need extensions.
|
220
|
+
- **Performance:** High vehicle counts may impact performance.
|
221
|
+
|
222
|
+
## Contributing
|
223
|
+
Ideas for contribution include:
|
224
|
+
- Machine learning or optimization for signals
|
225
|
+
- More realistic India Mode dynamics
|
226
|
+
- Network-level expansions
|
227
|
+
- Additional vehicle classes (auto-rickshaws, e-bikes)
|
228
|
+
|
229
|
+
Submit pull requests or open issues on GitHub.
|
230
|
+
|
231
|
+
## License
|
232
|
+
TraffiSim is under the GNU License.
|
233
|
+
Feel free to use, modify, and distribute with attribution.
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
|
traffisim-0.1.1/setup.py
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
from setuptools import setup, find_packages
|
2
|
+
import pathlib
|
3
|
+
|
4
|
+
# Path to the current directory
|
5
|
+
HERE = pathlib.Path(__file__).parent.resolve()
|
6
|
+
|
7
|
+
# Read the contents of README.md
|
8
|
+
long_description = (HERE / "README.md").read_text(encoding="utf-8")
|
9
|
+
|
10
|
+
setup(
|
11
|
+
name='TraffiSim',
|
12
|
+
version='0.1.1',
|
13
|
+
author='A. Sharan',
|
14
|
+
description='A modular intersection traffic simulator with IDM, MOBIL, and adaptive signals',
|
15
|
+
long_description=long_description,
|
16
|
+
long_description_content_type='text/markdown',
|
17
|
+
packages=find_packages(),
|
18
|
+
install_requires=[
|
19
|
+
'pygame>=2.0.0'
|
20
|
+
],
|
21
|
+
extras_require={
|
22
|
+
'rendering': ['pygame>=2.0.0'],
|
23
|
+
'analysis': [
|
24
|
+
'streamlit',
|
25
|
+
'pandas',
|
26
|
+
'plotly',
|
27
|
+
'seaborn',
|
28
|
+
'matplotlib'
|
29
|
+
],
|
30
|
+
},
|
31
|
+
python_requires='>=3.7',
|
32
|
+
entry_points={
|
33
|
+
'console_scripts': [
|
34
|
+
'traffisim-run = traffisim.run:main_cli',
|
35
|
+
]
|
36
|
+
}
|
37
|
+
)
|
traffisim-0.1.0/PKG-INFO
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
Metadata-Version: 2.2
|
2
|
-
Name: TraffiSim
|
3
|
-
Version: 0.1.0
|
4
|
-
Summary: A modular intersection traffic simulator with IDM, MOBIL, and adaptive signals
|
5
|
-
Author: A. Sharan
|
6
|
-
Requires-Python: >=3.7
|
7
|
-
License-File: LICENSE
|
8
|
-
Requires-Dist: pygame>=2.0.0
|
9
|
-
Provides-Extra: rendering
|
10
|
-
Requires-Dist: pygame>=2.0.0; extra == "rendering"
|
11
|
-
Provides-Extra: analysis
|
12
|
-
Requires-Dist: streamlit; extra == "analysis"
|
13
|
-
Requires-Dist: pandas; extra == "analysis"
|
14
|
-
Requires-Dist: plotly; extra == "analysis"
|
15
|
-
Requires-Dist: seaborn; extra == "analysis"
|
16
|
-
Requires-Dist: matplotlib; extra == "analysis"
|
17
|
-
Dynamic: author
|
18
|
-
Dynamic: provides-extra
|
19
|
-
Dynamic: requires-dist
|
20
|
-
Dynamic: requires-python
|
21
|
-
Dynamic: summary
|
@@ -1,21 +0,0 @@
|
|
1
|
-
Metadata-Version: 2.2
|
2
|
-
Name: TraffiSim
|
3
|
-
Version: 0.1.0
|
4
|
-
Summary: A modular intersection traffic simulator with IDM, MOBIL, and adaptive signals
|
5
|
-
Author: A. Sharan
|
6
|
-
Requires-Python: >=3.7
|
7
|
-
License-File: LICENSE
|
8
|
-
Requires-Dist: pygame>=2.0.0
|
9
|
-
Provides-Extra: rendering
|
10
|
-
Requires-Dist: pygame>=2.0.0; extra == "rendering"
|
11
|
-
Provides-Extra: analysis
|
12
|
-
Requires-Dist: streamlit; extra == "analysis"
|
13
|
-
Requires-Dist: pandas; extra == "analysis"
|
14
|
-
Requires-Dist: plotly; extra == "analysis"
|
15
|
-
Requires-Dist: seaborn; extra == "analysis"
|
16
|
-
Requires-Dist: matplotlib; extra == "analysis"
|
17
|
-
Dynamic: author
|
18
|
-
Dynamic: provides-extra
|
19
|
-
Dynamic: requires-dist
|
20
|
-
Dynamic: requires-python
|
21
|
-
Dynamic: summary
|
traffisim-0.1.0/setup.py
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
from setuptools import setup, find_packages
|
2
|
-
|
3
|
-
setup(
|
4
|
-
name='TraffiSim',
|
5
|
-
version='0.1.0',
|
6
|
-
author='A. Sharan',
|
7
|
-
description='A modular intersection traffic simulator with IDM, MOBIL, and adaptive signals',
|
8
|
-
packages=find_packages(),
|
9
|
-
install_requires=[
|
10
|
-
'pygame>=2.0.0'
|
11
|
-
],
|
12
|
-
extras_require={
|
13
|
-
'rendering': ['pygame>=2.0.0'],
|
14
|
-
'analysis': [
|
15
|
-
'streamlit',
|
16
|
-
'pandas',
|
17
|
-
'plotly',
|
18
|
-
'seaborn',
|
19
|
-
'matplotlib'
|
20
|
-
|
21
|
-
],
|
22
|
-
},
|
23
|
-
python_requires='>=3.7',
|
24
|
-
entry_points={
|
25
|
-
'console_scripts': [
|
26
|
-
'traffisim-run = traffisim.run:main_cli',
|
27
|
-
|
28
|
-
]
|
29
|
-
}
|
30
|
-
)
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|