Supervisor Controller

Controller Data

class pandaprosumer.supervisor.supervisor.SupervisorData(input_columns: List[str], result_columns: List[str])[source]

Data class for supervisor controller.

Attributes

controlled_columnsList[str]

List of input column names.

Controller

Given a set of input columns, the Supervisor checks whether each defined rule is satisfied. If the condition is met, the supervisor executes a corresponding action (such as modifying an attribute of the prosumer). If the condition is not satisfied, a fallback action can optionally be applied. This enables dynamic, logic-driven changes to the system inputs in response to time series data or simulation states.

class pandaprosumer.supervisor.supervisor.Supervisor(prosumer, supervisor_object, order=-1, level=-1, in_service=True, index=None, drop_same_existing_ctrl=False, overwrite=False, name='supervisor', matching_params=None, **kwargs)[source]
add_rule(rule: Rule)[source]

Adds a rule-based action to the supervisor.

Parameters:

action – An instance of Action class containing rule and action to execute.

control_step(prosumer)[source]

Executes the control step for the controller.

Parameters:

prosumer – The prosumer object

finalize_control(container)[source]

Finalizes the step for the controller.

Parameters:
  • container – The container object

  • time – The current time step

Rule Class

Each rule evaluates one input column using a comparison operator (e.g., <, >, ==, etc.) against a threshold. If the condition is true, the rule executes an action that changes an attribute in the prosumer or a mapped object. If false, it can optionally execute an alternative action. If you decide to change the value of a maximum or minimum attribute, such as the max_q_value of the gas boiler, the supervisor ensures that the new value does not exceed the original extremum. It is also possible to change the attributes of a mapping controller (e.g., FluidMixMapping), especially if you want to modify the fluid mix mapping order between an initiator and its responders; in that case, you must set the mapping argument to true. Finally, you can use lists for the last parameters (controller, attr, new_value, value_if_false, mapping), allowing each rule to execute multiple actions. All lists must be the same length, where action 1 corresponds to the first element of each list, action 2 to the second, and so on.

class pandaprosumer.supervisor.rule.Rule(controlled_columns, operator_str, threshold_value, controller, attr, new_value, value_if_false=None, mapping=None)[source]

A class representing a rule that applies conditional logic to data and executes an action based on the evaluation of the condition. The rule compares an input value against a threshold using an operator and, if the condition is met, modifies a specified attribute of a prosumer’s data.

add_to_prosumer(prosumer)[source]

Adds the rule to the prosumer’s ‘Rules’ DataFrame.

evaluate(input)[source]

Evaluates the rule using the input data.

execute_action(prosumer, supervisor)[source]

Executes the action(s) on the controller(s).

Example

Suppose you want to reduce the maximum power output of a generator if the price column exceeds a certain threshold:

rule = Rule(
    controlled_columns="price",
    operator_str=">",
    threshold_value=100,
    controller=0,
    attr="max_p_kw",
    new_value=50.0,
    value_if_false=100.0,
    mapping = False
)
supervisor.add_rule(rule)

Combining Rule

The CombiningRules class allows multiple Rule instances to be evaluated together using logical operators such as AND or OR. This enables more complex, composite logic to govern control decisions in a Supervisor.

class pandaprosumer.supervisor.combining_rule.CombiningRules(rules: List[Rule], logical_operator: str = 'AND')[source]

A class that allows combining multiple rules using logical operators (AND, OR).

evaluate(input_data: dict)[source]

Evaluates the combined rules.

Args:

input_data (dict): A dictionary with values for each rule’s input column.

Returns:

bool: True if the composite rule is met, False otherwise.

execute_action(prosumer, supervisor)[source]

Executes the action of all the rules if the condition is met.

Example

rule1 = Rule("price", ">", 100, controller=0, attr="max_p_kw", new_value=50)
rule2 = Rule("demand", "<", 30, controller=0, attr="max_p_kw", new_value=50)

combo = CombiningRules([rule1, rule2], logical_operator="AND")
supervisor.add_rule(combo)

This example applies a limit to power output only if both the price is above 100 and demand is below 30.

Notes

  • The composite rule stores logical linkage information in the prosumer’s internal rule structure.

  • Even though all rules are evaluated individually, they are treated as one logic unit for decision-making.