toYALMIP

Purpose

Converts an MPC problem into YALMIP's constraints and objective

Syntax

yalmipdata = controller.toYALMIP()

Description

This function convers an MPC optimization problem into YALMIP. The output structure contains following fields: This method is MPT3 replacement of MPT2's ownmpc mechanism. In short, toYALMIP allows to modify the MPC problem by adding new constraints and/or by modifying the objective function.

Output Arguments

yalmipdata

Structure containing constraints, objective, and variables of the MPC problem.

Class: struct

Example(s)

Example 1

Create a 1D LTI system ../../../../../fig/mpt/modules/ui/@MPCController/toyalmip1.png.
sys = LTISystem('A', 0.9, 'B', 1);
Define an MPC controller.
ctrl = MPCController(sys);
Specify constraints, penalties, and the prediction horizon.
		ctrl.model.x.min = -5; ctrl.model.x.max = 5;
		ctrl.model.u.min = -5; ctrl.model.u.max = 5;
		ctrl.model.x.penalty = QuadFunction(1);
		ctrl.model.u.penalty = QuadFunction(1);
		ctrl.N = 3;
	
Obtain the optimal sequence of inputs over the whole
    prediction horizon for the initial condition x0=3.
[~, ~, openloop] = ctrl.evaluate(3); openloop.U
ans =

         -1.57733887733888        -0.505197505197505      5.55111512312578e-17

Convert the problem to YALMIP and add custom state constraints on the first two predicted inputs via YALMIP.
		Y = ctrl.toYALMIP()
		Y.constraints = Y.constraints + [ -0.5 <= Y.variables.u(:, 1) <= 0.5];
		Y.constraints = Y.constraints + [ -0.8 <= Y.variables.u(:, 2) <= 0.8];
		ctrl.fromYALMIP(Y);
		x0 = 3;
		[~, ~, openloop] = ctrl.evaluate(x0); openloop.U
	
Y = 

    constraints: [4 lmi]
      objective: [1x1 sdpvar]
      variables: [1x1 struct]
       internal: [1x1 struct]


ans =

                      -0.5                      -0.8       -6.418622835482e-17

Notice that the updated controller respects constraints added via YALMIP.

See Also

fromyalmip


© 2003-2013 Michal Kvasnica: STU Bratislava, michal.kvasnica@stuba.sk