sash-ko / simobility

simobility - light-weight mobility simulation framework. Best for quick prototyping
MIT License
38 stars 9 forks source link

Is there any way to change the position of idle vehicles? #9

Open Xiaobing-Shen opened 3 years ago

Xiaobing-Shen commented 3 years ago

It seems we have to give the information about stations where idle vehicles can stop at. (Fleet.infleet_from_geojson), can I modify this limitation? I mean, I want vechicles stop at the positions when they finish one route and wait for new command.

Actually, I want to rebalance the idle vehicles and want to know how to do this.

Xiaobing-Shen commented 3 years ago

One more question, I just found that vehicle can be in the state "is_moving_to"

image

But I cannot find the definition of such state. It seems self.is_moving_to is always none?????

sash-ko commented 3 years ago

@icyshenfighting Sorry for the delayed response. Regarding vehicle states, there are 3 states "offline", "idling" and "moving_to". You can check if the vehicle is one of those states by calling is_moving_to or is_offline or is_idling. These methods are autogenerated by state machine (one of the features of transition framework)

sash-ko commented 3 years ago

Fleet.infleet_from_geojson is just one of the ways to create a simulation scenario. It just reads a GeoJSON file with points (stations) and randomly selects one of the stations for each new vehicle. But it does not restrict vehicles from moving only between the stations (it can be implemented with routers). In general, you can create new vehicles at any position you need.

sash-ko commented 3 years ago

For rebalancing, you first check if a vehicle in state "idling" (vehicle.is_idling()). If yes, you create a simple itinerary:

if vehicle.is_idling():
    itinerary = Itinerary(clock.now, vehicle)
    itinerary.move_to(some_random_location)
    dispatcher.dispatch(itinerary)