Main Content

ss

Convert unconstrained MPC controller to state-space linear system form

Description

Use the Model Predictive Control Toolbox™ ss function to convert an unconstrained MPC controller to transfer function form (see mpc for background). The returned controller is equivalent to the original MPC controller MPCobj when no constraints are active. You can then use Control System Toolbox™ software for sensitivity analysis and other diagnostic calculations.

To create or convert a generic LTI dynamical system to state space form, see ss and Dynamic System Models.

example

kss = ss(MPCobj) returns the linear discrete-time dynamic controller kss, in state-space form. kss is equivalent to the MPC controller MPCobj when no constraint is active.

kssFull = ss(MPCobj,signals) returns the linear discrete-time dynamic controller kss, in full state-space form, and allows you to specify the signals that you want to include as inputs for kssFull.

kssFullPv = ss(MPCobj,signals,refPreview,mdPreview) specifies whether the returned controller has preview action, that is if it uses the whole reference and measured disturbance sequences as input signals.

[kss,ut] = ss(MPCobj) also returns the input target values for the full form of the controller.

Examples

collapse all

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.

Convert 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).

Restore mpcverbosity.

mpcverbosity(old_status);

Input Arguments

collapse all

Model predictive controller, specified as an MPC controller object. To create an MPC controller, use mpc.

Specify signals as a character vector or string with any combination that contains one or more of the following characters:

  • '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:

kss = ss(MPCobj,'rv');

Example: 'r'

If this flag is 'on', then the input matrices of the returned controller have a larger size to multiply the whole reference sequence.

Example: 'on'

If this flag is 'on', then the input matrices of the returned controller have a larger size to multiply the whole disturbance sequence.

Example: 'on'

Output Arguments

collapse all

The discrete-time state space form of the unconstrained MPC controller has the following structure:

x(k + 1) = Ax(k) + Bym(k)

u(k) = Cx(k) + Dym(k)

where A, B, C, and D are the matrices forming a state space realization of the controller kss, ym is the vector of measured outputs of the plant, and u is the vector of manipulated variables. The sampling time of controller kss 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).

Note

Only the following fields of MPCobj are used when computing the state-space model: Model, PredictionHorizon, ControlHorizon, Ts, Weights.

The full discrete-time state space form of the unconstrained 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:

  • A, B, C, and D are the matrices forming a state space realization of the controller from measured plant output to manipulated variables

  • 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.

In the general case of nonzero offsets, ym, 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 and 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.

If the flag refPreview = '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 mdPreview='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)] +...

ut is returned as a vector of doubles, [utarget(k); utarget(k+1); ... utarget(k+h)].

Here:

  • 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

Introduced before R2006a