nrel.hive.dispatcher.instruction_generator.instruction_generator_ops
Module Contents
Classes
Typed version of namedtuple. |
Functions
|
applies a set of InstructionGenerators to the SimulationState; |
only allows vehicles to use stations where the membership is correct |
|
a helper function to set n vehicles to charge at a station |
|
a helper function to find the distance between a vehicle and the closest valid station |
Attributes
- nrel.hive.dispatcher.instruction_generator.instruction_generator_ops.i_map: immutables.Map[nrel.hive.dispatcher.instruction.instructions.VehicleId, List[nrel.hive.dispatcher.instruction.instructions.Instruction]]
- class nrel.hive.dispatcher.instruction_generator.instruction_generator_ops.InstructionGenerationResult[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)])
- instruction_stack: immutables.Map[nrel.hive.dispatcher.instruction.instructions.VehicleId, nrel.hive.dispatcher.instruction.instructions.Tuple[nrel.hive.dispatcher.instruction.instructions.Instruction, Ellipsis]]
- updated_instruction_generators: nrel.hive.dispatcher.instruction.instructions.Tuple[nrel.hive.dispatcher.instruction_generator.instruction_generator.InstructionGenerator, Ellipsis] = ()
- apply_instruction_generator(instruction_generator: nrel.hive.dispatcher.instruction_generator.instruction_generator.InstructionGenerator, simulation_state: nrel.hive.dispatcher.instruction.instructions.SimulationState, environment: nrel.hive.dispatcher.instruction.instructions.Environment) InstructionGenerationResult[source]
generates instructions from one of the InstructionGenerators; each of these instructions are added to the stack for the appropriate vehicle id;
- Parameters:
instruction_generator – an InstructionGenerator to apply to the SimulationState
simulation_state – the current simulation state
environment – the simulation environment
- Returns:
the updated accumulator
- add_driver_instructions(simulation_state, environment)[source]
drivers are given a chance to optionally generate instructions; each of these instructions are added to the stack for the appropriate vehicle id;
- Parameters:
simulation_state – the current simulation state
environment – the simulation environment
- Returns:
- nrel.hive.dispatcher.instruction_generator.instruction_generator_ops.generate_instructions(instruction_generators: nrel.hive.dispatcher.instruction.instructions.Tuple[nrel.hive.dispatcher.instruction_generator.instruction_generator.InstructionGenerator, Ellipsis], simulation_state: nrel.hive.dispatcher.instruction.instructions.SimulationState, environment: nrel.hive.dispatcher.instruction.instructions.Environment) InstructionGenerationResult[source]
applies a set of InstructionGenerators to the SimulationState; each time an instruction is generated it gets added to a stack (per vehicle id); the last instruction to be added gets popped and executed; thus, the order of instruction generation matters as the last instruction generated (per vehicle) gets executed;
- Parameters:
instruction_generators – a tuple of instruction generators
simulation_state – the simulation state
environment – the simulation environment
- Returns:
the instructions generated for this time step (0 to many instructions per vehicle)
- nrel.hive.dispatcher.instruction_generator.instruction_generator_ops.valid_station_for_vehicle(vehicle: nrel.hive.model.vehicle.vehicle.Vehicle, env: nrel.hive.dispatcher.instruction.instructions.Environment) Callable[[nrel.hive.model.station.station.Station], bool][source]
only allows vehicles to use stations where the membership is correct and the fuel type is correct :param vehicle: the vehicle :param env: simulation environment :return: valid station function
- nrel.hive.dispatcher.instruction_generator.instruction_generator_ops.instruct_vehicles_to_dispatch_to_station(n: int, max_search_radius_km: float, vehicles: nrel.hive.dispatcher.instruction.instructions.Tuple[nrel.hive.model.vehicle.vehicle.Vehicle, Ellipsis], simulation_state: nrel.hive.dispatcher.instruction.instructions.SimulationState, environment: nrel.hive.dispatcher.instruction.instructions.Environment, target_soc: nrel.hive.util.units.Ratio, charging_search_type: nrel.hive.dispatcher.instruction_generator.charging_search_type.ChargingSearchType) nrel.hive.dispatcher.instruction.instructions.Tuple[nrel.hive.dispatcher.instruction.instructions.Instruction, Ellipsis][source]
a helper function to set n vehicles to charge at a station
- Parameters:
n – how many vehicles to charge at the base
max_search_radius_km – the max kilometers to search for a station
vehicles – the list of vehicles to consider
simulation_state – the simulation state
environment – the simulation environment
target_soc – when ranking alternatives, use this target SoC value
charging_search_type – the type of search to conduct
- Returns:
instructions for vehicles to charge at stations
- nrel.hive.dispatcher.instruction_generator.instruction_generator_ops.get_nearest_valid_station_distance(max_search_radius_km: float, vehicle: nrel.hive.model.vehicle.vehicle.Vehicle, geoid: nrel.hive.util.typealiases.GeoId, simulation_state: nrel.hive.dispatcher.instruction.instructions.SimulationState, environment: nrel.hive.dispatcher.instruction.instructions.Environment, target_soc: nrel.hive.util.units.Ratio, charging_search_type: nrel.hive.dispatcher.instruction_generator.charging_search_type.ChargingSearchType) nrel.hive.util.units.Kilometers[source]
a helper function to find the distance between a vehicle and the closest valid station
- Parameters:
max_search_radius_km – the max kilometers to search for a station
vehicle – the vehicle to consider
geoid – the geoid of the origin
simulation_state – the simulation state
environment – the simulation environment
target_soc – when ranking alternatives, use this target SoC value
charging_search_type – the type of search to conduct
- Returns:
the distance in km to the nearest valid station