flow.utils package

Submodules

flow.utils.exceptions module

Flow-specific exceptions.

exception flow.utils.exceptions.FatalFlowError(msg)[source]

Bases: Exception

Exception class for Flow errors which do not allow for continuation.

flow.utils.flow_warnings module

Warnings that may be printed by Flow (e.g. deprecation warnings).

flow.utils.flow_warnings.deprecation_warning(obj, dep_from, dep_to)[source]

Print a deprecation warning.

Parameters

obj : class

The class with the deprecated attribute

dep_from : str

old (deprecated) name of the attribute

dep_to : str

new name for the attribute

flow.utils.registry module

flow.utils.rllib module

Utility functions for Flow compatibility with RLlib.

This includes: environment generation, serialization, and visualization.

class flow.utils.rllib.FlowParamsEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]

Bases: json.encoder.JSONEncoder

Custom encoder used to generate flow_params.json.

Extends json.JSONEncoder.

default(self, obj)[source]

See parent class.

Extended to support the VehicleParams object in flow/core/params.py.

flow.utils.rllib.get_flow_params(config)[source]

Return Flow experiment parameters, given an experiment result folder.

Parameters

config : dict < dict > or str

May be one of two things:

  • If it is a dict, then it is the stored RLlib configuration dict.

  • If it is a string, then it is the path to a flow_params json file.

Returns

dict

flow-related parameters, consisting of the following keys:

  • exp_tag: name of the experiment

  • env_name: name of the flow environment the experiment is running on

  • scenario: name of the scenario class the experiment uses

  • simulator: simulator that is used by the experiment (e.g. aimsun)

  • sim: simulation-related parameters (see flow.core.params.SimParams)

  • env: environment related parameters (see flow.core.params.EnvParams)

  • net: network-related parameters (see flow.core.params.NetParams and the scenario’s documentation or ADDITIONAL_NET_PARAMS component)

  • veh: vehicles to be placed in the network at the start of a rollout (see flow.core.params.VehicleParams)

  • initial: parameters affecting the positioning of vehicles upon initialization/reset (see flow.core.params.InitialConfig)

  • tls: traffic lights to be introduced to specific nodes (see flow.core.params.TrafficLightParams)

flow.utils.rllib.get_rllib_config(path)[source]

Return the data from the specified rllib configuration file.

flow.utils.rllib.get_rllib_pkl(path)[source]

Return the data from the specified rllib configuration file.

Module contents

empty init file to ensure documentation for utils is created.

exception flow.utils.FatalFlowError(msg)[source]

Bases: Exception

Exception class for Flow errors which do not allow for continuation.