|
|
python3 -m venv envsource env/bin/activatepip install -r requirements.txtpython3 train.py --save_model="data/<trained_model>" --simulation="cross/cross" --num_timesteps=100000python3 test.py --load_model="data/<trained_model>" --simulation="cross/cross" --traffic_scale=1python3 train.py --save_model="data/trained_model_ppo_aveiro_traffic" --simulation="aveiro_traffic/osm" --timesteps=200000python3 test.py --load_model="data/trained_model_ppo_aveiro_traffic" --simulation="aveiro_traffic/osm" --traffic_scale=1python3 -m tensorboard.main --logdir="./data/logs/"python3 $SUMO_HOME/tools/visualization/plotXMLAttributes.py teste.xml teste2.xml -x maxJamLengthInMeters -y @COUNT -i @NONE --legend --barplot --xbin 1 --xclamp :3000Select the area in the opened website page and download the files:
python3 $SUMO_HOME/tools/osmWebWizard.py- Copy files to
sumo_config/<simulation_name>. - Add
osm.det.xmlin the created folder:- In this file, you can add the detectors with the corresponding lanes (see in
netedit).
- In this file, you can add the detectors with the corresponding lanes (see in
- Change the traffic light id in
neteditin the fileosm.net.xml.gzto TLS. - Start a test with the corresponding simulation parameters.
Arguments:
data/trained_model_ppo_aveiro_traffic_1M_new- The trained model.2.75- The traffic scale.
./stats.sh data/trained_model_ppo_aveiro_traffic_1M_new 2.75 Change data/emissions.xml to data/emissions-smart.xml and data/waitingTime.xml to data/waitingTime-smart.xml.
python3 test.py --load_model="data/trained_model_ppo_aveiro_traffic_1M_new" --simulation="aveiro_traffic/osm" --traffic_scale=2.75Change data/emissions.xml to data/emissions-normal.xml and data/waitingTime.xml to data/waitingTime-normal.xml.
sumo -c sumo_config/aveiro_traffic/osm.sumocfg --tripinfo-output.write-unfinished="true" --duration-log.statistics="true" --device.emissions.probability="0.10" --no-step-log="true" --no-warnings="true" --end="2250" --scale="2.75" --start="true"Change data/emissions.xml to data/emissions-actuated.xml and data/waitingTime.xml to data/waitingTime-actuated.xml.
sumo -c sumo_config/aveiro_traffic/osm.actuated.sumocfg --tripinfo-output.write-unfinished="true" --duration-log.statistics="true" --device.emissions.probability="0.10" --no-step-log="true" --no-warnings="true" --end="2250" --scale="2.75" --start="true"python3 $SUMO_HOME/tools/visualization/plotXMLAttributes.py -x begin -y CO2_abs -i @NONE data/emissions-smart.xml data/emissions-normal.xml data/emissions-actuated.xml --ylabel="CO2 mg/m" --title="CO2 Emission in Traffic Lights" --legend --barplot --xbin=60python3 $SUMO_HOME/tools/visualization/plotXMLAttributes.py -x begin -y waitingTime -i @NONE data/waitingTime-smart.xml data/waitingTime-normal.xml data/waitingTime-actuated.xml --ylabel="Time s/m" --title="Waiting Time in Traffic Lights" --legend --barplot --xbin=60Use the following command to create a simulation using the osmWebWizard:
python3 $SUMO_HOME/tools/osmWebWizard.py- In the web interface, choose the region of interest by selecting the desired city or area for the simulation.
- Open the file
osm.net.xml.gzin NetEdit. - Change the traffic light ID for each intersection to a sequential naming format:
- TLS1, TLS2, ..., TLSn.
-
Add detectors to the simulation by creating an
osm.det.xmlfile in the same folder where the simulation files are located.- This file should define detectors and associate them with the corresponding lanes. You can look on
/sumo_config/aveiro_traffic/osm.det.xml
- This file should define detectors and associate them with the corresponding lanes. You can look on
-
Connect the detectors to the simulation configuration file
osm.sumocfg.- This ensures the detectors are recognized and functional within the simulation.
Once the setup is complete, run the simulation using sumo-gui to visually verify the traffic flow and detector operations:
sumo-gui -c sumo_config/<simulation_name>/osm.sumocfg 

