Demostration of problem formulation using additional properties.
mpt_demo_lti5
lti = LTISystem('A', [1 1; 0 1], 'B', [1; 0.5]);Define the MPC controller
horizon = 5;
ctrl = MPCController(lti, horizon);Define quadratic penalties
ctrl.model.x.penalty = QuadFunction(eye(2));
ctrl.model.u.penalty = QuadFunction(1);
onl_ctrl.model.x.terminalPenalty = QuadFunction(10*eye(2));Add a terminal set constraint (see help SystemSignal/filter_terminalSet)
ctrl.model.x.with('terminalSet');
ctrl.model.x.terminalSet = Polyhedron('lb', [-1; -1], 'ub', [1; 1]);Add an LQR terminal penalty (see help SystemSignal/filter_terminalPenalty)
lqr_penalty = ctrl.model.LQRPenalty();
ctrl.model.x.with('terminalPenalty');
ctrl.model.x.terminalPenalty = lqr_penalty;Add a move-blocking constraint (the last 3 moves are to be constant)
ctrl.model.u.with('block');
ctrl.model.u.block.from = ctrl.N-2;
ctrl.model.u.block.to = ctrl.N;Obtain the optimal control input
x0 = [-4; 0];
[Uonl, feasible] = ctrl.evaluate(x0)
Uonl = 2.07136913674103 feasible = 1We can also ask for full open-loop predictions:
[~, ~, openloop] = ctrl.evaluate(x0)
openloop = cost: 28.9534609997889 U: [2.07136913674103 0.00571336432319767 -0.503441481063561 -0.503441481063562 -0.503441481063562] X: [2x6 double] Y: [0x5 double]Plot the open-loop predictions
ctrl.model.plot
◀ | mpt_demo_sets2 | mpt_demo_opt1 | ▶ |
© 2003-2013 Michal Kvasnica: STU Bratislava, michal.kvasnica@stuba.sk