nrel.hive.initialization.initialize_simulation
Module Contents
Functions
|
Initialize a simulation using a config object and a set of arbitrary initialization functions. |
An initialization function to add fleets to the environment |
|
An initialization function to add schedules to the environment |
|
An initialization function to add mechatronics to the environment |
|
An initialization function to add chargers to the environment |
|
An initialization function to add reporting to the environment |
|
|
Returns the defaul initialization functions in the proper order. |
|
Initialize an OSMRoadNetwork and add to the simulation |
adds all vehicles from the provided vehicles file |
|
|
all your base are belong to us |
vehicles which had a home base assigned will automatically generate a home base membership id |
|
all your station are belong to us |
Attributes
- nrel.hive.initialization.initialize_simulation.InitFunction
- nrel.hive.initialization.initialize_simulation.initialize(config: nrel.hive.config.HiveConfig, init_functions: Iterable[InitFunction] | None = None) Tuple[nrel.hive.state.simulation_state.simulation_state.SimulationState, nrel.hive.runner.environment.Environment][source]
Initialize a simulation using a config object and a set of arbitrary initialization functions. If no initialziation functions are specified, we use a set of default functions to provide basic initialization
NOTE: If providing custom initialization functions, the default functions would be overritten and so be sure to also include the default functions when passing any functions via the init_functions parameter.
ALSO NOTE: The order of the initialization matters as some initialization functions depend on a previous function. For example, the base, station and vehicle initialization functions need to have access to the road network and so that initalization step must come before those functions are called.
- Parameters:
config – the configuration of this run
init_functions – any optional custom initialization functions
- Returns:
an initialized SimulationState and Environment
:raises Exception due to IOErrors, missing keys in DictReader rows, or parsing errors
- nrel.hive.initialization.initialize_simulation.initialize_environment_fleets(config: nrel.hive.config.HiveConfig, simulation_state: nrel.hive.state.simulation_state.simulation_state.SimulationState, environment: nrel.hive.runner.environment.Environment) Tuple[nrel.hive.state.simulation_state.simulation_state.SimulationState, nrel.hive.runner.environment.Environment][source]
An initialization function to add fleets to the environment
- Parameters:
config – the configuration of this run
simulation_state – the partially initialized simulation state
environment – the partially initialized environment
- Returns:
a SimulationState and Environment with fleets added
- nrel.hive.initialization.initialize_simulation.initialize_environment_schedules(config: nrel.hive.config.HiveConfig, simulation_state: nrel.hive.state.simulation_state.simulation_state.SimulationState, environment: nrel.hive.runner.environment.Environment) Tuple[nrel.hive.state.simulation_state.simulation_state.SimulationState, nrel.hive.runner.environment.Environment][source]
An initialization function to add schedules to the environment
- Parameters:
config – the configuration of this run
simulation_state – the partially initialized simulation state
environment – the partially initialized environment
- Returns:
a SimulationState and Environment with schedules added
- nrel.hive.initialization.initialize_simulation.initialize_environment_mechatronics(config: nrel.hive.config.HiveConfig, simulation_state: nrel.hive.state.simulation_state.simulation_state.SimulationState, environment: nrel.hive.runner.environment.Environment) Tuple[nrel.hive.state.simulation_state.simulation_state.SimulationState, nrel.hive.runner.environment.Environment][source]
An initialization function to add mechatronics to the environment
- Parameters:
config – the configuration of this run
simulation_state – the partially initialized simulation state
environment – the partially initialized environment
- Returns:
a SimulationState and Environment with mechatronics added
- nrel.hive.initialization.initialize_simulation.initialize_environment_chargers(config: nrel.hive.config.HiveConfig, simulation_state: nrel.hive.state.simulation_state.simulation_state.SimulationState, environment: nrel.hive.runner.environment.Environment) Tuple[nrel.hive.state.simulation_state.simulation_state.SimulationState, nrel.hive.runner.environment.Environment][source]
An initialization function to add chargers to the environment
- Parameters:
config – the configuration of this run
simulation_state – the partially initialized simulation state
environment – the partially initialized environment
- Returns:
a SimulationState and Environment with chargers added
- nrel.hive.initialization.initialize_simulation.initialize_environment_reporting(config: nrel.hive.config.HiveConfig, simulation_state: nrel.hive.state.simulation_state.simulation_state.SimulationState, environment: nrel.hive.runner.environment.Environment) Tuple[nrel.hive.state.simulation_state.simulation_state.SimulationState, nrel.hive.runner.environment.Environment][source]
An initialization function to add reporting to the environment
- Parameters:
config – the configuration of this run
simulation_state – the partially initialized simulation state
environment – the partially initialized environment
- Returns:
a SimulationState and Environment with reporting added
- nrel.hive.initialization.initialize_simulation.default_init_functions() Iterable[InitFunction][source]
Returns the defaul initialization functions in the proper order.
- nrel.hive.initialization.initialize_simulation.osm_init_function(config: nrel.hive.config.HiveConfig, simulation_state: nrel.hive.state.simulation_state.simulation_state.SimulationState, environment: nrel.hive.runner.environment.Environment, cache_dir=Path.home()) Tuple[nrel.hive.state.simulation_state.simulation_state.SimulationState, nrel.hive.runner.environment.Environment][source]
Initialize an OSMRoadNetwork and add to the simulation
- Parameters:
config – the hive config
simulation_state – the partially-constructed simulation state
environment – the partially-constructed environment
- Returns:
the SimulationState with the OSMRoadNetwork in it
- Raises:
Exception – from IOErrors parsing the road network
- nrel.hive.initialization.initialize_simulation.vehicle_init_function(config: nrel.hive.config.HiveConfig, simulation_state: nrel.hive.state.simulation_state.simulation_state.SimulationState, environment: nrel.hive.runner.environment.Environment) Tuple[nrel.hive.state.simulation_state.simulation_state.SimulationState, nrel.hive.runner.environment.Environment][source]
adds all vehicles from the provided vehicles file
- Parameters:
config – the hive config
simulation_state – the partially-constructed simulation state
environment – the partially-constructed environment
- Returns:
the SimulationState with vehicles in it
- Raises:
Exception – from IOErrors parsing the vehicle, powertrain, or powercurve files
- nrel.hive.initialization.initialize_simulation.base_init_function(config: nrel.hive.config.HiveConfig, simulation_state: nrel.hive.state.simulation_state.simulation_state.SimulationState, environment: nrel.hive.runner.environment.Environment) Tuple[nrel.hive.state.simulation_state.simulation_state.SimulationState, nrel.hive.runner.environment.Environment][source]
all your base are belong to us
- Parameters:
bases_file – path to file with bases
base_member_ids – an immutables Map with all of the base membership ids
simulation_state – the partial simulation state
base_filter – a function that returns True if a base should be filtered out of the simulation
- Returns:
the simulation state with all bases in it
:raises Exception if a parse error in Base.from_row or any error adding the Base to the Sim
- nrel.hive.initialization.initialize_simulation._assign_private_memberships(sim: nrel.hive.state.simulation_state.simulation_state.SimulationState) nrel.hive.state.simulation_state.simulation_state.SimulationState[source]
vehicles which had a home base assigned will automatically generate a home base membership id which links the vehicle and the base, in order to avoid having to specify this (obvious) relationship in the fleets configuration of a scenario.
- Parameters:
sim – partial simulation state with vehicles and bases added
- Returns:
sim state where vehicles + bases which should have a private relationship have been updated
- nrel.hive.initialization.initialize_simulation.station_init_function(config: nrel.hive.config.HiveConfig, simulation_state: nrel.hive.state.simulation_state.simulation_state.SimulationState, environment: nrel.hive.runner.environment.Environment) Tuple[nrel.hive.state.simulation_state.simulation_state.SimulationState, nrel.hive.runner.environment.Environment][source]
all your station are belong to us
- Parameters:
config – the hive config
simulation_state – the partial simulation state
environment – the simulation environment
- Returns:
the resulting simulation state with all stations in it
:raises Exception if parsing a Station row failed or adding a Station to the Simulation failed