01Overview
For the full problem definition, please see: Assignment.
The challenge is to design an MPC-based controller for maintaining the stability of an electricity grid that uses renewables for generation.
The system block diagram is given as the following:

The given state-space prediction model is:
Eq. 1 Eq. 202Explaining the Variables
-
- Represents the deviation of grid frequency from the synchronous frequency of , using a normalised unit.
-
- Represents the deviation from the nominal mechanical power output of the steam turbine, using a normalised unit.
-
- Represents the deviation from the governed mechanical power output of the governor, using a normalised unit.
-
- Represents the demand response, using a normalised unit. This is the value used to reduce the difference in load, ie, , and the physical means for doing this is through the transfer of money (paying users).
-
- Represents the deviation from nominal net power demand, using a normalised unit. This is the difference between the power demanded by consumers and the power generated by renewables.
03Tuning Parameters
There are a number of tuning parameters in the given problem, both within the controller and as part of the problem formulation. Within the controller, the and matrices serve as ways for the controller to 'prioritise' different states or inputs as part of the optimisation procedure, and changing the prediction horizion changes how 'far ahead' the controller optimises for. Similarly, we have the ability to tune the demand response parameter directly within the model.
04Unconstrained
First attempt at the unconstrained controller

Here we can see the unconstrained controller exerting control over the system. The controller itself can be validated as stabilising through checking the spectral radius, which returns hence the controller is stabilising.
Tuning Controller Variables
Eq. 3 Eq. 405Constrained
Constraint modelling requires translating the requirement into bounds on either the states or inputs . When developing an MPC controller, it is important to introduce constraints gradually, and tune the controller incrementally. This approach ensures that you can maintain the feasibility of a given controller as you tune , and .
We begin by introducing input constraints, defined as
Eq. 5We also have output constraints, defined as
Eq. 6We convert the input constraints into linear inequalities as follows:
Eq. 7And, we have only output constraints, meaning we create the following linear inequalitie:
Eq. 8Outcome
After editing the code further and making more adjustments to the matrices, the following output was achieved.

This was achieved with matrices and
Eq. 9 Eq. 1006Disturbance Rejection
Including disturbance enhances the realism both of the model and the controller. Disturbances are modelled via state space through the addition of an matrix and a vector. However, typically we can assume .
Eq. 11 Eq. 12 Eq. 13The disturbances have been modelled using Gaussian white noise, with and as a starting point. Using the same matrix configuration as above, we attain the following result. In the result, a price is associated with the control action. This will help when assessing the realism and cost effectiveness of any given control schema.

Now that we have modelled disturbances, we begin with the implementation of disturbance rejection.