nrel.hive.dispatcher.instruction_generator.assignment_ops
Module Contents
Classes
each call of find_assignment produces an AssignmentSolution which has any |
Functions
|
|
|
cost function based on the h3_distance between two entities |
|
cost function based on the great circle distance between two entities. |
set up a shortest queue distance function which will rank station alternatives based on |
|
sort ordering that prioritizes short vehicle queues where possible, using h3_distance |
|
ranks this station by an estimate of the time which would pass until this agent reaches a target charge level |
|
given a station charging alternative, determine the time it would take to charge |
Attributes
- nrel.hive.dispatcher.instruction_generator.assignment_ops.MAX_DIST = 999999999.0
- nrel.hive.dispatcher.instruction_generator.assignment_ops.MAX_TIME = 999999999.0
- class nrel.hive.dispatcher.instruction_generator.assignment_ops.AssignmentSolution[source]
Bases:
NamedTupleeach call of find_assignment produces an AssignmentSolution which has any assignments (a pair of two ids), along with the total cost of this assignment.
- solution: Tuple[Tuple[nrel.hive.util.typealiases.EntityId, nrel.hive.util.typealiases.EntityId], Ellipsis] = ()
- solution_cost: float = 0.0
- add(pair: Tuple[nrel.hive.util.typealiases.EntityId, nrel.hive.util.typealiases.EntityId], cost: float) AssignmentSolution[source]
- nrel.hive.dispatcher.instruction_generator.assignment_ops.find_assignment(assignees: Tuple[nrel.hive.model.entity.EntityABC, Ellipsis], targets: Tuple[nrel.hive.model.entity.EntityABC, Ellipsis], cost_fn: Callable[[nrel.hive.model.entity.EntityABC, nrel.hive.model.entity.EntityABC], float]) AssignmentSolution[source]
- Parameters:
assignees – entities we are assigning to. assumed to have an id field.
targets – the different entities that each assignee can be assigned to. assumed to have an id field.
cost_fn – computes the cost of choosing a specific assignee (slot 1) with a specific target (slot 2)
- Returns:
a collection of pairs of (AssigneeId, TargetId) indicating the solution, along with it’s cost
- nrel.hive.dispatcher.instruction_generator.assignment_ops.h3_distance_cost(a: nrel.hive.model.entity.EntityABC, b: nrel.hive.model.entity.EntityABC) float[source]
cost function based on the h3_distance between two entities
- Parameters:
a – one entity, expected to have a geoid
b – another entity, expected to have a geoid
- Returns:
the h3_distance (number of cells between)
- nrel.hive.dispatcher.instruction_generator.assignment_ops.great_circle_distance_cost(a: nrel.hive.model.entity.EntityABC, b: nrel.hive.model.entity.EntityABC) float[source]
cost function based on the great circle distance between two entities. reverts h3 geoid to a lat/lon pair and calculates the haversine distance.
- Parameters:
a – one entity, expected to have a geoid
b – another entity, expected to have a geoid
- Returns:
the haversine (great circle) distance in lat/lon
- nrel.hive.dispatcher.instruction_generator.assignment_ops.nearest_shortest_queue_distance(vehicle: nrel.hive.model.vehicle.vehicle.Vehicle, env: nrel.hive.runner.Environment) Callable[[nrel.hive.model.station.station.Station], float][source]
set up a shortest queue distance function which will rank station alternatives based on the availability of on-shift charging and a simple heuristic based on Euclidean distance and smallest queue size.
- Parameters:
vehicle – the vehicle
env – simulation environment
- Returns:
a station distance function
- nrel.hive.dispatcher.instruction_generator.assignment_ops.nearest_shortest_queue_ranking(vehicle: nrel.hive.model.vehicle.vehicle.Vehicle, station: nrel.hive.model.station.station.Station, env: nrel.hive.runner.Environment, max_dist=999999999.0) Tuple[nrel.hive.util.typealiases.ChargerId | None, float][source]
sort ordering that prioritizes short vehicle queues where possible, using h3_distance as the base distance metric and extending that value by the proportion of available chargers
- Parameters:
vehicle – the vehicle
station – a station
env – simulation environment
max_dist – upper-bound on distance values
- Returns:
the distance metric for this station, a function of it’s queue sizes and h3 distance
- nrel.hive.dispatcher.instruction_generator.assignment_ops.shortest_time_to_charge_distance(vehicle: nrel.hive.model.vehicle.vehicle.Vehicle, sim: nrel.hive.state.simulation_state.simulation_state.SimulationState, env: nrel.hive.runner.Environment, target_soc: nrel.hive.util.units.Ratio) Callable[[nrel.hive.model.station.station.Station], float][source]
ranks this station by an estimate of the time which would pass until this agent reaches a target charge level
this function returns a distance function which accepts a Station and returns Seconds
- Parameters:
vehicle – a vehicle
sim – the simulation state
env – the simulation environment
target_soc – the SoC we are attempting to reach in this charge session
- Returns:
the distance metric for this vehicle/station pair (lower is better)
- nrel.hive.dispatcher.instruction_generator.assignment_ops.shortest_time_to_charge_ranking(sim: nrel.hive.state.simulation_state.simulation_state.SimulationState, env: nrel.hive.runner.Environment, vehicle: nrel.hive.model.vehicle.vehicle.Vehicle, station: nrel.hive.model.station.station.Station, target_soc: nrel.hive.util.units.Ratio) Tuple[nrel.hive.util.typealiases.ChargerId, float] | None[source]
given a station charging alternative, determine the time it would take to charge using the best charger type available
- Parameters:
sim – simulation state
env – the simulation environment
vehicle – the vehicle
station – the station to rank
target_soc – target vehicle charging SoC percentage
- Returns:
a ranking (estimated travel + queue + charge time) for accessing the best-ranked charger