TraffiSim 0.1.0__py3-none-any.whl → 0.1.1__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
+
@@ -5,9 +5,9 @@ traffisim/models.py,sha256=Ay0xmmussd4ZzW4wVGAaRAC3MnotklRy3eF3Oh67JcA,10566
5
5
  traffisim/rendering.py,sha256=qfhSeLWMqWJMJGdYttOtdg4YcqVL4PIn_CLRaCg_HJ8,8085
6
6
  traffisim/run.py,sha256=SFijx74mIxj2gaUI9-FjdowLFOT3sFjWOu9dTNiYolU,5875
7
7
  traffisim/utils.py,sha256=I3VtZi9Du5q0tSEj8hQNvSXZVFkolA6BBLeru4TyVLE,1417
8
- TraffiSim-0.1.0.dist-info/LICENSE,sha256=KR54sDCiIVQ3mVKXferCYkmiDK7qvMUS0bgWVKzr28Q,32125
9
- TraffiSim-0.1.0.dist-info/METADATA,sha256=n2PzFFi2aOT89YLNn8MLOUijlN3NDZtlVzv01Ls5DX4,684
10
- TraffiSim-0.1.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
11
- TraffiSim-0.1.0.dist-info/entry_points.txt,sha256=kXv192MMR9qwYY0pXTKNYwmhKE6cVsNdoec2ChrNEsQ,57
12
- TraffiSim-0.1.0.dist-info/top_level.txt,sha256=qEfYBcWya_kd7t_eWpvULuKJtNk3dfpbzrq3mQMOy5E,10
13
- TraffiSim-0.1.0.dist-info/RECORD,,
8
+ TraffiSim-0.1.1.dist-info/LICENSE,sha256=KR54sDCiIVQ3mVKXferCYkmiDK7qvMUS0bgWVKzr28Q,32125
9
+ TraffiSim-0.1.1.dist-info/METADATA,sha256=Br_zwwH23w7CEIhHCB4q8S2BjENcsKkPQnQPJn1tRAg,10063
10
+ TraffiSim-0.1.1.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
11
+ TraffiSim-0.1.1.dist-info/entry_points.txt,sha256=kXv192MMR9qwYY0pXTKNYwmhKE6cVsNdoec2ChrNEsQ,57
12
+ TraffiSim-0.1.1.dist-info/top_level.txt,sha256=qEfYBcWya_kd7t_eWpvULuKJtNk3dfpbzrq3mQMOy5E,10
13
+ TraffiSim-0.1.1.dist-info/RECORD,,
@@ -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