eta_ctrl.envs.state module
- class eta_ctrl.envs.state.StateVar(*, name: str, is_agent_action: bool = False, is_agent_observation: bool = False, add_to_state_log: bool = True, ext_id: str | None = None, is_ext_input: bool = False, is_ext_output: bool = False, ext_scale_add: float = 0.0, ext_scale_mult: float = 1.0, scenario_id: str | None = None, from_scenario: bool = False, scenario_scale_add: float = 0.0, scenario_scale_mult: float = 1.0, low_value: float = -3.4028234663852886e+38, high_value: float = 3.4028234663852886e+38, abort_condition_min: float = -inf, abort_condition_max: float = inf, index: int = 0, duration: int = 1)[source]
Bases:
BaseModelA variable in the state of an environment.
- model_config = {'extra': 'forbid', 'frozen': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- is_agent_observation: bool
Should the agent be allowed to observe the value of this variable? (default: False).
- add_to_state_log: bool
Should the state log of this episode be added to state_log_longtime? (default: True).
- ext_id: str | None
Name of the variable in the external model (e.g.: environment or FMU) (default: StateVar.name if (is_ext_input or is_ext_output) else None).
- is_ext_input: bool
Should this variable be passed to the external model as an input? (default: False).
- is_ext_output: bool
Should this variable be parsed from the external model output? (default: False).
- scenario_id: str | None
Name of the scenario variable, this value should be read from (default: None).
- scenario_scale_mult: float
Value to multiply to the value read from a scenario file (default: 1.0).
- high_value: float
Highest possible value of the state variable (default: np.finfo(np.float32).max).
- abort_condition_min: float
If the value of the variable dips below this, the episode should be aborted (default: -np.inf).
- abort_condition_max: float
If the value of the variable rises above this, the episode should be aborted (default: np.inf).
- index: int
Determine the index, where to look (useful for mathematical optimization, where multiple time steps could be returned). In this case, the index values might be different for actions and observations.
- duration: int
For scenario StateVars: Length of StateVars horizon in state, e.g. the prediction horizon length (unit: steps).
- class eta_ctrl.envs.state.StateStructure(*, state_parameters: dict[str, float | bool] | None = None, actions: list[StateVar], observations: list[StateVar])[source]
Bases:
BaseModelUsed for parsing the state structure from a config file.
- model_config = {'extra': 'forbid', 'frozen': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class eta_ctrl.envs.state.StateConfig(*state_vars: StateVar, source_file: Path | None = None)[source]
Bases:
objectThe configuration for the action and observation spaces. The values are used to control which variables are part of the action space and observation space. Therefore, the StateConfig is very important for the functionality of EtaCtrl.
- vars
Mapping of the variables names to their StateVar instance with all associated information.
- df_vars: pandas.DataFrame
- ext_inputs: list[str]
List of variables that should be provided to an external source (such as an FMU).
- ext_outputs: list[str]
List of variables that can be received from an external source (such as an FMU).
- classmethod from_file(root_path: pathlib.Path, filename: Path, extra_params: Mapping[str, float] | None = None) Self[source]
Load a StateConfig from a config file.
- Parameters:
file – Path of the config file.
- Returns:
StateConfig object.
- classmethod from_dict(mapping: Sequence[dict[str, Any]] | pd.DataFrame, *, state_params: Mapping[str, float] | None = None, **kwargs: Any) Self[source]
Convert a potentially incomplete StateConfig DataFrame or a list of dictionaries to the standardized StateConfig format. This will ignore any additional columns.
- Parameters:
mapping – Mapping to be converted to the StateConfig format.
state_params – State parameter values for parameters supplied in mapping (e.g. {min_temp: 20})
- Returns:
StateConfig object.
- store_file(file: Path) None[source]
Save the StateConfig to a comma separated file.
- Parameters:
file – Path to the file.
- within_abort_conditions(state: Mapping[str, float]) bool[source]
Check whether the given state is within the abort conditions specified by the StateConfig instance.
- Parameters:
state – The state array to check for conformance.
- Returns:
Result of the check (False if the state does not conform to the required conditions).
- continuous_action_space() Box[source]
Generate a numpy ndarray action space.
- Returns:
Action space.
- continuous_observation_space() Dict[source]
Generate a dictionary observation space.
- Returns:
Observation Space.
- continuous_spaces() tuple[Box, Dict][source]
Generate continuous action and observation spaces according to the OpenAI specification.
- Returns:
Tuple of action space and observation space.
- property loc: pandas.api.indexers._LocIndexer
Behave like dataframe (enable indexing via loc) for compatibility.