Main Content

setEstimator

Modify a model predictive controller’s state estimator

Description

setEstimator(mpcobj,L,M) sets the gain matrices used for estimation of the states of an MPC controller. For more information, see State Estimator Equations.

example

setEstimator(mpcobj,'default') restores the gain matrices L and M to their default values. The default values are the optimal static gains calculated using kalmd for the plant, disturbance, and measurement noise models specified in mpcobj.

setEstimator(mpcobj,'custom') specifies that controller state estimation will be performed by a user-supplied procedure. This option suppresses calculation of L and M. When the controller is operating in this way, the procedure must supply the state estimate x[n|n] to the controller at the beginning of each control interval.

Examples

collapse all

Design an estimator using pole placement, assuming the linear system AM=L is solvable.

Create a plant model.

G = tf({1,1,1},{[1 .5 1],[1 1],[.7 .5 1]});

To improve the clarity of this example, call mpcverbosity to suppress messages related to working with an MPC controller.

old_status = mpcverbosity('off');

Create a model predictive controller for the plant. Specify the controller sample time as 0.2 seconds.

mpcobj = mpc(G, 0.2);

Obtain the default state estimator gain.

[~,M,A1,Cm1] = getEstimator(mpcobj);

Calculate the default observer poles.

e = eig(A1-A1*M*Cm1);
abs(e)
ans = 6×1

    0.9402
    0.9402
    0.8816
    0.8816
    0.7430
    0.9020

Specify faster observer poles.

new_poles = [.8 .75 .7 .85 .6 .81];

Compute a state-gain matrix that places the observer poles at new_poles.

L = place(A1',Cm1',new_poles)';

place returns the controller-gain matrix, whereas you want to compute the observer-gain matrix. Using the principle of duality, which relates controllability to observability, you specify the transpose of A1 and Cm1 as the inputs to place. This function call yields the observer gain transpose.

Obtain the estimator gain from the state-gain matrix.

M = A1\L;

Specify M as the estimator for mpcobj.

setEstimator(mpcobj,L,M)

The pair, (A1,Cm1), describing the overall state-space realization of the combination of plant and disturbance models must be observable for the state estimation design to succeed. Observability is checked in Model Predictive Control Toolbox™ software at two levels: (1) observability of the plant model is checked at construction of the MPC object, provided that the model of the plant is given in state-space form; (2) observability of the overall extended model is checked at initialization of the MPC object, after all models have been converted to discrete-time, delay-free, state-space form and combined together.

Restore mpcverbosity.

mpcverbosity(old_status);

Input Arguments

collapse all

MPC controller, specified as an MPC controller object. Use the mpc command to create the MPC controller.

Kalman gain matrix for the time update, specified as a matrix. The dimensions of L are nx-by-nym, where nx is the total number of controller states, and nym is the number of measured outputs.

If L is empty, it defaults to L = A*M, where A is the state-transition matrix.

Kalman gain matrix for the measurement update, specified as a matrix. The dimensions of L are nx-by-nym, where nx is the total number of controller states, and nym is the number of measured outputs.

If M is omitted or empty, it defaults to a zero matrix, and the state estimator becomes a Luenberger observer.

Algorithms

collapse all

State Estimator Equations

In general, the controller states are unmeasured and must be estimated. By default, the controller uses a steady-state Kalman filter that derives from the state observer. For more information, see Controller State Estimation.

At the beginning of the kth control interval, the controller state is estimated with the following steps:

  1. Obtain the following data:

    • xc(k|k–1) — Controller state estimate from previous control interval, k–1

    • uact(k–1) — Manipulated variable (MV) actually used in the plant from k–1 to k (assumed constant)

    • uopt(k–1) — Optimal MV recommended by MPC and assumed to be used in the plant from k–1 to k

    • v(k) — Current measured disturbances

    • ym(k) — Current measured plant outputs

    • Bu, Bv — Columns of observer parameter B corresponding to u(k) and v(k) inputs

    • Cm — Rows of observer parameter C corresponding to measured plant outputs

    • Dmv — Rows and columns of observer parameter D corresponding to measured plant outputs and measured disturbance inputs

    • L, M — Constant Kalman gain matrices

    Plant input and output signals are scaled to be dimensionless prior to use in calculations.

  2. Revise xc(k|k–1) when uact(k–1) and uopt(k–1) are different.

    xcrev(k|k1)=xc(k|k1)+Bu[uact(k1)uopt(k1)]

  3. Compute the innovation.

    e(k)=ym(k)[Cmxcrev(k|k1)+Dmvv(k)]

  4. Update the controller state estimate to account for the latest measurements.

    xc(k|k)=xcrev(k|k1)+Me(k)

    Then, the software uses the current state estimate xc(k|k) to solve the quadratic program at interval k. The solution is uopt(k), the MPC-recommended manipulated-variable value to be used between control intervals k and k+1.

    Finally, the software prepares for the next control interval assuming that the unknown inputs, wid(k), wod(k), and wn(k) assume their mean value (zero) between times k and k+1. The software predicts the impact of the known inputs and the innovation as follows:

    xc(k+1|k)=Axcrev(k|k1)+Buuopt(k)+Bvv(k)+Le(k)

Version History

Introduced in R2014b