I am currently porting the original C# Code to Node.js 12. I would LOVE to have your contributions and proposed ideas
SmartTrafficIntersection
Another AI toy project; Of a traffic intersection controlled by an AI agent to optimize traffic flow and avoid collission.
I would love to hear your feedback, especially bugs found in the code and suggested features.
Alpha release is scheduled at the end of September 2017, while the Beta is scheduled at End of October. I would love to stuff in as much as possible before moving on to the next project.
Also, if someone can help me out in the visualization part, that would be awsome!
Thanks
How to use it
on Linux
upcoming, I will port this code from mono to .NET Core 2.1
Install .NET Core 2.1 on your machine
Download/Clone the project at your Machine
Create a directory where you want to have your code
mkdir Traffic
go to that location
cd Traffic
Clone repo onyour machine
git clone https://github.com/aawadall/SmartTrafficIntersection.git
Compile and Run
Go to Code Location
cd SmartTrafficIntersection
Restore
dotnet restore
Build
dotnet build
Run
dotnet run
Theoritical Model
Current Model is designed that a single agent controls an Intersection
made of one or more directoins
Lanes
and Traffic Controllers
Directions
The direction is a conceptual entity used to identify where the traffic flows. It can be considered a vector in the traffic space listing all possible traffic flows.
It is used to:
- link lanes to traffic controllers
- detect potential collision
Lanes
A lane is the physical lane, where traffic lines up. It contains a queue simulator with two parameters
In addition, each lane has a direction as a property.
When traffic is allowed,
i.e. Traffic Controller associated with this lane allows traffic flowing out, it will dequeue using the rate parameter, and in both cases it will enqueue using the rate parameter.
And in all situations, the lane is capable of measuring total wait time for all clients queued in the lane
where v are all vehicles or a pedistrians, currently linedup in this lane.
Such wait time is used as a cost function used by the agent to minimize.
Traffic Controllers
Traffic Controllers are general case of a traffic light in an intersection. A traffic controller can be thought of as a pair boolean vectors; each vector has an element for direction, such that
First vector , is the set of directions allowed to have non risky traffic flowwing, e.g. northbound and southbound traffic are allowed to flow freely. While the second vector is the secondary traffic allowed as per this controller. It means that the traffic of this direction can flow after yielding for incoming traffic from other primary directions, if collision is detected. e.g. left turn wen no dedicated controller for left is green, or right turn, when pedistrians are allowed to cross.
Current model is considering a simple binary traffic light only, with two states; true for green and false for red;
Components
This project is planned to have the following components:
Simulation Component
Lanes, Traffic Controllers, and Intersections, This should simulate traffic in a given intersection configuration, with the optoin to manually control the controller behaviour if dynamic (i.e. not a stop sign or a roundabout)
AI Component
This is a Reinforcement Learning AI agent controlling traffic controller to optimize metrics
Visualiztion Component
Visualize intersection in terms of lanes, controller status and traffic accumilation
Future Work
Collision detection
for a direction to detect if incoming traffic is floowing, and hence detect potential collision and simulate a collision in the future for an unconstrained ystem
Bad driver simulator
Simulate a driver driving slowly, too fast, or running a red light
Include Pedestrians to the simulated model
an extra lane, with a dedicated direction
Unconstrained State/Action Space
Alow the controller to pick wahtever actions, even if the result might end up in a simulated collision. this will allow the system to come up with creative solutions
TD(lambda)
TD(λ) policy
Web Application
port the solution to a web application and allow users to play with it
Message to Students
I appreciate your visit to this repo, and I feel proud that you landed here. I have a request.. PLEASE do NOT copy code from this repo and paste it into your coursework assignment.