It may be more appropriate to query the Flow devs on this. However, if you are missing vehicles in the simulation, you could check for https://sumo.dlr.de/docs/Simulation/VehicleInsertion.html#delayed_departure
Am Di., 6. Juni 2023 um 20:49 Uhr schrieb Stefano Bonasera < [email protected]>: > Hi there, > > I am trying to randomly place a finite (and specific) set of vehicles in > certain parts of a map network in SUMO using Flow along with the Traci > simulator but... without using Flow's inflows() objects. > When running the flow.envs.base.reset() to reset the sim with a new > randomized configuration, one of the vehicles added is missing. > > Let network_object = flow.networks.Network(....) derived from Flow. I can > confirm it has the correct ID list and initial state configuration (ID, > lane_ID, position, velocity) in its fields. When calling Flow reset(), > running self.k.kernel_api.vehicle.getIDList() confirms there are missing > vehicles relative to network_object.vehicles.ids. After detecting this > discrepancy, Flow errors out. > > The error message form is: > > File "~/flow_env_with_status.py", line N, in reset > return super().reset() > File "/tmp/ucrl/flow/envs/base.py", line M, in reset > raise FatalFlowError(msg=msg) > flow.utils.exceptions.FatalFlowError: > Not enough vehicles have spawned! Bad start? > Missing vehicles / initial state: > - vehicle_X : ('vehicle_type_X', 'custom_road_name', lane_id, position, > velocity) > A hack that seems to help is adding the following code inside of the > missing vehicles check before returning the observation vector to the > simulation environment: > > # check to make sure all vehicles have been spawned > if len(network_object.initial_ids) > > len(self.k.kernel_api.vehicle.getIDList()): > missing_vehicles = list(set(self.initial_ids) - set(initial_ids)) > for mv in missing_vehicles: > self.k.kernel_api.vehicle.remove(mv) # FIXME: hack > type_id, edge, lane_index, pos, speed = self.initial_state[mv] > self.k.vehicle.add( > veh_id=mv, > type_id=type_id, > edge=edge, > lane=lane_index, > pos=pos, > speed=speed) > self.k.simulation.simulation_step() > # update the information in each kernel to match the current > state > self.k.update(reset=True) > > I am not sure why the missing vehicle was not added before reaching this > part of the code. Is this a problem that others have seen before? Any > suggested fixes if we do not want to use Inflows()? > > Thanks as always for your time and your help! > > Stefano > _______________________________________________ > sumo-user mailing list > [email protected] > To unsubscribe from this list, visit > https://www.eclipse.org/mailman/listinfo/sumo-user >
_______________________________________________ sumo-user mailing list [email protected] To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/sumo-user
