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

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

Added original make3d

File size: 2.4 KB
Line 
1function Matrices = yalmip2mpt(interfacedata)
2
3F_struc = interfacedata.F_struc;
4c       = interfacedata.c;
5f       = interfacedata.f;
6K       = interfacedata.K;
7x0      = interfacedata.x0;
8Q       = interfacedata.Q;
9lb      = interfacedata.lb;
10ub      = interfacedata.ub;
11
12% We have three groups of variables.
13% parametric, free, and binary free
14param_var  = interfacedata.parametric_variables;
15free_var   = setdiff(1:length(c),param_var);
16binary_var = interfacedata.binary_variables;
17
18% These rows of the solution should be returned
19if isempty(interfacedata.requested_variables)
20    Matrices.requested_variables = 1:length(free_var);
21else
22    Matrices.requested_variables = [];
23    for i = 1:length(interfacedata.requested_variables)
24        Matrices.requested_variables = [Matrices.requested_variables  find(ismember(free_var,interfacedata.requested_variables(i)))];
25    end
26end
27
28% Extract data for free and parametric variables
29Matrices.F  = (2*Q(param_var,free_var));
30Matrices.Y  = (Q(param_var,param_var));
31Matrices.H  = (2*Q(free_var,free_var));
32Matrices.G  = (-F_struc(1+K.f:end,1+free_var));
33Matrices.E  = (F_struc(1+K.f:end,1+param_var));
34Matrices.W  = (F_struc(1+K.f:end,1));
35Matrices.Cf = (c(free_var)');
36Matrices.Cx = (c(param_var)');
37Matrices.Cc = (f);
38
39% Equality constraints (YALMIP specific)
40Matrices.Aeq = -F_struc(1:K.f,1+free_var);
41Matrices.Beq = -F_struc(1:K.f,1+param_var);
42Matrices.beq = F_struc(1:K.f,1);
43
44% This is not dealth with in YALMIP
45Matrices.bndA=[];
46Matrices.bndb=[];
47
48% Save this silly info also
49Matrices.nu = length(free_var);
50Matrices.nx = length(param_var);
51
52if nnz(Matrices.H)==0 & nnz(Matrices.Y)==0%nnz(Q)==0
53    % Whoops, it's an LP and MPT uses the name H for linear cost also...
54    Matrices.H = c(free_var)';   
55    if nnz(Matrices.F) > 0
56        % Latest MPT does not fullify D
57        Matrices.D = full(Matrices.F');
58    end
59    Matrices.F = Matrices.Cx;
60    Matrices.qp = 0;
61else
62    Matrices.qp = 1;
63end
64
65if ~isempty(lb)
66    Matrices.lb = [lb(free_var);lb(param_var)];
67else
68    Matrices.lb = repmat(-inf,nx+nu,1);
69end
70if ~isempty(ub)
71    Matrices.ub = [ub(free_var);ub(param_var)];
72else
73    Matrices.ub = repmat(inf,nx+nu,1);
74end
75
76Matrices.param_var  = interfacedata.parametric_variables;
77Matrices.free_var   = setdiff(1:length(c),param_var);
78Matrices.binary_var_index = find(ismember(free_var,binary_var));
79
80% A transformation to go to original variables when
81% equality constraints have been removed
82Matrices.getback = [];
Note: See TracBrowser for help on using the repository browser.