Line | |
---|
1 | sdpvar x y z |
---|
2 | F = set(max(1,x)+max(y^2,z) < 3)+set(max(1,-min(x,y)) < 5)+set(norm([x;y],2) < z); |
---|
3 | sol = solvesdp(F,max(x,z)-min(y,z)-z); |
---|
4 | |
---|
5 | if ~(sol.problem == 0 & abs(double(max(x,z)-min(y,z)-z) - -sqrt(2))<1e-3) |
---|
6 | error('Failed') |
---|
7 | end |
---|
8 | |
---|
9 | sdpvar x y z |
---|
10 | F = set(max(1,x)+max(y^2,z) < 3)+set(max(1,min(x,y)) < 5)+set(norm([x;y],2) < z); |
---|
11 | sol = solvesdp(F,max(x,z)-min(y,z)-z); |
---|
12 | if sol.problem ~= 14 |
---|
13 | error('Failed') |
---|
14 | end |
---|
15 | |
---|
16 | randn('seed',456); |
---|
17 | rand('seed',456); |
---|
18 | A = randn(15,2); |
---|
19 | b = rand(15,1)*5; |
---|
20 | x = sdpvar(2,1); |
---|
21 | sol = solvesdp([],-geomean(b-A*x)); |
---|
22 | if ~(sol.problem == 0 & abs(double(-geomean(b-A*x)) - -2.7797)<1e-3) |
---|
23 | error('Failed') |
---|
24 | end |
---|
25 | |
---|
26 | randn('seed',456); |
---|
27 | rand('seed',456); |
---|
28 | A = randn(15,2); |
---|
29 | b = rand(15,1)*5; |
---|
30 | x = sdpvar(2,1); |
---|
31 | sol = solvesdp([],-geomean([b-A*x;min(x)])); |
---|
32 | if ~(sol.problem == 0 & abs(double(-geomean([b-A*x;min(x)])) - -2.4936)<1e-3) |
---|
33 | error('Failed') |
---|
34 | end |
---|
35 | |
---|
36 | n = 500; |
---|
37 | randn('seed',456); |
---|
38 | A = randn(2*n,n); |
---|
39 | b = randn(2*n,1); |
---|
40 | x=sdpvar(n,1); |
---|
41 | sol = solvesdp([],norm(A*x-b)); |
---|
42 | if ~(sol.problem == 0 & abs(double(norm(A*x-b)) - 24.126)<1e-3) |
---|
43 | error('Failed') |
---|
44 | end |
---|
45 | |
---|
46 | |
---|
47 | |
---|
48 | |
---|
Note: See
TracBrowser
for help on using the repository browser.