nrel.hive.state.vehicle_state.dispatch_ops

Module Contents

Functions

requests_exist_and_match_membership(→ bool)

confirm that all requests currently exist in the system

modify_vehicle_assignment(→ Tuple[Optional[Exception], ...)

assign/un-assign this vehicle to each request. if a request does not exist, it is ignored.

create_routes(...)

creates routes between each phase of a trip plan. requires at least 2

get_position_for_phase(...)

gets the EntityPosition for the request based on the trip phase

begin_or_replan_dispatch_pooling_state(...)

create a DispatchPoolingTrip state. if the vehicle is currently in a ServicingPoolingTrip

nrel.hive.state.vehicle_state.dispatch_ops.requests_exist_and_match_membership(sim: nrel.hive.state.simulation_state.simulation_state.SimulationState, vehicle: nrel.hive.model.vehicle.vehicle.Vehicle, requests: Tuple[nrel.hive.util.RequestId, Ellipsis]) bool[source]

confirm that all requests currently exist in the system

Parameters:
  • sim – the simulation state

  • requests – the requests

Returns:

True if all requests currently exist

nrel.hive.state.vehicle_state.dispatch_ops.modify_vehicle_assignment(sim: nrel.hive.state.simulation_state.simulation_state.SimulationState, vehicle_id: nrel.hive.util.VehicleId, requests: Tuple[nrel.hive.util.RequestId, Ellipsis], unassign: bool = False) Tuple[Exception | None, nrel.hive.state.simulation_state.simulation_state.SimulationState | None][source]

assign/un-assign this vehicle to each request. if a request does not exist, it is ignored.

Parameters:
  • sim – the simulation state

  • vehicle_id – the vehicle to assign

  • requests – the requests to assign this vehicle to

:param assign if true, un-assign the request, otherwise, assign :return: either an error, or, the updated simulation

nrel.hive.state.vehicle_state.dispatch_ops.create_routes(sim: nrel.hive.state.simulation_state.simulation_state.SimulationState, trip_plan: Tuple[Tuple[nrel.hive.util.RequestId, nrel.hive.model.vehicle.trip_phase.TripPhase], Ellipsis]) Tuple[nrel.hive.model.roadnetwork.route.Route, Ellipsis][source]

creates routes between each phase of a trip plan. requires at least 2 entries in the trip plan, which in the base case, would be a PICKUP followed by a DROPOFF.

this does not include the access (dispatch) trip phase.

Parameters:
  • sim – the simulation state

  • env – the simulation environment

  • trip_plan – the trip plan

Returns:

nrel.hive.state.vehicle_state.dispatch_ops.get_position_for_phase(sim: nrel.hive.state.simulation_state.simulation_state.SimulationState, req_id: nrel.hive.util.RequestId, trip_phase: nrel.hive.model.vehicle.trip_phase.TripPhase) nrel.hive.model.entity_position.EntityPosition | None[source]

gets the EntityPosition for the request based on the trip phase

Parameters:
  • sim – the simulation state

  • req_id – the request id

  • trip_phase – pickup or dropoff phase of a trip

Returns:

the EntityPosition for the Request at the specified TripPhase

nrel.hive.state.vehicle_state.dispatch_ops.begin_or_replan_dispatch_pooling_state(sim: nrel.hive.state.simulation_state.simulation_state.SimulationState, vehicle_id: nrel.hive.util.VehicleId, trip_plan: Tuple[Tuple[nrel.hive.util.RequestId, nrel.hive.model.vehicle.trip_phase.TripPhase], Ellipsis]) Tuple[Exception | None, nrel.hive.state.vehicle_state.dispatch_pooling_trip.DispatchPoolingTrip | None][source]

create a DispatchPoolingTrip state. if the vehicle is currently in a ServicingPoolingTrip state, then carry over that state information here as well in the construction of the new state.

Parameters:
  • sim – the simulation state

  • vehicle_id – the vehicle to generate a new state for

  • trip_plan – the trip plan to put into effect

Returns:

a DispatchPoolingTrip state, or, an error