VehicleState

The VehicleState class holds a vehicle’s Stoplist. It exposes two methods:

fast_forward

fast-forwards the state to a new point in time.

handle_transportation_request_single_vehicle

computes the cost for serving a TransportationRequest with this vehicle.

class VehicleState(*, vehicle_id, initial_stoplist, space, dispatcher, seat_capacity)[source]

Single vehicle insertion logic is implemented here. Can optionally be implemented in Cython or another compiled language.

Parameters:
  • vehicle_id – id of the vehicle to be created.

  • initial_stoplist (Stoplist) – stoplist to start out with, MUST contain CPE as first element.

  • space (TransportSpace)

  • dispatcher (Dispatcher) – see the docstring of FleetState.

  • seat_capacity (int) –

    the maximum number of TransportationRequest s

    that can be in a vehicle at the same time.

stoplist: List[Stop]

The list of Stop objects specifying the planned future actions to be undertaken by this vehicle.

fast_forward_time(t)[source]

Update the vehicle_state to the simulator time t.

Parameters:

t (float) – time to be updated to.

Returns:

  • events – List of stop events emitted through servicing stops upto time=t

  • new_stoplist – Stoplist remaining after servicing the stops upto time=t

Return type:

Tuple[List[ridepy.events.StopEvent], List[Stop]]

handle_transportation_request_single_vehicle(request)[source]

The computational bottleneck. An efficient simulator could do the following:

  1. Parallelize this over all vehicles. This function being without any side effects, it should be easy to do.

  2. Implement as a c extension. The args and the return value are all basic c data types, so this should also be easy.

Parameters:

request (TransportationRequest) – Request to be handled.

Returns:

The SingleVehicleSolution for the respective vehicle.

Return type:

ridepy.data_structures.SingleVehicleSolution