commonpower.control.runners.BaseRunner

class BaseRunner(sys: ~commonpower.core.System, global_controller: ~commonpower.control.controllers.OptimalController | None = None, horizon: ~datetime.timedelta = datetime.timedelta(days=1), dt: ~datetime.timedelta = datetime.timedelta(seconds=3600), continuous_control: bool = False, history: ~commonpower.modeling.history.ModelHistory | None = None, solver: ~pyomo.opt.base.solvers.OptSolver = <pyomo.solvers.plugins.solvers.gurobi_direct.GurobiDirect object>, seed: int | None = None, normalize_actions: bool = True)[source]

Bases: object

Base class for any runner for power system control with one or multiple agents. Initializes the system and its controllers. Can be used for training one or multiple reinforcement learning (RL) agents or for deploying agents. Subclasses mainly have to implement the ‘run()’ method.

Parameters:
  • sys (System) – power system to be controlled

  • global_controller (OptimalController) – instance of controller taking over control of all nodes that have not yet been assigned a controller. Mostly used to balance the system using a market node or a generator. Defaults to OptimalController(“global”).

  • horizon (timedelta) – amount of time that the controller looks into the future

  • dt (timedelta) – control time interval

  • continuous_control (bool) – whether to use an infinite control horizon

  • history (ModelHistory) – logger

  • solver (OptSolver) – solver for optimization problem

  • seed (int) – seed for the global random number generator of numpy (we use np.random.seed(seed) instead

  • generator) (of instantiating our own)

  • normalize_actions (bool) – whether or not to normalize the action space

Returns:

BaseRunner

Methods

finish_run

Terminates run.

prepare_run

Prepare the training or deployment by initializing the system and its controllers.

run

Simulates the scenario for a given number of time steps.

set_start_time

Set start time from external.

system_feasible

Check whether the current system set-up is feasible.

finish_run()[source]

Terminates run.

Returns:

None

prepare_run()[source]

Prepare the training or deployment by initializing the system and its controllers. Assigns a global controller that takes over control of all entities which require inputs and have not been assigned a controller by the system’s set-up.

Returns: None

run(n_steps: int = 24, fixed_start: datetime | None = None) None[source]

Simulates the scenario for a given number of time steps.

Parameters:
  • n_steps (int) – number of steps to run

  • fixed_start (datetime) – whether to run from a fixed given start timestamp

set_start_time(start_time: datetime)[source]

Set start time from external.

Parameters:

start_time (datetime) – date and hour at which to reset the system before starting a run.

Returns:

None

system_feasible(n_checks: int = 1)[source]

Check whether the current system set-up is feasible.

Parameters:

n_checks (int) – number of feasibility checks to run

Returns:

None