Converts an MPC problem into YALMIP's constraints and objective
yalmipdata = controller.toYALMIP()
yalmipdata |
Structure containing constraints, objective, and variables
of the MPC problem. Class: struct |
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-17Convert 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-17Notice that the updated controller respects constraints added via YALMIP.
◀ | fromyalmip | mpt | ▶ |
© 2003-2013 Michal Kvasnica: STU Bratislava, michal.kvasnica@stuba.sk