Demonstration for modeling PWA systems
mpt_demo_pwa1
B = [0; 1]; C = [1 0]; D = 0;First dynamics:
alpha = -pi/3;
A1 = 0.8*[cos(alpha) -sin(alpha); sin(alpha) cos(alpha)];
dyn1 = LTISystem('A', A1, 'B', B, 'C', C, 'D', D);We need to tell that dynamics 1 should be active if
dyn1.setDomain('x', Polyhedron([1 0], 1));Second dynamics:
alpha = pi/3;
A2 = 0.8*[cos(alpha) -sin(alpha); sin(alpha) cos(alpha)];
dyn2 = LTISystem('A', A2, 'B', B, 'C', C, 'D', D);Region of validity of the dynamics (
dyn2.setDomain('x', Polyhedron([-1 0], 0));Create the PWA description using an array of LTI systems:
pwa = PWASystem([dyn1 dyn2]);
State/input/output constraints not imported, set them manually afterwards.Optionally we can set constraints:
pwa.x.min = [-10; -10];
pwa.x.max = [10; 10];
pwa.y.min = -10;
pwa.y.max = 10;
pwa.u.min = -1;
pwa.u.max = 1;Define an on-line MPC controller for such a system
horizon = 2;
onl_ctrl = MPCController(pwa, horizon);Set one-norm penalties used in the cost function:
onl_ctrl.model.x.penalty = OneNormFunction(10*eye(2));
onl_ctrl.model.u.penalty = OneNormFunction(1);Construct the explicit solution
exp_ctrl = onl_ctrl.toExplicit();
mpt_plcp: 6 regions mpt_plcp: 7 regions mpt_plcp: 6 regions mpt_plcp: 13 regions -> Generated 4 partitions.Obtain the closed-loop optimizers for a particular initial condition
x0 = [-4; 0];
Uonl = onl_ctrl.evaluate(x0)
Uonl = -1
Uexp = exp_ctrl.evaluate(x0)
Uexp = -1
◀ | mpt_demo_sets1 | mpt_demo_lti3 | ▶ |
© 2003-2013 Michal Kvasnica: STU Bratislava, michal.kvasnica@stuba.sk