Convert unconstrained MPC controller to state-space linear system
sys = ss(MPCobj,signals)
sys = ss(MPCobj,signals,ref_preview,md_preview)
[sys,ut] = ss(MPCobj)
The ss command returns a linear controller in the state-space form. The controller is equivalent to the MPC controller MPCobj when the constraints are not active. The purpose is to use the linear equivalent control in Control System Toolbox™ software for sensitivity analysis and other linear analysis.
sys=ss(MPCobj) returns the linear discrete-time dynamic controller sys
x(k + 1) = Ax(k) + Bym(k)
u(k) = Cx(k) + Dym(k)
where ym is the vector of measured outputs of the plant, and u is the vector of manipulated variables. The sampling time of controller sys is MPCobj.Ts.
Note Vector x includes the states of the observer (plant+disturbance+noise model states) and the previous manipulated variable u(k-1).
sys = ss(MPCobj,signals) returns the linearized MPC controller in its full form and allows you to specify the signals that you want to include as inputs for sys.
The full form of the MPC controller has the following structure:
x(k + 1) = Ax(k) + Bym(k) + Brr(k) + Bvv(k) + Bututarget(k) + Boff
u(k) = Cx(k) + Dym(k) + Drr(k) + Dvv(k) + Dututarget(k) + Doff
Here, r is the vector of setpoints for both measured and unmeasured plant outputs, v is the vector of measured disturbances, utarget is the vector of preferred values for manipulated variables.
Specify signals as a single or multicharacter string constructed using any of the following:
'r' — Output references
'v' — Measured disturbances
'o' — Offset terms
't' — Input targets
For example, to obtain a controller that maps [ym; r; v] to u, use:
sys = ss(MPCobj,'rv');
In the general case of nonzero offsets, ym (as well as r, v, and utarget) must be interpreted as the difference between the vector and the corresponding offset. Offsets can be nonzero is MPCobj.Model.Nominal.Y or MPCobj.Model.Nominal.U are nonzero.
Vectors Boff, Doff are constant terms. They are nonzero if and only if MPCobj.Model.Nominal.DX is nonzero (continuous-time prediction models), or MPCobj.Model.Nominal.Dx-MPCobj.Model.Nominal.X is nonzero (discrete-time prediction models). In other words, when Nominal.X represents an equilibrium state, Boff, Doff are zero.
Only the following fields of MPCobj are used when computing the state-space model: Model, PredictionHorizon, ControlHorizon, Ts, Weights.
sys = ss(MPCobj,signals,ref_preview,md_preview) specifies if the MPC controller has preview actions on the reference and measured disturbance signals. If the flag ref_preview='on', then matrices Br and Dr multiply the whole reference sequence:
x(k + 1) = Ax(k) + Bym(k) + Br[r(k);r(k + 1);...;r(k + p – 1)] +...
u(k) = Cx(k) + Dym(k) + Dr[r(k);r(k + 1);...;r(k + p– 1)] +...
Similarly if the flag md_preview='on', then matrices Bv and Dv multiply the whole measured disturbance sequence:
x(k + 1) = Ax(k) +...+ Bv[v(k);v(k + 1);...;v(k + p)] +...
u(k) = Cx(k) +...+ Dv[v(k);v(k + 1);...;v(k + p)] +...
[sys,ut] = ss(MPCobj) additionally returns the input target values for the full form of the controller.
ut is returned as a vector of doubles, [utarget(k); utarget(k+1); ... utarget(k+h)].
h — Maximum length of previewed inputs, that is, h = max(length(MPCobj.ManipulatedVariables(:).Target)
utarget — Difference between the input target and corresponding input offsets, that is, MPCobj.ManipulatedVariables(:).Targets - MPCobj.Model.Nominal.U
To improve the clarity of the example, suppress messages about working with an MPC controller.
old_status = mpcverbosity('off');
Create the plant model.
G = rss(5,2,3); G.D = 0; G = setmpcsignals(G,'mv',1,'md',2,'ud',3,'mo',1,'uo',2);
Configure the MPC controller with nonzero nominal values, weights, and input targets.
C = mpc(G,0.1); C.Model.Nominal.U = [0.7 0.8 0]; C.Model.Nominal.Y = [0.5 0.6]; C.Model.Nominal.DX = rand(5,1); C.Weights.MV = 2; C.Weights.OV = [3 4]; C.MV.Target = [0.1 0.2 0.3];
C is an unconstrained MPC controller. Specifying C.Model.Nominal.DX as nonzero means that the nominal values are not at steady state. C.MV.Target specifies three preview steps.
Covert C to a state-space model.
sys = ss(C);
The output, sys, is a seventh-order SISO state-space model. The seven states include the five plant model states, one state from the default input disturbance model, and one state from the previous move, u(k-1).