This is my take on optimizing traffic light controls as a discrete type problem with genetic algorithms.
-
Building with Docker
This will build the project with Docker. This must be done before running the program.
docker build -t tls_optimization . -
Running with Docker
This will run the project with Docker.
docker run --rm -v $(pwd):/app -w /app tls_optimization -
Run GA with PyGad
This will run the PyGad Implementation of the Genetic Algorithm.
docker run --rm -v $(pwd):/app -w /app tls_optimization python -m src.pygad.pygad_genetic_algorithm -
View map statistics
Will display statistics of the downloaded map and traffic network
docker run --rm -v $(pwd):/app -w /app tls_optimization python -m src.sumo_setup.statistics -
Generate network data
This will generate network data that will have phase durations assigned for individual TLS. This is required step to run the optimization algorithm.
docker run --rm -v $(pwd):/app -w /app tls_optimization python -m src.sumo_setup.generation -
Generate map
This will generate a new map following
osm.netccfgconfigurations.docker run --rm -v $(pwd):/app -w /app/src/sumo_setup tls_optimization netconvert -c osm.netccfg -
Configure Simulator variables
Configure SUMO Simulator variables when running every simulation. We are now using precalculated routes. this step is not necessary.
docker run --rm -v $(pwd):/app -w /app/src/sumo_setup tls_optimization bash -c 'python $SUMO_HOME/tools/randomTrips.py -n osm.net.xml.gz -o [name of your routes file].rou.xml'
You can change from random trips to a specific configuration such as setting the specific number of cars generated per second or setting the total number of cars within every simulation.
-
Discover TLS linkage
This will discover linkage of TLS by Direct Linkage Empirical Discovery.
docker run --rm -v $(pwd):/app -w /app tls_optimization python -m src.pygad.dled_optimizer -
Execute DG2 Grouping
This will execute Differential Grouping method as an alternative to linkage discovery. Theoretically it is faster than Embpirical Linkage Learning.
docker run --rm -v $(pwd):/app -w /app tls_optimization python -m src.pygad.DG2_grouping
Docker has build-in commands that are ment to be used for house keeping tasks:
docker image prune: delete all dangling images (as in without an assigned tag)docker image prune -a: delete all images not used by any containerdocker system prune: delete stopped containers, unused networks and dangling image + dangling build cachedocker system prune -a: delete stopped containers, unused networks, images not used by any container + all build cache