source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/opt/yalmip/dev/impliestest.m @ 37

Last change on this file since 37 was 37, checked in by (none), 14 years ago

Added original make3d

File size: 2.2 KB
Line 
1
2A1 = randn(8,2);
3b1 = rand(8,1)*2-A1*[3;3];
4A2 = randn(8,2);
5b2 = rand(8,1)*2-A2*[-3;3];
6A3 = randn(8,2);
7b3 = rand(8,1)*2-A3*[3;-3];
8A4 = randn(8,2);
9b4 = rand(8,1)*2-A4*[-3;-3];
10
11plot(polytope(A1,b1),polytope(A2,b2),polytope(A3,b3),polytope(A4,b4))
12
13yalmip('clear')
14binvar inp1 inp2 inp3 inp4
15
16x = sdpvar(2,1);bounds(x,-100,100)
17y = sdpvar(1);  bounds(y,-100,100);
18
19F = set([]);
20F = F + set(iff(inp1,A1*x < b1));
21F = F + set(iff(inp2,A2*x < b2));
22F = F + set(iff(inp3,A3*x < b3));
23F = F + set(iff(inp4,A4*x < b4))
24F = F + set(iff(inp4,y==pi));
25F = F + set(inp1 | inp2 | inp3 | inp4);
26%F = F + set(inp1 + inp2 + inp3 + inp4 == 1);
27F=F+set(x==[-3;-4])
28
29solvesdp(F,x(2))
30
31F = set([]);
32F = F + set(inp1 == (A1*x < b1));
33F = F + set(inp2 == (A2*x < b2));
34F = F + set(inp3 == (A3*x < b3));
35F = F + set(inp4 == (A4*x < b4))
36F = F + set(inp2 == (y==pi));
37F = F + set(inp1 | inp2 | inp3 | inp4);
38solvesdp(F,x(2))
39
40
41binvar inp1 inp2 inp3 inp4
42
43x = sdpvar(2,1);
44
45F = set([]);
46F = F + set(iff(A1*x < b1,inp1));
47F = F + set(iff(A2*x < b2,inp2));
48F = F + set(iff(A3*x < b3,inp3));
49F = F + set(iff(A4*x < b4,inp4))
50
51F = F + set(inp1 | inp2 | inp3 | inp4);
52
53
54solvesdp(F,x(2))
55
56
57
58x = sdpvar(2,1);bounds(x,-1000,1000)
59F = set( (A1*x < b1) | (A2*x < b2) | (A3*x < b3) | (A4*x < b4));
60solvesdp(F,x(2));
61
62
63clear all
64pwa_di
65yalmip('clear')
66N=3;
67for i=1:N
68    x{i} = sdpvar(2,1);bounds(x{i},-[5;5],[5;5]);
69    u{i} = sdpvar(1,1);bounds(u{i},-1,1);
70    y{i} = sdpvar(2,1);bounds(y{i},-[5;5],[5;5]);
71end
72delta = binvar(N,4);
73
74F = set(x{1} == [0.1;0.11]);
75
76for i = 1:N
77    F = F + set(sysStruct.umin < u{i} < sysStruct.umax);
78    F = F + set(sysStruct.ymin < y{i} < sysStruct.ymax);
79   
80    for j = 1:4
81        F = F + set(iff(sysStruct.guardX{j}*x{i} < sysStruct.guardC{j},delta(i,j)));
82        F = F + set(iff(delta(i,j),y{i} == [sysStruct.C{j} sysStruct.D{j} sysStruct.g{j}]*[x{i};u{i};1]));
83    end
84end
85for i = 1:N-1
86    for j = 1:4
87        F = F + set(iff(delta(i,j),x{i+1} == [sysStruct.A{j} sysStruct.B{j} sysStruct.f{j}]*[x{i};u{i};1]));
88    end
89end
90
91tu = sdpvar(N,1)
92ty = sdpvar(N,1)
93tx = sdpvar(N,1)
94for i = 1:N
95    F = F + set(-tu(i) < u{i} < tu(i))+set(-ty(i) < y{i} < ty(i))+set(-tx(i) < 8*(x{i}-0*[0.1;0.11]) < tx(i));
96end
97F=F+set(sum(delta,2)==1);
98solvesdp(F,sum(2*tu)+sum(ty(1:end))+sum(tx(1:end)))
99
100
101
102
103
Note: See TracBrowser for help on using the repository browser.