Model Predictive Control Toolbox    
cmpc

Simulates closed-loop systems with hard bounds on manipulated variables and/or outputs using models in the MPC step format. Solves the MPC optimization problem by quadratic programming.

Syntax

[yp,u,ym] = cmpc(plant,model,ywt,uwt,M,P,tend,...

        r,ulim,ylim,tfilter,dplant,dmodel,dstep)

Description

cmpc simulates the performance of the type of system shown in the above diagram when there are bounds on the manipulated variables and/or outputs. Measurement noise can be simulated by treating it as an unmeasured disturbance.

The required input variables are as follows:

plant
Is a model in the MPC step format that represents the plant.

model
Is a model in the MPC step format that is to be used for state estimation in the controller. In general, it can be different from plant if you want to simulate the effect of plant/controller model mismatch.

ywt
Is a matrix of weights that will be applied to the setpoint tracking errors. If ywt=[ ], the default is equal (unity) weighting of all out- puts over the entire prediction horizon. If ywt[ ], it must have ny columns, where ny is the number of outputs. All weights must be 0.

You may vary the weights at each step in the prediction horizon by including up to P rows in ywt. Then the first row of ny values applies to the tracking errors in the first step in the prediction horizon, the next row applies to the next step, etc. See mpccon for details on the form of the optimization objective function.

If you supply only nrow rows, where 1 nrow < P, cmpc will use the last row to fill in any remaining steps. Thus if you want the weighting to be the same for all P steps, you need only specify a single row.

uwt
Same format as ywt, except that uwt applies to the changes in the manipulated variables. If you use uwt = [ ], the default is zero weighting. If uwt [ ], it must have nu columns, where nu is the number of manipulated variables.

M
There are two ways to specify this variable:

If it is a scalar, cmpc interprets it as the input horizon (number of moves) as in DMC.

If it is a row vector containing nb elements, each element of the vector indicates the number of steps over which u = 0 during the optimization and cmpc interprets it as a set of nb blocking factors. There may be 1 nb P blocking factors, and their sum must be P

If you set M=[ ] and P Inf, the default is M=P, which is equivalent to M=ones(1,P). The default value for M is 1 if P=Inf.

P
    The number of sampling periods in the prediction horizon. If P=Inf, the prediction horizon is infinite.

tend
Is the desired duration of the simulation (in time units).

r
Is a setpoint matrix consisting of N rows and ny columns, where ny is the number of output variables, y:


where ri(k) is the setpoint for output j at time t = kT, and T is the sampling period (as specified in the step format of plant and model). If tend > NT, the setpoints vary for the first N periods in the simulation, as specified by r, and are then held constant at the values given in the last row of r for the remainder of the simulation.

In many simulations one wants the setpoints to be constant for the entire time, in which case r need only contain a single row of ny values.

    If you set r=[ ], the default is a row of ny zeros.

The following input variables are optional. In general, setting one of them equal to an empty matrix causes cmpc to use the default value, which is given in the description.

ulim

Is a matrix giving the limits on the manipulated variables. Its format is as follows:

    

Note that it contains three matrices of N rows. In this case, the limits on N are 1 N nb, where nb is the number of times the manipulated variables are to change over the input horizon. If you supply fewer than nb rows, the last row is repeated automatically.

    The first matrix specifies the lower bounds on the nu manipulated variables. For example, umin,j(2) is the lower bound for manipulated variable j for the second move of the manipulated variables (where the first move is at the start of the prediction horizon). If umin,j(k) = -inf, manipulated variable j will have no lower bound for that move.

    The second matrix gives the upper bounds on the manipulated variables. If umax,j(k) = inf, manipulated variable j will have no upper bound for that move.

    The lower and upper bounds may be either positive or negative (or zero) as long as umin,j(k) umax,j(k).

    The third matrix gives the limits on the rate of change of the manipulated variables. In other words, cmpc will force|uj(k) - uj(k - 1)| umax,j(k). The limits on the rate of change must be nonnegative and finite. If you want it to be unbounded, set the bound to a large number (but not too large -- a value of 106 should work well in most cases).

    The default is umin = -inf, umax = inf and umax = 106

ylim
Same idea as for ulim, but for the lower and upper bounds of the outputs. The first row applies to the first point in the prediction horizon. The default is ymin = -inf, and ymax = inf.

tfilter
Is a matrix of time constants for the noise filter and the unmeasured disturbances entering at the plant output. The first row of ny elements gives the noise filter time constants and the second row of ny elements gives the time constants of the lags through which the unmeasured disturbance steps pass. If tfilter only contains one row, the unmeasured disturbances are assumed to be steps. If you set tfilter=[ ] or omit it, the default is no noise filtering and steplike unmeasured disturbances.

dplant
Is a model in MPC step format representing all the disturbances (measured and unmeasured) that affect plant in the above diagram. If dplant is provided, then input dstep is also required. For output step disturbances, set dplant=[ ]. The default is no disturbances.

dmodel
Is a model in MPC step format representing the measured disturbances. If dmodel is provided, then input dstep is also required. If there are no measured disturbances, set dmodel=[ ]. For output step disturbances, set dmodel=[ ]. If there are both measured and un- measured disturbances, set the columns of dmodel corresponding to the unmeasured disturbances to zero. The default is no measured disturbances.

dstep
Is a matrix of disturbances to the plant. For output step disturbances (dplant=[ ] and dmodel=[ ]), the format is the same as for r. For disturbances through step-response models (dplant only or both dplant and dmodel nonempty), the format is the same as for r, except that the number of columns is nd rather than ny. The default is a row of zeros.

Notes

The calculated outputs are as follows (all but yp are optional):

yp

Is a matrix containing M rows and ny columns, where M = max(fix(tend=T) + 1, 2). The first row will contain the initial condition, and row k - 1 will give the values of the plant outputs, y (see above diagram), at time t = kT.

u
Is a matrix containing the same number of rows as yp and nu columns. The time corresponding to each row is the same as for yp. The elements in each row are the values of the manipulated variables, u (see above diagram).

ym
Is a matrix of the same structure as yp, containing the values of the predicted output from the state estimator in the controller. These will, in general, differ from those in yp if modelplant and/or there are unmeasured disturbances. The prediction includes the effect of the most recent measurement, i.e., it is .

For unconstrained problems, cmpc and mpcsim should give the same results. The latter will be faster because it uses an analytical solution of the QP problem, whereas cmpc solves it by iteration.

Examples
Consider the linear system:


The following statements build the model and set up the controller in the same way as in the mpcsim example.

Here, however, we will demonstrate the effect of constraints. First we set a limit of 0.1 on the rate of change of u1 and a minimum of -0.15 for u2.

Note that u2 has a large (but finite) limit. It never comes into play.

We next apply a lower bound of zero to both outputs:

The following results show that no constraints are violated.

Restriction
Initial conditions of zero are used for all the variables. This simulates the condition where all variables represent a deviation from a steady-state initial condition.

Suggestion
Problems with many inequality constraints can be very time consuming. You can minimize the number of constraints by:

See Also
plotall, ploteach, mpccl, mpccon, mpcsim



autosc, scal, rescal cp2dp