source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/opt/yalmip/modules/robust/robust_classify_variables.m @ 37

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

Added original make3d

File size: 3.3 KB
Line 
1function [x,w,x_variables,w_variables,aux_variables,F,failure] = robust_classify_variables(F,h,ops,w);
2
3failure = 0;
4% Variables before expanding nonlinear operators
5initial_variables = unique([depends(F) depends(h)]);
6
7% Uncertain variables
8w_variables = getvariables(w);
9
10% Decision variables
11x_variables = 1:yalmip('nvars');%union(depends(F),depends(h));
12x_variables = setdiff(x_variables,w_variables);
13
14% Any fancy modelling goin on here? If so, we need to expand the model, and
15% associate the new lifted variables either to the uncertainty set or to
16% the set of general variables. There are some classes of variables
17% 1. Uncertain variables
18% 2. Original decision variables
19% 4. Lifted variables used for uncertain variables in uncertainty description
20% 5. Lifted variables used for uncertain variables in uncertain model
21% 6. Lifted variables used for mixed  variables in uncertain model
22% FIX : This code is currently a miserable hack and should be cleaned up
23extended = yalmip('extvariables');
24aux_variables = [];
25if ~isempty(extended) & any(ismember(initial_variables,extended))
26
27    % Remove auxilliary variables (defined by YALMIP)
28    aux_variables = intersect(extended,x_variables);
29    % These variables are original decision variables
30    x_variables = setdiff(x_variables,aux_variables);
31
32    % Original constraint index
33    id = getlmiid(F(find(~lifted(F))));
34   
35    % This is a tweak to allow epxansion of bilinear terms in robust problems,
36    % is expression such as abs(x*w) < 1 for all -1 < w < 1
37    ops.expandbilinear = 1;
38
39    % Expand the model to model norms etc
40    [F,failure,cause] = expandmodel(F,h,ops);
41    if failure % Convexity propgation failed
42        interfacedata = [];
43        recoverdata = [];
44        solver = '';
45        diagnostic.solvertime = 0;
46        diagnostic.problem = 14;
47        diagnostic.info = yalmiperror(14,cause);
48        x = [];
49        w = [];
50        x_variables=[];
51        w_variables=[];
52        F = [];
53        return
54    end
55
56    % Auxillary variables (introduced by YALMIP). These variables are lifting
57    % variables that are used to model advanced constructs suck as norms etc in
58    % the nonlinear operator framework
59    new_aux_variables = setdiff(unique([depends(F) depends(h)]),initial_variables);
60    aux_variables = setdiff(union(aux_variables,new_aux_variables),w_variables);
61
62    % We know try to find the auxillary variables that are used to model
63    % functions that only depends on w
64    F_lifted = F(find(~ismember(getlmiid(F),id)));
65    aux_variables_w = aux_variables;
66    for i = 1:length(F_lifted)
67        variables = depends(F_lifted(i));
68        with_x = any(ismember(variables,x_variables));
69        with_w = any(ismember(variables,w_variables));
70        if with_x
71            aux_variables_w = setdiff(aux_variables_w,intersect(variables,aux_variables));
72            x_variables = union(x_variables,intersect(variables,aux_variables));
73        end
74    end
75
76    aux_variables_x = setdiff(aux_variables,aux_variables_w);
77    x_variables = union(aux_variables_x, x_variables);
78    w_variables = union(aux_variables_w, w_variables);
79end
80
81x_variables = intersect([getvariables(F) getvariables(h)],x_variables);
82w_variables = intersect([getvariables(F) getvariables(h)],w_variables);
83
84
85x = recover(x_variables);
86x = recover(setdiff(depends(x),w_variables));
87x_variables = getvariables(x);
88w = recover(w_variables);
89
90
Note: See TracBrowser for help on using the repository browser.