nrel.hive.state.vehicle_state.servicing_ops
Module Contents
Classes
Typed version of namedtuple. |
Functions
|
helper to grab the currently-active trip |
|
performs the action associated with closing out a trip phase. |
helper to update the route of the leading trip when no route changes are required |
|
|
has a vehicle pick up a trip and receive payment for it. |
|
handles the dropping off of passengers, which is really mostly a validation |
- class nrel.hive.state.vehicle_state.servicing_ops.ActivePoolingTrip[source]
Bases:
NamedTupleTyped version of namedtuple.
Usage in Python versions >= 3.6:
class Employee(NamedTuple): name: str id: int
This is equivalent to:
Employee = collections.namedtuple('Employee', ['name', 'id'])
The resulting class has an extra __annotations__ attribute, giving a dict that maps field names to types. (The field names are also in the _fields attribute, which is part of the namedtuple API.) Alternative equivalent keyword syntax is also accepted:
Employee = NamedTuple('Employee', name=str, id=int)
In Python versions <= 3.5 use:
Employee = NamedTuple('Employee', [('name', str), ('id', int)])
- request_id: nrel.hive.util.RequestId
- trip_phase: nrel.hive.model.vehicle.trip_phase.TripPhase
- route: nrel.hive.model.roadnetwork.route.Route
- nrel.hive.state.vehicle_state.servicing_ops.get_active_pooling_trip(vehicle_state: nrel.hive.state.vehicle_state.servicing_pooling_trip.ServicingPoolingTrip) Tuple[Exception | None, ActivePoolingTrip | None][source]
helper to grab the currently-active trip
- Parameters:
vehicle_state – the servicing state to inspect
- Returns:
the active pooling trip we are servicing
- nrel.hive.state.vehicle_state.servicing_ops.complete_trip_phase(sim: nrel.hive.state.simulation_state.simulation_state.SimulationState, env: nrel.hive.runner.Environment, vehicle: nrel.hive.model.vehicle.vehicle.Vehicle, active_trip: ActivePoolingTrip) Tuple[Exception | None, nrel.hive.state.simulation_state.simulation_state.SimulationState | None][source]
performs the action associated with closing out a trip phase.
invariant: the Vehicle must be in a ServicingPoolingTrip state!
- Parameters:
sim – the simulation state
env – the simulation environment
vehicle – the vehicle
active_trip – the active pooling trip phase to close out
- Returns:
an error, or, the updated simulation state
- nrel.hive.state.vehicle_state.servicing_ops.update_active_pooling_trip(sim: nrel.hive.state.simulation_state.simulation_state.SimulationState, env: nrel.hive.runner.Environment, vehicle_id: nrel.hive.util.VehicleId) Tuple[Exception | None, nrel.hive.state.simulation_state.simulation_state.SimulationState | None][source]
helper to update the route of the leading trip when no route changes are required
- Parameters:
vehicle_state –
- Returns:
- nrel.hive.state.vehicle_state.servicing_ops.pick_up_trip(sim: nrel.hive.state.simulation_state.simulation_state.SimulationState, env: nrel.hive.runner.Environment, vehicle_id: nrel.hive.util.VehicleId, request_id: nrel.hive.util.RequestId) Tuple[Exception | None, nrel.hive.state.simulation_state.simulation_state.SimulationState | None][source]
has a vehicle pick up a trip and receive payment for it.
- Parameters:
sim – the sim state
env – the sim environment
vehicle_id – the vehicle picking up the request
request_id – the request to pick up
- Returns:
an error, or, the sim with the request picked up by the vehicle
- nrel.hive.state.vehicle_state.servicing_ops.drop_off_trip(sim: nrel.hive.state.simulation_state.simulation_state.SimulationState, env: nrel.hive.runner.Environment, vehicle_id: nrel.hive.util.VehicleId, request: nrel.hive.model.request.Request) Tuple[Exception | None, nrel.hive.state.simulation_state.simulation_state.SimulationState | None][source]
handles the dropping off of passengers, which is really mostly a validation step followed by a logging step.
- Parameters:
sim – the sim state
env – the sim environment
vehicle_id – vehicle dropping off the trip
trip – the trip to drop off
- Returns:
an exception due to failure or the simulation state