nrel.hive

Subpackages

Submodules

Package Contents

Classes

HiveConfig

Typed version of namedtuple.

StepSimulation

Helper class that provides a standard way to create an ABC using

Update

Typed version of namedtuple.

Functions

package_root(→ pathlib.Path)

Attributes

__doc__

__doc__

FORMAT

rich_handler

nrel.hive.__doc__ = Multiline-String
Show Value
"""

##     ##  ####  ##     ##  #######
##     ##   ##   ##     ##  ##
#########   ##   ##     ##  ######
##     ##   ##    ##   ##   ##
##     ##  ####     ###     #######

                .' '.            __
       .        .   .           (__\_
        .         .         . -{{_(|8)
          ' .  . ' ' .  . '     (__/


**HIVE** is a Python application for simulating the effects of hypothetical
mobility as a service (MaaS) applications on
infrastructure, levels of service, and additional energy outcomes. Developed in
2019 at the National Renewable Energy Laboratory (NREL), HIVE is an
agent-based model that simulates MaaS operations over real world trip data.
"""
class nrel.hive.HiveConfig[source]

Bases: NamedTuple

Typed 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)])
global_config: nrel.hive.config.global_config.GlobalConfig
input_config: nrel.hive.config.input.Input
sim: nrel.hive.config.sim.Sim
network: nrel.hive.config.network.Network
dispatcher: nrel.hive.config.dispatcher_config.DispatcherConfig
scenario_output_directory: pathlib.Path
classmethod build(scenario_file_path: pathlib.Path, config: Dict | None = None, output_suffix: str | None = None) Exception | HiveConfig[source]

builds a hive config by reading from a scenario file. optionally append additional key/value pairs and modify the datetime convention for naming output directories. :param scenario_file_path: path to the file to load as a HiveConfig :param config: optional overrides to the default config values (Default: None) :param output_suffix: directory name suffix to append to sim_name (by default, timestamp) :return: a hive config or an error

classmethod from_dict(d: Dict, scenario_file_path: pathlib.Path, output_suffix: str | None) HiveConfig[source]
asdict() Dict[source]
set_scenario_output_directory(output_directory: pathlib.Path) HiveConfig[source]
suppress_logging() HiveConfig[source]
to_yaml()[source]

writes this configuration as a file in the scenario output directory

nrel.hive.__doc__ = Multiline-String
Show Value
"""
dispatchers assign requests to vehicles and reposition unassigned vehicles
"""
class nrel.hive.StepSimulation[source]

Bases: nrel.hive.state.simulation_state.update.simulation_update.SimulationUpdateFunction

Helper class that provides a standard way to create an ABC using inheritance.

property ordered_instruction_generators: Tuple[nrel.hive.dispatcher.instruction_generator.instruction_generator.InstructionGenerator, Ellipsis]
instruction_generators: immutables.Map[nrel.hive.dispatcher.instruction_generator.instruction_generator.InstructionGeneratorId, nrel.hive.dispatcher.instruction_generator.instruction_generator.InstructionGenerator]
instruction_generator_order: Tuple[nrel.hive.dispatcher.instruction_generator.instruction_generator.InstructionGeneratorId, Ellipsis]
classmethod from_tuple(instruction_generators: Tuple[nrel.hive.dispatcher.instruction_generator.instruction_generator.InstructionGenerator, Ellipsis]) StepSimulation[source]

Create a StepSimulation from a tuple of instruction generators.

update_instruction_generators(updated_i_gens: Tuple[nrel.hive.dispatcher.instruction_generator.instruction_generator.InstructionGenerator, Ellipsis]) StepSimulation[source]

Update the set of instruction generators.

update(simulation_state: nrel.hive.state.simulation_state.simulation_state.SimulationState, env: nrel.hive.runner.environment.Environment) Tuple[nrel.hive.state.simulation_state.simulation_state.SimulationState, StepSimulation][source]

generates all instructions for this time step and then attempts to apply them to the SimulationState upon completion, returns the modified simulation state along with any reports and additionally, returns an updated version of the StepSimulation (in the case of any modifications to the InstructionGenerators)

before beginning, it first calls a provided update function on the set of InstructionGenerators for any control models injected by the user

Parameters:
  • simulation_state – state to modify

  • env – the sim environment

Returns:

updated simulation state, with reports, along with the (optionally) updated StepSimulation

get_instruction_generator(identifier: nrel.hive.dispatcher.instruction_generator.instruction_generator.InstructionGeneratorId | Type[nrel.hive.dispatcher.instruction_generator.instruction_generator.InstructionGenerator]) returns.result.ResultE[nrel.hive.dispatcher.instruction_generator.instruction_generator.InstructionGenerator][source]

Get the instance of an internal instruction generator either by an id or the actual class type.

update_instruction_generator(i_gen: nrel.hive.dispatcher.instruction_generator.instruction_generator.InstructionGenerator) returns.result.ResultE[StepSimulation][source]

Update a single instruction generator.

class nrel.hive.Update[source]

Bases: NamedTuple

Typed 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)])
pre_step_update: Tuple[nrel.hive.state.simulation_state.update.simulation_update.SimulationUpdateFunction, Ellipsis]
step_update: nrel.hive.state.simulation_state.update.step_simulation.StepSimulation
classmethod build(config: nrel.hive.config.HiveConfig, instruction_generators: Tuple[nrel.hive.dispatcher.instruction_generator.instruction_generator.InstructionGenerator, Ellipsis]) Update[source]

constructs the functionality to update the simulation each time step

Parameters:
  • config

  • instruction_generators – any overriding dispatcher functionality

Returns:

the Update that will be applied at each time step

apply_update(runner_payload: nrel.hive.runner.RunnerPayload) nrel.hive.runner.RunnerPayload[source]

applies the update at a time step, calling each SimulationUpdateFunction in order

Parameters:

runner_payload – the current SimulationState and assets at the current simtime

Returns:

the updated payload after one SimTime step

nrel.hive.package_root() pathlib.Path[source]
nrel.hive.FORMAT = '%(message)s'
nrel.hive.rich_handler