source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/opt/yalmip/extras/sedumi2penbmi.m @ 37

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

Added original make3d

File size: 2.8 KB
Line 
1function pen = sedumi2penbmi(F_struc,c,Q,K,monomtable,options,x0)
2
3% Linear before bilinearize
4temp = sum(monomtable,2)>1;
5tempnonlinearindicies = find(temp);
6templinearindicies = find(~temp);
7
8if isempty(monomtable)
9    monomtable = eye(length(c));
10end
11
12temp = sum(monomtable,2)>1;
13nonlinearindicies = find(temp);
14linearindicies = find(~temp);
15c0 = c;
16c  = c(linearindicies);
17Q = Q(linearindicies,linearindicies);
18nonlinear_scalars = [];
19
20% Any non-linear scalar inequalities?
21% Move these to the BMI part
22if K.l>0
23    nonlinear_scalars = find(any(full(F_struc(1:K.l,[nonlinearindicies(:)'+1])),2));
24    if ~isempty(nonlinear_scalars)
25        Kold = K;
26        linear_scalars = setdiff(1:K.l,nonlinear_scalars);
27        F_struc = [F_struc(linear_scalars,:);F_struc(nonlinear_scalars,:);F_struc(K.l+1:end,:)];
28        K.l = K.l-length(nonlinear_scalars);
29        if (length(K.s)==1) & (K.s==0)
30            K.s    = [repmat(1,1,length(nonlinear_scalars))];
31            K.rank = repmat(1,1,length(nonlinear_scalars));
32        else
33            K.s    = [repmat(1,1,length(nonlinear_scalars)) K.s];
34            K.rank = [repmat(1,1,length(nonlinear_scalars)) K.rank];
35        end
36    end
37end
38
39if ~isempty(F_struc)
40    pen = sedumi2pen(F_struc(:,[1 linearindicies(:)'+1]),K,c,x0);
41else
42    pen = sedumi2pen([],K,c,x0);
43end
44
45if ~isempty(nonlinearindicies)
46    bmi = sedumi2pen(F_struc(:,[nonlinearindicies(:)'+1]),K,[],[]);
47    pen.ki_dim = bmi.ai_dim;
48    % Nonlinear index
49    pen.ki_dim = bmi.ai_dim;
50    pen.ki_row = bmi.ai_row;
51    pen.ki_col = bmi.ai_col;
52    pen.ki_nzs = bmi.ai_nzs;
53    pen.ki_val = bmi.ai_val;
54    for i = 1:length(bmi.ai_idx)
55        nl = nonlinearindicies(1+bmi.ai_idx(i));
56        v = find(monomtable(nl,:));
57        if length(v)==1
58            v(2)=v(1);
59        end     
60        pen.ki_idx(i)=find(linearindicies == v(1));
61        pen.kj_idx(i)=find(linearindicies == v(2));
62    end
63else
64    pen.ki_dim = 0*pen.ai_dim;
65    pen.ki_row = 0;
66    pen.ki_col = 0;
67    pen.ki_nzs = 0;
68    pen.ki_idx = 0;
69    pen.kj_idx = 0;
70    pen.kj_val = 0;   
71end
72
73if nnz(Q)>0
74    [row,col,vals] = find(triu(Q));
75    pen.q_nzs = length(row);
76    pen.q_val = vals';
77    pen.q_col = col'-1;
78    pen.q_row = row'-1;
79else
80    pen.q_nzs = 0;
81    pen.q_val = 0;
82    pen.q_col = 0;
83    pen.q_row = 0;   
84end
85
86ops = struct2cell(options.penbmi);ops = [ops{1:end}];
87pen.ioptions = ops(1:12);
88pen.foptions = ops(13:end);
89pen.ioptions(4) = max(0,min(3,options.verbose+1));
90if pen.ioptions(4)==1
91    pen.ioptions(4)=0;
92end
93
94% ****************************************
95% UNCOMMENT THIS FOR PENBMI version 1
96% ****************************************
97%pen.ioptions = pen.ioptions(1:8);
98%pen.foptions = pen.foptions(1:8);
99
100if ~isempty(x0)   
101    pen.x0(isnan(pen.x0)) = 0;
102    pen.x0 = x0(linearindicies);   
103    pen.x0 = pen.x0(:)';
104end
Note: See TracBrowser for help on using the repository browser.