Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [sumo-user] Prevent loaded vehicles from being inserted into the simulation

The easiest solution is to load all vehicles at once by loading the route file with option --additional-files (see https://sumo.dlr.de/docs/SUMO.html#loading_order_of_input_files). This way, the simulation will keep running until all defined vehicles are arrived or removed.
Alternatively, you could read the maximum departure time from your input file and rewrite the condition as
 
    while traci.simulation.getTime() < maxDeparTime or getMinExpectedNumber() > 0:

I cannot replicate the issue with getDepartedIDList though. Feel free to open up an issue on github and attach a minimum failing example.

regards,
Jakob

Am Di., 26. Mai 2020 um 13:22 Uhr schrieb marcelreppi <marcelreppi@xxxxxxxxx>:
Hello,

I am using TraCI with the following while loop condition to run the
simulation until all vehicles have arrived:

while traci.simulation.getMinExpectedNumber() > 0

In my code I want to randomly prevent some vehicles from being inserted into
the simulation.
I realized that the following code causes the simulation to end early due to
the while condition:

loaded_vehicles = simulation_sub[tc.VAR_LOADED_VEHICLES_IDS]
for vid in loaded_vehicles:
   if not should_vehicle_depart():
      traci.vehicle.remove(vid)

Therefore, I am currently using:

departed_vehicles = simulation_sub[tc.VAR_DEPARTED_VEHICLES_IDS]
for vid in departed_vehicles:
   if not should_vehicle_depart():
      traci.vehicle.remove(vid)

My problem with the current implementation is that the vehicles still show
up for one timestep in the output files (vehroute-output, fcd-output,
tripinfo-output, etc.).

Is there another way of doing this to achieve the desired output?
Maybe a different while condition?

I think I have also found a small bug:
When a vehicle has departure time 00:00:00 it shows up twice in the
tc.VAR_DEPARTED_VEHICLES_IDS list.
Once after timestep 0 and then also after timestep 1.
This even happens when removing the vehicle after timestep 0!
Here an example of my logs:

After step 0
Departed list = ('10292601_3',)
Remove vehicle 10292601_3
After step 1
Departed list = ('10292601_3',)
After step 2
Departed list = ()

Thanks for the help!

Best regards
Marcel



--
Sent from: http://sumo-user-mailing-list.90755.n8.nabble.com/
_______________________________________________
sumo-user mailing list
sumo-user@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/sumo-user

Back to the top