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 <marcelre...@gmail.com
>:

> 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@eclipse.org
> To unsubscribe from this list, visit
> https://www.eclipse.org/mailman/listinfo/sumo-user
>
_______________________________________________
sumo-user mailing list
sumo-user@eclipse.org
To unsubscribe from this list, visit 
https://www.eclipse.org/mailman/listinfo/sumo-user

Reply via email to