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:
objectBase 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
Terminates run.
Prepare the training or deployment by initializing the system and its controllers.
Simulates the scenario for a given number of time steps.
Set start time from external.
Check whether the current system set-up is feasible.
- 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