[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[sumo-user] Prevent loaded vehicles from being inserted into the simulation
|
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/