Rev | Line | |
---|
[37] | 1 | |
---|
| 2 | % MPC setting |
---|
| 3 | N =10; |
---|
| 4 | |
---|
| 5 | % Create numerics for a discretized double integrator |
---|
| 6 | A = [2 -1;1 0]; |
---|
| 7 | B = 0.1*[1;0]; |
---|
| 8 | C = [0.5 0.5]; |
---|
| 9 | |
---|
| 10 | [H,S] = create_CHS(A,B,C,N) |
---|
| 11 | |
---|
| 12 | % Initial state |
---|
| 13 | x = [2;0]; |
---|
| 14 | |
---|
| 15 | % Define free variables |
---|
| 16 | t = sdpvar(1,1); |
---|
| 17 | U = [intvar(10,1)] |
---|
| 18 | |
---|
| 19 | % Define the prediction vector |
---|
| 20 | Y = H*x+S*U; |
---|
| 21 | |
---|
| 22 | % Control constraints (we add a tag for later) |
---|
| 23 | control_bound = 10; |
---|
| 24 | F = lmi('U<control_bound','Upper bound'); |
---|
| 25 | F = F+lmi('U>-control_bound','Lower bound') ; |
---|
| 26 | % Terminal constraint |
---|
| 27 | F = F+lmi('Y(N)>-1'); |
---|
| 28 | F = F+lmi('Y(N)<1'); |
---|
| 29 | t = sdpvar(2*N,1); |
---|
| 30 | %F = lmi([Y;U]<t) + lmi(t>-[Y;U]); |
---|
| 31 | |
---|
| 32 | solvesdp(F,Y'*Y+U'*U,sdpsettings('verbose',0,'bnb.solver','sedumi')) |
---|
Note: See
TracBrowser
for help on using the repository browser.