eclipse-sumo / sumo

Eclipse SUMO is an open source, highly portable, microscopic and continuous traffic simulation package designed to handle large networks. It allows for intermodal simulation including pedestrians and comes with a large set of tools for scenario creation.
https://eclipse.dev/sumo
Eclipse Public License 2.0
2.49k stars 1.41k forks source link

Particular Vehicle Number in Simulation #11312

Closed erev-84 closed 2 years ago

erev-84 commented 2 years ago

Hello,

I created ambulance and fire truck using netedit and added these vehicles to the simulation, but I want only one ambulance and fire truck in the simulation but I faced with few problems, first of all, I couldn't find a way to set the total number of ambulances and firetrucks that will be in the simulation and the other problem is I want the trip of these vehicles to be random in the simulation but I could not generate random trips for these vehicles. What type command should i use to create random trips for particular vehicle types?

In which file and what kind of changes do I need to make in order to solve the above-mentioned problems?

Thanks in advance

namdre commented 2 years ago

One solution to create a single random firebrigade would be:

python randomTrips.py -n net.net.xml --vehicle-class emergency --prefix firebrigade --trip-attributes="guiShape=\"firebrigade\"" -e 1

see https://sumo.dlr.de/docs/Tools/Trip.html#generating_vehicles_with_additional_parameters

erev-84 commented 2 years ago

Hello,

Can I create a random trip for each emergency vehicle seperately? Also, will the random trips I create for emergency vehicles affect the trip of passenger vehicles?

namdre commented 2 years ago

Just call randomTrips once per emergency vehicle but make sure to vary the --prefix argument to obtain distinct ids. I also recommend setting randomTrips option --seed to ensure variety among the random trips. The emergency vehicles will interact with the passenger trips and might cause them to be delayed in the simulation. However, their origins and destinations will not be affected (since they would be generated by independent calls to randomTrips.py).

erev-84 commented 2 years ago

Hello,

I have few more questions;

First of all, I want the emergency vehicle to start randomly from anywhere in the simulation and always go through the traffic lights. Is there any way to do that?

Secondly, how can I determine the number of emergency vehicle I created with Netedit without using the "randomTrips.py" script. In your first message, you told me that I can generate 1 emergency vehicle with "-e 1", but how can I do this without using the randomTrips.py script?

Also, can I determine in what second the emergency vehicle will enter the simulation in the random trips I have created? For example, is it possible for an emergency vehicle to enter to the simulation at 700th second of a simulation of 3600 seconds? is there a way to do this?

Thirdly, can I make the emergency vehicle always use different paths/roads without using the build.bat and "randomTrips.py" script each time? In other words, I can create a random trip with "randomTrips.py", but every time I start the simulation, the trip of the car is always the same until I use the "randomTrips.py" script or build.bat and create a new trip.

Finally, Reading this link (https://sumo.dlr.de/docs/Simulation/Randomness.html#random_number_generation_rng), it seems like I can assign my own random seed using --random but I'm still not sure where (in which file) I would specify this.

namdre commented 2 years ago
  1. You could use routeSampler with counting data that forces a vehicle to move over a given list of traffic light edges. You would need to set option --min-count X where X is the number of traffic lights that the vehicle must pass. As an input you could use a large set of random routes (large enough so that there are different candidates to pick from). See https://sumo.dlr.de/docs/Tools/Turns.html#routesamplerpy

  2. netedit is for manual creation. You can not define random routes with netedit. 2b. use randomTrips -b 700 -e 701 to define a random trip starting at time 700

  3. take a look at https://sumo.dlr.de/docs/Definition_of_Vehicles%2C_Vehicle_Types%2C_and_Routes.html#route_and_vehicle_type_distributions

  4. you can put <random value="true"> into your sumocfg. Note, that this prevents replication because the random seed is not retrievable at the moment. Consider using runSeeds.py instead: https://sumo.dlr.de/docs/Tools/Misc.html#runseedspy

erev-84 commented 2 years ago

Hello,

1-)

I tried using routeSampler.py but got the following error

image

How can I generate input route file with the intervals? I tried randomTrips.py but it is not generate route file with the intervals

2-)

Can I set different begin and end values for each emergency vehicle?

To do this, I tried to create 10 different trip file with different begin values for each emergency vehicle by using "randomTrips.py" script, but sumo gave the warning shown in the screenshot below.

python randomTrips.py -n osm.net.xml --vehicle-class emergency --prefix emergency --trip-attributes="guiShape=\"emergency\"" -e 1 -b 700 -e701

python randomTrips.py -n osm.net.xml --vehicle-class emergency --prefix emergency --trip-attributes="guiShape=\"emergency\"" -e 1 -b 800 -e801

python randomTrips.py -n osm.net.xml --vehicle-class emergency --prefix emergency --trip-attributes="guiShape=\"emergency\"" -e 1 -b 900 -e901 . . . .

image

image

I would appreciate it if you could explain to me how I can specify different begin and end values for the trips shown in the screenshot below?

image

namdre commented 2 years ago
  1. Using routeSampler is explained in the tutorials: https://sumo.dlr.de/docs/Tutorials/index.html#sumo_user_conference_tutorials
  2. As already written before: "make sure to vary the --prefix argument to obtain distinct ids."