Network Model¶
Network of power devices.
-
class
dem.network.Terminal¶ Bases:
objectDevice terminal.
-
power¶ Power consumed (positive value) or produced (negative value) at this terminal.
-
-
class
dem.network.Net(terminals, name=None)¶ Bases:
objectConnection point for device terminals.
A net defines the power balance constraint ensuring that power sums to zero across all connected terminals at each time point.
Parameters: - terminals (list of
Terminal) – The terminals connected to this net - name (string) – (optional) Display name of net
-
price¶ Price associated with this net.
- terminals (list of
-
class
dem.network.Device(terminals, name=None)¶ Bases:
objectBase class for network device.
Subclasses are expected to override
constraintsand/orcostto define the device-specific cost function.Parameters: - terminals (list of
Terminal) – The terminals of the device - name (string) – (optional) Display name of device
-
cost¶ Device objective, to be overriden by subclasses.
Return type: cvxpy expression of size \(T imes K\)
-
constraints¶ Device constraints, to be overriden by subclasses.
Return type: list of cvxpy constraints
-
problem¶ The network optimization problem.
Return type: cvxpy.Problem
-
init_problem(time_horizon=1, num_scenarios=1)¶ Initialize the network optimization problem.
Parameters: - time_horizon (int) – The time horizon \(T\) to optimize over.
- num_scenarios (int) – The number of scenarios for robust MPC.
- terminals (list of
-
class
dem.network.Group(devices, nets, terminals=[], name=None)¶ Bases:
dem.network.DeviceA single device composed of multiple devices and nets.
The Group device allows for creating new devices composed of existing base devices or other groups.
Parameters:
-
class
dem.network.Results(power=None, price=None)¶ Bases:
objectNetwork optimization results.
-
summary()¶ Summary of results.
Return type: str
-
plot()¶ Plot results.
-
-
exception
dem.network.OptimizationError¶ Bases:
exceptions.ExceptionError due to infeasibility or numerical problems during optimziation.
-
dem.network.run_mpc(device, time_steps, predict, execute, **kwargs)¶ Execute model predictive control.
This method executes the model predictive control loop, roughly:
for t in time_steps: predict(t) device.problem.solve() execute(t)
It is the responsibility of the provided predict and execute functions to update the device models with the desired predictions and execute the actions as appropriate.
Parameters: - device (
Device) – Device (or network of devices) to optimize - time_steps (sequence) – Time steps to optimize over
- predict (single argument function) – Prediction step
- execute (single argument function) – Execution step
Returns: Model predictive control results
Return type: Raise: - device (