commonpower.control.safety_layer.safety_layers.BaseSafetyLayer

class BaseSafetyLayer[source]

Bases: object

Base class for safety layers. A safety layer checks whether the action selected by a controller violates any constraints of the controlled entities and adjusts the actions if necessary.

Returns:

BaseSafetyLayer

Methods

compute_safe_action

Checks whether the actions proposed by the controller satisfy the constraints of the controlled entities and modifies them if necessary.

initialize

Initializes the safety layer :param nodes: list of controlled entities to be safeguarded :type nodes: List[ModelEntity] :param top_level_nodes: list of controlled entities in highest level of model tree :type top_level_nodes: List[ModelEntity] :param solver: solver for optimization problem which will be called by Pyomo :type solver: OptSolver

compute_safe_action(action: Dict | None = None) Tuple[Dict, bool, float][source]

Checks whether the actions proposed by the controller satisfy the constraints of the controlled entities and modifies them if necessary.

Parameters:

action (dict) – action suggested by the controller

Returns:

safe_action (dict) – verified action action_corrected (bool): whether the action was corrected or not correction_penalty (float): penalty for action correction (0 if action was not corrected)

initialize(nodes: List[ModelEntity], top_level_nodes: List[ModelEntity])[source]

Initializes the safety layer :param nodes: list of controlled entities to be safeguarded :type nodes: List[ModelEntity] :param top_level_nodes: list of controlled entities in highest level of model tree :type top_level_nodes: List[ModelEntity] :param solver: solver for optimization problem which will be called by Pyomo :type solver: OptSolver

Returns:

None