source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/opt/yalmip/dev/tests-mbg/solvers/test_pennon_vibration.m @ 37

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

Added original make3d

File size: 3.4 KB
Line 
1function  test_pennon_vibration%(file, upper, rank, lambda_bar, resx, resy)
2
3draw = 1;
4
5if nargin < 6
6    draw = 0;
7end
8
9if nargin < 4
10    lambda_bar = 0.0001;
11end
12
13if nargin < 2
14    upper = 10;
15end   
16   
17if nargin < 3
18    rank = 0;
19end
20
21file = 'shape1';
22
23load (file);
24
25
26if upper > 0
27    bounds = 1;
28else
29    bounds = 0;
30end
31
32tic;
33
34compl = 5.0e-0;
35vol = nelem/3;
36
37% the variables
38u = sdpvar(nnod,1);
39if rank > 0
40    w = sdpvar(nnod,rank);
41end
42
43if bounds > 0
44    r = sdpvar(nelem,1);
45end
46
47alpha = sdpvar(1,1);
48
49lb = 1;
50BIUALL = [];
51NN = zeros(length(u));
52for ie=1:nelem %for all elements
53    len = Bdim(ie); %number of nonzeros in (Bi_1,...,Bi_nig)
54    nb = len/nig; %number of nonzeros in Bi ...   
55    SumBiuuBi = zeros(3,3);
56   
57    BIU = [];
58    for ig=1:nig
59        Bi = sparse(Brow(lb:lb+nb-1),Bcol(lb:lb+nb-1),Bval(lb:lb+nb-1),3,nnod);
60        Biu = Bi*u;
61        SumBiuuBi = SumBiuuBi + Biu*Biu';   
62     
63        if rank > 0
64            Biw = Bi*w;
65            SumBiuuBi = SumBiuuBi + Biw*Biw';   
66            %for ir=1:rank
67            %    ss = Bi*w(:,ir);
68            %    SumBiuuBi = SumBiuuBi + ss*ss';
69            %end
70        end
71        lb = lb + nb;
72     %   BIU = [ BIU Biu];
73    end
74 
75NN = NN | full(Bi)'*full(Bi);
76    %SumBiuuBi = BIU*BIU';
77    BuuB{ie} = 0.5*SumBiuuBi;
78end
79
80if rank > 0
81    %Compue global mass matrix
82    Mass = sparse(nnod,nnod);
83    lb = 1;
84    for ie = 1:nelem
85        len = Bdim(ie); %number of nonzeros in (Bi_1,...,Bi_nig)
86        nb = len/nig; %number of nonzeros in Bi ...   
87        elm=sparse(nnod,nnod);
88        for ig=1:nig
89            Bi = sparse(Brow(lb:lb+nb-1),Bcol(lb:lb+nb-1),Bval(lb:lb+nb-1),3,nnod);
90            elm = elm + Bi'*Bi; 
91            lb = lb + nb;
92        end
93        ss =  spones(diag(diag(elm)));
94        MM{ie} = .5*ss;
95    end
96end
97
98if rank > 0
99    % This is to prevent rank-deficient solutions
100    G = set(w(1,1)>=0);
101    for ir=2:rank
102    %    G = G+set(w(1,ir)<0);
103        G = G+set(w(1,ir)>=0);
104    end
105   
106    % Add matrix constraints
107    for ie=1:nelem
108        if bounds > 0
109            G = G + set(BuuB{ie}-(lambda_bar*(trace(w'*MM{ie}*w))+alpha+r(ie))*eye(3)<=0);
110        else
111            G = G + set(BuuB{ie}-(lambda_bar*(trace(w'*MM{ie}*w))+alpha)*eye(3)<=0);
112        end
113    end
114
115    %if rank > 1
116    %    G = G + set(w'*w-0.01*eye(rank)>=0);
117    %end
118   
119    if bounds > 0
120        for ie=1:nelem
121            G = G + set(r(ie)>=0);
122        end
123    end
124else
125    % Create 1-st constraint
126    if bounds > 0
127        G = set(BuuB{1}-(alpha+r(1))*eye(3)<=0);
128        % Add constraint 2 to #elements
129        for ie=2:nelem
130            G = G + set(BuuB{ie}-(alpha+r(ie))*eye(3)<=0);
131        end
132        for ie=1:nelem
133            G = G + set(r(ie)>=0);
134        end
135    else
136        G = set(BuuB{1}-alpha*eye(3)<=0);
137        % Add constraint 2 to #elements
138        for ie=2:nelem
139            G = G + set(BuuB{ie}-alpha*eye(3)<=0);
140        end       
141    end
142   
143end
144
145% Create objective
146if bounds > 0
147    Obj = alpha*vol-F'*u+upper*r'*ones(nelem,1);
148else
149    Obj = alpha*vol-F'*u;
150end
151
152% Solve the problem
153options = sdpsettings('solver','penbmi','usex0',1,'savedebug',0,...
154    'penbmi.U0',1000,...
155    'penbmi.P0',1000,...
156    'penbmi.PEN_UP',.5,...
157    'penbmi.ALPHA',1e-5,...
158    'penbmi.P_EPS',1e-3,...%    'penbmi.PBM_EPS',1e-3,...
159    'penbmi.PRECISION_2', 1e-4);  %1e-7
160
161toc;
162tic;
163
164sol = solvesdp(G, Obj, options);
165mbg_asserttrue(sol.problem == 0);
166
167
168
169
170toc;
Note: See TracBrowser for help on using the repository browser.