simulationsimulatortraffic-simulationsumo

How to maintain constant number of vehicles through out the simulation in SUMO simulation?


I am a new to SUMO. Can someone help me on how to maintain the constant number of vehicles i.e. constant density, over the complete simulation period like for 1 hr. In this post, they said that using options --begin, --end. I didn't understand how to make use of that option.

Also, It is said that "You can use the option --max-num-vehicles to set the desired number"

Where to execute this option ? Is it with netconvert? Can someone guide me with an example? I mean the full command. Thank you so much.

P.S: I am using SUMO 0.26.0 simulator, windows 10 64bit.

Edit:

after Micheal suggestion I am able to limit the total number of vehicles in the simulation but not able to maintain the same number. Because some of the vehicles are leaving the simulation. Can any one guide me how to maintain the same number of vehicles?

In this post they have mentioned to use Rerouter.But didn't get where should I write retoure attribue.

Should I manually edit my cars.rou.xml file and add some more edges to vechile attribute? someone please guide me. Thank you.


Solution

  • The following route file could be used together with the net from sumo/examples/sumo/simple_nets/cross/cross1l

    <routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/routes_file.xsd">
        <route id="horizontal" edges="2i 1o 1i 2o 2i"/>
        <flow id="horizontal" route="horizontal" begin="0" end="3600" period="3"
              departPos="last" departSpeed="max"/>
    </routes>
    

    It generates a flow of vehicles with maximum departure speed departing every 3 seconds. But if you want to limit the number of vehicles to a constant (let's say 30), you start sumo like this:

    sumo-gui -n net.net.xml -r input_routes.rou.xml --max-num-vehicles 30
    

    This will limit the maximum amount of vehicles to 30. To let it end precisely after one hour use the additional --end 3600 option.