Model Predictive Control Toolbox™ Previous page   Next Page 
mpcmove
 Provide feedback about this page

Compute MPC control action

Syntax

Description

u=mpcmove(MPCobj,x,ym,r,v) computes the current input move u(k), given the current estimated extended state x(k), the vector of measured outputs ym(k), the reference vector r(k), and the measured disturbance vector v(k), by solving the quadratic programming problem based on the parameters contained in the MPC controller MPCobj.

x is an mpcstate object. It is updated by mpcmove through the internal state observer based on the extended prediction model (see getestim for details). A default initial state x for the first call at time k=0 can be simply defined as:

[u,Info]=mpcmove(MPCobj,x,ym,r,v) also returns the structure Info containing details about the optimal control calculations. Info has the following fields.

Field Name
Description
Uopt
Optimal input trajectory over the prediction horizon, returned as a p-by-nu dimensional array.
Yopt
Optimal output sequence over the prediction horizon, returned as a p-by-ny dimensional array.
Xopt
Optimal state sequence over the prediction horizon, returned as a p-by-nx dimensional array, where nx=total number of states of the extended state vector.
Topt
Prediction time vector (0:p-1)'.
Slack
Value of the ECR slack variable epsilon at optimum.
Iterations
Number of iterations needed by the QP solver.
QPCode
Exit code of the QP solver.

To plot the optimal input trajectory, type:

The optimal output and state trajectories can be plotted similarly. The input, output, and state sequences Uopt, Yopt, Xopt, Topt correspond to the predicted open-loop optimal control trajectories solving the optimization problem described in Optimization Problem. The optimal trajectories might also help understand the closed-loop behavior. For instance, constraints that are active in the open-loop optimal trajectory only at late steps of the prediction horizon might not be active at all in the closed-loop MPC trajectories. The sequence of optimal manipulated variable increments can be retrieved from MPCobj.MPCData.MPCstruct.optimalseq.

QPCode returns either 'feasible', 'infeasible' or 'unreliable' (the latter occurs when the QP solver terminates because the maximum number of iterations MPCobj.Optimizer.MaxIter is exceeded; see qpdantz). When QPCode='infeasible', then u is obtained by shifting the previous optimal sequence of manipulated variable rates (stored in MPCobj.MPCData.MPCstruct.optimalseq inside the MPC object MPCobj), and summing the first entry of this sequence to the previous vector of manipulated moves. You may set up different backup strategies for handling infeasible situations by discarding u and replacing it with a different emergency decision-variable vector.

r/v can be either a sample (no future reference/disturbance known in advance) or a sequence of samples (when a preview / look-ahead / anticipative effect is desired). In the latter case, they must be an array with as many rows as p and as many columns as the number of outputs/measured disturbances, respectively. If the number of rows is smaller than p, the last sample is extended constantly over the horizon, to obtain the correct size.

The default for y and r is MPCobj.Model.Nominal.Y. The default for v is obtained from MPCobj.Model.Nominal.U. The default for x is mpcstate(MPCobj,MPCobj.Model.Nominal.X,0,0,U0) where U0 are the entries from MPCobj.Model.Nominal.U corresponding to manipulated variables.

To bypass the MPC Controller block's internal estimator and use your own state observer to update the MPC state yourself, you can for instance use the syntax:

xp=x.plant; xd=x.dist; xn=x.noise;    % Save current state
u=mpcmove(MPCobj,x,ym,r,v);           % x will be updated
% Now call to your state update function:
[xp,xd,xn]=my_estimator(xp,xd,xn,ym); % States get updated
x.plant=xp;x.dist=xd;x.noise=xn;

Examples

Model predictive control of a multi-input single-output system (see the demo MISO.M). The system has three inputs (one manipulated variable, one measured disturbance, one unmeasured disturbance) and one output.

See Also

mpc, mpcstate, sim, setestim, getestim


 Provide feedback about this page 

Previous page mpchelp mpcprops Next page

 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS