Skip to content

Add traffic light model#465

Closed
catherinedevlin wants to merge 24 commits into
mesa:mainfrom
catherinedevlin:add-traffic-light-model-2
Closed

Add traffic light model#465
catherinedevlin wants to merge 24 commits into
mesa:mainfrom
catherinedevlin:add-traffic-light-model-2

Conversation

@catherinedevlin
Copy link
Copy Markdown
Contributor

This is modified from @FedericoCelauro's PR at #369, with minor stylistic changes and one installation bugfix.

Original PR:

Summary

This PR adds a new example model. It's a very simple modellization of traffic flow at an intersection that can show how smart traffic light control can reduce the wait time of the cars.

Motive

This is a very easy traffic model that can be made using meta agents.

Implementation

In the model, both cars and traffic lights are agents that interact with each others. On top of them, I implemented a meta-agent called IntersectionController, that can change the status of the traffic lights based on the number of cars waiting in line.

Usage Examples

To run the example usage do

$ cd examples/smart_traffic_lights
$ python run_example.py

To run the interactive Solara simulation please do

$ cd examples/smart_traffic_lights
$ solara run app.py

Additional Notes

Being a simple model, this can be made much more complex implementing, for example, smarter traffic lights controls, larger road systems, non periodic boundary conditions and many more. It can be easily implemented using experimental meta agent class

FedericoCelauro and others added 24 commits March 9, 2026 17:37
enum has been in the standard library since Python 3.4
Slight changes for more Pythonic style, especially in adding DRY to run_example.py
@catherinedevlin
Copy link
Copy Markdown
Contributor Author

Closing in favor of #467

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants