Main Content

Compare Multiple Controller Responses Using MPC Designer

This example shows how to compare multiple controller responses usingMPC Designer. In particular, controllers with different output constraint configurations are compared.

Define Plant Model

Create a state-space model of your plant, and specify the MPC signal types.

A = [-0.0285 -0.0014; -0.0371 -0.1476]; B = [-0.0850 0.0238; 0.0802 0.4462]; C = [0 1; 1 0]; D = zeros(2,2); plant = ss(A,B,C,D); plant = setmpcsignals(plant,'MV',1,'UD',2,'MO',1,'UO',2);

OpenMPC Designer, and import the plant model.

mpcDesigner(plant)

The app adds the specified plant to theData Browseralong with a default controller,mpc1, and a default simulation scenario,scenario1.

Define Simulation Scenario

Configure a disturbance rejection simulation scenario.

InMPC Designer, on theMPC Designertab, clickEdit Scenario>scenario1.

In the Simulation Scenario dialog box, specify aSimulation durationof 40 seconds.

In the参考信号stable, in theSignaldrop-down lists, selectConstantto hold the setpoints of both outputs at their nominal values.

In theUnmeasured Disturbancestable, in theSignaldrop-down list, selectStep. Use the defaultTimeandStepvalues.

This scenario simulates a unit step change in the unmeasured input disturbance at a time of 1 second.

ClickOK.

The app runs the updated simulation scenario and updates the controller response plots. In theOutput Responseplots, the default controller returns the measured output,MO1, to its nominal value, however the control action causes an increase in the unmeasured output,UO1.

Create Controller with Hard Output Constraints

Suppose that the control specifications indicate that such an increase in the unmeasured disturbance is undesirable. To limit the effect of the unmeasured disturbance, create a controller with a hard output constraint.

Note

In practice, using hard output constraints is not recommended. Such constraints can create an infeasible optimization problem when the output variable moves outside of the constraint bounds due to a disturbance.

In theData Browser, in theControllerssection, right-clickmpc1, and selectCopy.

The app creates a copy of the default controller and adds it to theData Browser.

Double-click each controller and rename them as follows.

Right-click thempcHardcontroller, and selectTune (make current). The app adds thempcHardcontroller response to theInput ResponseandOutput Responseplots.

On theTuningtab, in theControllersection,mpcHardis selected as the currentMPC Controllerbeing tuned.

In theDesignsection, clickConstraints.

In the Constraints dialog box, in theOutput Constraintssection, in theMaxcolumn, specify a maximum output constraint of3for the unmeasured output (UO).

By default, all output constraints are soft, that is the controller can allow violations of the constraint when computing optimal control moves.

To make the unmeasured output constraint hard, clickConstraint Softening Settings, and enter aMaxECRvalue of0UO。这个设置严格限制的地方the controller output that cannot be violated.

ClickOK.

The response plots update to reflect the newmpcHardconfiguration. In theOutput Responseplot, in theUO1plot, thempcHardresponse is limited to a maximum of3. As a trade-off, the controller cannot return theMO1response to its nominal value.

Tip

If the plot legends are blocking the response signals, you can drag the legends to different locations.

Create Controller with Soft Output Constraints

Suppose the deviation ofMO1from its nominal value is too large. You can soften the output constraint for a compromise between the two control objectives:MO1output tracking andUO1constraint satisfaction.

On theTuningtab, in theAnalysissection, clickStore Controllerto save a copy ofmpcHardin theData Browser.

In theData Browser, in theControllerssection, renamempcHard_CopytompcSoft.

On theTuningtab, in theControllersection, in theMPC Controllerdrop-down list, selectmpcSoftas the current controller.

The app adds thempcSoftcontroller response to theInput ResponseandOutput Responseplots.

In theDesignsection, clickConstraints.

In the Constraints dialog box, in theOutput Constraintssection, enter aMaxECRvalue of100for the UO to soften the constraint.

ClickOK.

The response plots update to reflect the newmpcSoftconfiguration. In theOutput Responseplot,mpcSoftshows a compromise between the previous controller responses.

Remove Default Controller Response Plot

To compare the two constrained controllers only, you can remove the default unconstrained controller from the input and output response plots.

On theMPC Designertab, in theResultsection, clickCompare Controllers>mpcNone.

The app removes thempcNoneresponses from theInput ResponseandOutput Responseplots.

You can toggle the display of any controller in theData Browserexcept for controller currently being tuned. UnderCompare Controllers, the controllers with displayed responses are indicated with check marks.

See Also

Related Topics