epyt_control.envs.actions

epyt_control.envs.actions.actions

This module contains a base class for actions.

class epyt_control.envs.actions.actions.Action[source]

Bases: object

Base class for actions.

abstract apply(env: epyt_flow.gym.ScenarioControlEnv, action_value) None[source]

Applies a given action (from the action space) in a given environment.

Parameters:
abstract to_gym_action_space() gymnasium.spaces.Space[source]

Converts this action to a gymnasium.spaces.Space instance.

Returns:

gymnasium.spaces.Space instance.

Return type:

gymnasium.spaces.Space

epyt_control.envs.actions.actuator_state_actions

This module contains classes for modeling actuator state action spaces – i.e. controlling pump and valve states.

class epyt_control.envs.actions.actuator_state_actions.ActuatorStateAction(state_space: list[int], **kwds)[source]

Bases: Action

Base class of an actuator state action.

Parameters:

state_space (list[int]) – List of possible actions that can be taken by the agent.

property action_space: list[int]

Returns the list of possible actions that an agent can take.

Returns:

List of possible actions.

Return type:

list[int]

to_gym_action_space() gymnasium.spaces.Space[source]

Converts this action to a gymnasium.spaces.Space instance.

Returns:

gymnasium.spaces.Space instance.

Return type:

gymnasium.spaces.Space

class epyt_control.envs.actions.actuator_state_actions.PumpStateAction(pump_id: str, **kwds)[source]

Bases: ActuatorStateAction

Action for controling the state of a pump.

Parameters:

pump_id (str) – ID of the pump.

apply(env: epyt_flow.gym.ScenarioControlEnv, action_value) None[source]

Applies a given action (from the action space) in a given environment.

Parameters:
  • env – The environment.

  • action_value (Any) – The action.

property pump_id: str

Return the ID of the pump.

Returns:

ID of the pump.

Return type:

str

class epyt_control.envs.actions.actuator_state_actions.ValveStateAction(valve_id: str, **kwds)[source]

Bases: ActuatorStateAction

Action for controlling the state of a valve.

Parameters:

valve_id (str) – ID of the valve.

apply(env: epyt_flow.gym.ScenarioControlEnv, action_value: int) None[source]

Applies a given action (from the action space) in a given environment.

Parameters:
  • env – The environment.

  • action_value (Any) – The action.

property valve_id: str

Returns the ID of the valve.

Returns:

ID of the valve.

Return type:

str

epyt_control.envs.actions.pump_speed_actions

This module contains a class for modeling pump speed action spaces.

class epyt_control.envs.actions.pump_speed_actions.PumpSpeedAction(pump_id: str, speed_lower_bound: float = 0.0, speed_upper_bound: float | None = None, **kwds)[source]

Bases: Action

Action for controlling the speed of a pump.

Parameters:
  • pump_id (str) – ID of the pump.

  • speed_lower_bound (float, optional) –

    Lower bound on the pump speed.

    The default is zero.

  • speed_upper_bound (float, optional) –

    Upper bound on the pump speed. If None, no upper bound restriction for the agent.

    The default is None.

apply(env: epyt_flow.gym.ScenarioControlEnv, action_value: float) None[source]

Applies a given action (from the action space) in a given environment.

Parameters:
  • env – The environment.

  • action_value (Any) – The action.

property pump_id: str

Return the ID of the pump.

Returns:

ID of the pump.

Return type:

str

property speed_lower_bound: float

Returns the lower bound of the pump speed that can be set by the agent.

Returns:

Lower bound on the pump speed.

Return type:

float

property speed_upper_bound: float

Returns the upper bound of the pump speed that can be set by the agent.

Returns:

Upper bound on the pump speed.

Return type:

float

to_gym_action_space() gymnasium.spaces.Space[source]

Converts this action to a gymnasium.spaces.Space instance.

Returns:

gymnasium.spaces.Space instance.

Return type:

gymnasium.spaces.Space

epyt_control.envs.actions.quality_actions

This module contains classes for modeling chemical/species injection action spaces – i.e. a chemical (EPANET) or species (EPANET-MSX) injection that has to be controlled by the agent.

class epyt_control.envs.actions.quality_actions.ChemicalInjectionAction(node_id: str, pattern_id: str, source_type_id: int, upper_bound: float | None = None, **kwds)[source]

Bases: Action

Action for controlling the injection of a chemical – only for EPANET control scenarios.

Parameters:
  • node_id (str) – ID of the node at which the injection is going to happen.

  • pattern_id (str) – ID of the pattern that is used for the injection.

  • source_type_id (int) –

    Type of the injection source – must be one of the following EPANET constants:

    • EN_CONCEN = 0

    • EN_MASS = 1

    • EN_SETPOINT = 2

    • EN_FLOWPACED = 3

    Description:

    • E_CONCEN Sets the concentration of external inflow entering a node

    • EN_MASS Injects a given mass/minute into a node

    • EN_SETPOINT Sets the concentration leaving a node to a given value

    • EN_FLOWPACED Adds a given value to the concentration leaving a node

  • upper_bound (float, optional) –

    Upper bound on the amount that can be injected by the agent. If None, there is no upper bound on the amount.

    The default is None.

apply(env: epyt_flow.gym.ScenarioControlEnv, action_value: float) None[source]

Applies a given action (from the action space) in a given environment.

Parameters:
  • env – The environment.

  • action_value (Any) – The action.

property node_id: str

Return the ID of the node at which the injection is going to happen.

Returns:

ID of the node.

Return type:

str

property pattern_id: str

Returns the ID of the pattern that is used for the injection.

Returns:

ID of the pattern.

Return type:

str

property source_type_id: int

Returns the type (i.e. ID) of the injection source – will be one of the following EPANET toolkit constants:

  • EN_CONCEN = 0

  • EN_MASS = 1

  • EN_SETPOINT = 2

  • EN_FLOWPACED = 3

Description:

  • E_CONCEN Sets the concentration of external inflow entering a node

  • EN_MASS Injects a given mass/minute into a node

  • EN_SETPOINT Sets the concentration leaving a node to a given value

  • EN_FLOWPACED Adds a given value to the concentration leaving a node

Returns:

Type (ID) of the injection source.

Return type:

int

to_gym_action_space() gymnasium.spaces.Space[source]

Converts this action to a gymnasium.spaces.Space instance.

Returns:

gymnasium.spaces.Space instance.

Return type:

gymnasium.spaces.Space

property upper_bound: float

Returns the upper bound on the amount that can be injected by the agent.

Returns:

Upper bound.

Return type:

float

class epyt_control.envs.actions.quality_actions.SpeciesInjectionAction(species_id: str, node_id: str, pattern_id: str, source_type_id: int, upper_bound: float | None = None, **kwds)[source]

Bases: ChemicalInjectionAction

Action for controlling the injection of a given species – only for EPANET-MSX control scenarios.

Parameters:
  • species_id (str) – ID of the species that is going to be injected by the agent.

  • node_id (str) – ID of the node at which the injection is going to happen.

  • pattern_id (str) – ID of the pattern that is used for the injection.

  • source_type_id (int) –

    Types of the injection source – must be one of the following EPANET toolkit constants:

    • EN_CONCEN = 0

    • EN_MASS = 1

    • EN_SETPOINT = 2

    • EN_FLOWPACED = 3

    Description:

    • E_CONCEN Sets the concentration of external inflow entering a node

    • EN_MASS Injects a given mass/minute into a node

    • EN_SETPOINT Sets the concentration leaving a node to a given value

    • EN_FLOWPACED Adds a given value to the concentration leaving a node

  • upper_bound (float, optional) –

    Upper bound on the amount that can be injected by the agent. If None, there is no upper bound on the amount.

    The default is None.

apply(env: epyt_flow.gym.ScenarioControlEnv, action_value: float) None[source]

Applies a given action (from the action space) in a given environment.

Parameters:
  • env – The environment.

  • action_value (Any) – The action.

property species_id: str

Returns the ID of the species that is going to be injected.

Returns:

ID of the species.

Return type:

str