nrel.hive.state.simulation_state.update.step_simulation_ops
Module Contents
Classes
Typed version of namedtuple. |
Functions
|
|
|
|
helper function for StepSimulation which runs the update function for all driver states |
|
helper function for StepSimulation which applies a vehicle state update to each vehicle |
|
|
this helper function takes a map with one instruction per agent at most, and attempts to apply each |
applies a user-provided function designed to inject an external update to InstructionGenerators |
Attributes
- nrel.hive.state.simulation_state.update.step_simulation_ops._instruction_to_report(i: nrel.hive.dispatcher.instruction.instruction.Instruction, sim_time: nrel.hive.model.sim_time.SimTime) nrel.hive.reporting.reporter.Report[source]
- nrel.hive.state.simulation_state.update.step_simulation_ops.log_instructions(instructions: Tuple[nrel.hive.dispatcher.instruction.instruction.Instruction, Ellipsis], env: nrel.hive.runner.environment.Environment, sim_time: nrel.hive.model.sim_time.SimTime)[source]
- nrel.hive.state.simulation_state.update.step_simulation_ops.step_vehicle(s: nrel.hive.state.simulation_state.simulation_state.SimulationState, env: nrel.hive.runner.environment.Environment, vehicle: nrel.hive.model.vehicle.vehicle.Vehicle) nrel.hive.state.simulation_state.simulation_state.SimulationState[source]
- nrel.hive.state.simulation_state.update.step_simulation_ops.perform_driver_state_updates(simulation_state: nrel.hive.state.simulation_state.simulation_state.SimulationState, env: nrel.hive.runner.environment.Environment) nrel.hive.state.simulation_state.simulation_state.SimulationState[source]
helper function for StepSimulation which runs the update function for all driver states
- Parameters:
simulation_state – the simulation state to update
env – the simulation environment
- Returns:
the sim after all vehicle update functions have been called
- nrel.hive.state.simulation_state.update.step_simulation_ops.perform_vehicle_state_updates(simulation_state: nrel.hive.state.simulation_state.simulation_state.SimulationState, env: nrel.hive.runner.environment.Environment) nrel.hive.state.simulation_state.simulation_state.SimulationState[source]
helper function for StepSimulation which applies a vehicle state update to each vehicle
- Parameters:
simulation_state – the simulation state to update
env – the simulation environment
- Returns:
the sim after all vehicle update functions have been called
- nrel.hive.state.simulation_state.update.step_simulation_ops.InstructionApplicationResult
- nrel.hive.state.simulation_state.update.step_simulation_ops.apply_instructions(sim: nrel.hive.state.simulation_state.simulation_state.SimulationState, env: nrel.hive.runner.environment.Environment, instructions: Tuple[nrel.hive.dispatcher.instruction.instruction.Instruction, Ellipsis]) nrel.hive.state.simulation_state.simulation_state.SimulationState[source]
this helper function takes a map with one instruction per agent at most, and attempts to apply each instruction to the simulation, managing the instruction’s externalities, and managing failure.
- Parameters:
sim – the current simulation state
env – the sim environment
instructions – all instructions to add at this time step
- Returns:
the simulation state modified by all successful Instructions
- class nrel.hive.state.simulation_state.update.step_simulation_ops.UserProvidedUpdateAccumulator[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)])
- updated_fns: Tuple[nrel.hive.dispatcher.instruction_generator.instruction_generator.InstructionGenerator, Ellipsis] = ()
- apply_updated_instruction_generator(i: nrel.hive.dispatcher.instruction_generator.instruction_generator.InstructionGenerator)[source]
- nrel.hive.state.simulation_state.update.step_simulation_ops.instruction_generator_update_fn(fn: Callable[[nrel.hive.dispatcher.instruction_generator.instruction_generator.InstructionGenerator, nrel.hive.state.simulation_state.simulation_state.SimulationState], nrel.hive.dispatcher.instruction_generator.instruction_generator.InstructionGenerator | None], sim: nrel.hive.state.simulation_state.simulation_state.SimulationState) Callable[[UserProvidedUpdateAccumulator, nrel.hive.dispatcher.instruction_generator.instruction_generator.InstructionGenerator], UserProvidedUpdateAccumulator][source]
applies a user-provided function designed to inject an external update to InstructionGenerators
- Parameters:
fn – the function which applies an update or returns None for no update
sim – the simulation state, which will not be modified but available to the update function
- Returns:
the updated list of InstructionGenerators