Skip to content

Commit

Permalink
docs: added documentation for stress detection module, bugfix: depend…
Browse files Browse the repository at this point in the history
…ency issue
  • Loading branch information
vijay-jaisankar committed May 7, 2022
1 parent 4193754 commit 18a6827
Show file tree
Hide file tree
Showing 10 changed files with 84 additions and 21 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,21 @@ sc = trafficinterventions.SpeedCamera.SpeedCamera(

# Run the simulation and get outputs
sc.runSimulation()
```
---

### Sample Usage: Stressed Junctions Detection
```py
sj = trafficinterventions.StressJunction.StressJunction(
maxTimeSteps=1000,
weightsArray=[1,1,1,1,1],
pathCFG="map.sumocfg",
outPath="Outputs/",
pathNET="osm.net.xml",
pathSummaryFile="stressed_junctions.txt",
numLocs = 5
)

# Run the simulation and get outputs
sj.runSimulation()
```
Binary file added dist/trafficinterventions-1.0.3-py3-none-any.whl
Binary file not shown.
Binary file added dist/trafficinterventions-1.0.3.tar.gz
Binary file not shown.
15 changes: 15 additions & 0 deletions docs/stress_junction.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import trafficinterventions

# Initialiasing the object
sj = trafficinterventions.StressJunction.StressJunction(
maxTimeSteps=1000, # Number of time steps, could be overridden by the system
weightsArray=[1,1,1,1,1], # Weights for the parameters - in the order of [haltingNumber, CO2Emissions, StepOccupancy, vehicleLength, waitingTime]
pathCFG="map.sumocfg", # .sumocfg file path
outPath="Outputs/", # Output path for screenshots
pathNET="osm.net.xml", # .net.xml file path
pathSummaryFile="stressed_junctions.txt", # File path for summary of the simulation
numLocs = 5 # Number of stressed junctions to be printed
)

# Run the simulation and get outputs
sj.runSimulation()
6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
[build-system]
requires = [
"setuptools>=42",
"wheel"
"wheel",
"numpy",
"traci",
"sumolib",
"pandas"
]
build-backend = "setuptools.build_meta"
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[metadata]
name = trafficinterventions
version = 1.0.1
version = 1.0.3
author = WSL, IIITB
author_email = [email protected]
description = Python Package to perform simple Traffic Interventions.
description = Python Package to perform simple Traffic Interventions and run traffic simulations.
long_description = file: README.md
long_description_content_type = text/markdown
url = https://github.com/WSL-IIITB/Traffic-Interventions
Expand Down
44 changes: 41 additions & 3 deletions src/trafficinterventions.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Metadata-Version: 2.1
Name: trafficinterventions
Version: 1.0.1
Summary: Python Package to perform simple Traffic Interventions.
Version: 1.0.3
Summary: Python Package to perform simple Traffic Interventions and run traffic simulations.
Home-page: https://github.com/WSL-IIITB/Traffic-Interventions
Author: WSL, IIITB
Author-email: [email protected]
Expand All @@ -19,14 +19,16 @@ License-File: LICENSE

## Installation
- `python -m pip install --upgrade pip`
- `pip install trafficinterventions xml`
- `pip install --upgrade trafficinterventions`

---
## Documentation
All relevant files can be found [here](https://github.com/WSL-IIITB/Traffic-Interventions/tree/main/docs)

---

## Interventions

### Sample Usage : Edge Manipulation
```py
import trafficinterventions
Expand All @@ -49,5 +51,41 @@ cl = trafficinterventions.ChangeLanes.ChangeLanes(fileName="sample.xml")
ce.changePriorityLanes(["highway.cycleway"], 100, "new_file.xml")

```
## Simulations

### Sample Usage: Speed Camera Placement
```py
import trafficinterventions


sc = trafficinterventions.SpeedCamera.SpeedCamera(
maxTimeSteps= 1000,
nearestNeighbourDisallow= 250.0,
gridArray=[-10000,10000,10000,-10000],
pathCFG="map.sumocfg",
outPath="Outputs/",
summaryFilePath="summary.txt",
numLocs=5
)

# Run the simulation and get outputs
sc.runSimulation()
```
---

### Sample Usage: Stressed Junctions Detection
```py
sj = trafficinterventions.StressJunction.StressJunction(
maxTimeSteps=1000,
weightsArray=[1,1,1,1,1],
pathCFG="map.sumocfg",
outPath="Outputs/",
pathNET="osm.net.xml",
pathSummaryFile="stressed_junctions.txt",
numLocs = 5
)

# Run the simulation and get outputs
sj.runSimulation()
```

1 change: 1 addition & 0 deletions src/trafficinterventions.egg-info/SOURCES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ setup.cfg
src/trafficinterventions/ChangeEdges.py
src/trafficinterventions/ChangeLanes.py
src/trafficinterventions/SpeedCamera.py
src/trafficinterventions/StressJunction.py
src/trafficinterventions/__init__.py
src/trafficinterventions.egg-info/PKG-INFO
src/trafficinterventions.egg-info/SOURCES.txt
Expand Down
15 changes: 1 addition & 14 deletions src/trafficinterventions/StressJunction.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,17 +259,4 @@ def runSimulation(self):
# Running the loop
traci.start([sumoBinary, "-c", self.pathCFG, "--tripinfo-output", self.outPath + "tripinfo.xml", "--time-to-teleport", "-1"])
self.loop()


if __name__ == "__main__":
sj = StressJunction(
maxTimeSteps=1000,
weightsArray=[1,1,1,1,1],
pathCFG="/home/vijay/Desktop/labs/atl/main-repo/ATL/jan2022-pe-code/interventions/Scenarios/High_Traffic/map.sumocfg",
outPath="/home/vijay/Desktop/labs/atl/main-repo/ATL/jan2022-pe-code/interventions/Scenarios/High_Traffic/Outputs/",
pathNET="/home/vijay/Desktop/labs/atl/main-repo/ATL/jan2022-pe-code/interventions/Scenarios/High_Traffic/osm.net.xml",
pathSummaryFile="here.txt",
numLocs = 5
)

sj.runSimulation()

3 changes: 2 additions & 1 deletion src/trafficinterventions/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from . import ChangeEdges
from . import ChangeLanes
from . import SpeedCamera
from . import SpeedCamera
from . import StressJunction

0 comments on commit 18a6827

Please sign in to comment.