gym_anm.agents.mpc_constant.MPCAgentConstant

class gym_anm.agents.mpc_constant.MPCAgentConstant(*args, **kwargs)[source]

Bases: MPCAgent

A Model Predictive Control (MPC)-based policy with constant forecasts.

This class implements the \(\pi_{MPC-N}^{constant}\) policy, a variant of the general \(\pi_{MPC-N}\) policy in which the future demand and generation are assumed constant over the optimization horizon.

For more information, see https://gym-anm.readthedocs.io/en/latest/topics/mpc.html#constant-forecast.

__init__(*args, **kwargs)[source]
Parameters:
  • simulator (gym_anm.simulator.simulator.Simulator) – The electricity distribution network simulator.

  • action_space (gym.spaces.Box) – The action space of the environment (used to clip actions).

  • gamma (float) – The discount factor in [0, 1].

  • safety_margin (float, optional) – The safety margin constant \(\beta\) in [0, 1], used to further constraint the power flow on each transmission line, thus likely accounting for the error introduced in the DC approximation.

  • planning_steps (int, optional) – The number (N) of stages (time steps) taken into account in the optimization problem.

Methods

__init__(*args, **kwargs)

param simulator:

The electricity distribution network simulator.

act(env)

Select an action by solving the N-stage DC OPF.

forecast(env)

Forecast the demand and generation over the optimization horizon.

act(env)

Select an action by solving the N-stage DC OPF.

Parameters:

env (py:class:gym_anm.ANMEnv) – The gym-anm environment.

Returns:

The action vector to apply in the environment.

Return type:

numpy.ndarray

forecast(env)[source]

Forecast the demand and generation over the optimization horizon.

This method must be implemented by all sub-classes of MPCAgent. It gets called in act() and must return the predictions of future load demand, \(\tilde P_{l,k}^{(dev)}\), and maximum generation at non-slack generators, \(\tilde P_{g,k}^{(max)}\).

Parameters:

env (py:class:gym_anm.ANMEnv) – The gym-anm environment.

Returns:

  • P_load_forecast (array_like) – A (N_load, N) array of forecasted load power injections (<0), where N is the length of the optimization horizon. The rows should be ordered in increasing order of device ID.

  • P_gen_forecast (array_like) – A (N_gen-1, N) array of forecasted maximum generation from non-slack generators, where N is the length of the optimization horizon. The rows should be ordered in increasing order of device ID.