Rev | Line | |
---|
[37] | 1 | function algebraicmpc |
---|
| 2 | |
---|
| 3 | % Test bilinearization functionality |
---|
| 4 | N = 2; |
---|
| 5 | x = sdpvar(2*ones(1,N),ones(1,N)); |
---|
| 6 | u = sdpvar( ones(1,N),ones(1,N)); |
---|
| 7 | |
---|
| 8 | F = set(-5 < [x{:}] <5) + set(-10 < [u{:}] < 10); |
---|
| 9 | obj = 0; |
---|
| 10 | Q = eye(2);R = 1/10; |
---|
| 11 | h = 0.05; |
---|
| 12 | |
---|
| 13 | A = [1 h;-h 1-2*0.3*h]; |
---|
| 14 | B = [0;h]; |
---|
| 15 | dd = binvar(2,N-1); |
---|
| 16 | bounds([x{:}],-5,5); |
---|
| 17 | bounds([u{:}],-10,10); |
---|
| 18 | for i = 1:N-1 |
---|
| 19 | obj = obj + x{i+1}'*Q*x{i+1} + u{i}'*R*u{i}; |
---|
| 20 | F = F + set(x{i+1} == A*x{i} + B*u{i} + [0;-h*x{i}(1)^3]); |
---|
| 21 | end |
---|
| 22 | |
---|
| 23 | xk = [2.5;1]; |
---|
| 24 | uk = []; |
---|
| 25 | cost = 0; |
---|
| 26 | ops =sdpsettings('solver','bmibnb','bmibnb.lpreduce',0,'bmibnb.maxiter',10,'debug',1,'bmibnb.upper','fmincon','bmibnb.root',1); |
---|
| 27 | |
---|
| 28 | obj = obj + ([x{2}]'*[x{2}])^2; |
---|
| 29 | sol = solvesdp(F+set(-10 < x{1} < 10) + set(x{1} == xk(:,end)),obj,ops) |
---|
| 30 | |
---|
| 31 | mbg_asserttolequal(sol.problem,0); |
---|
| 32 | mbg_asserttolequal(double(obj), 48.8272, 1e-3); |
---|
Note: See
TracBrowser
for help on using the repository browser.