source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/opt/yalmip/operators/sort_internal.m @ 37

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

Added original make3d

File size: 1.1 KB
Line 
1function [F,vars] = sort_internal(t,X,data);%ii,D,V);
2
3% Hack to figure out all the sorted variables, not just this index.
4% Sort is implemented in a slighlt different way (general feature in
5% future versions) that allows one element in an operator to modell all
6% elements. Reduces the number of calls to the operator code.
7
8ii = data.i;
9D = data.D;
10V = data.V;
11
12var_start = getvariables(t)-ii+1;
13n = length(X);
14var_end   = getvariables(t)-ii+1 + n-1;
15vars = var_start:var_end;
16
17% Is this a location variable instead of the actuial sort variable. If so,
18% shift everything back to get the indicies of the sorted variables.
19if data.isthisloc == 1
20    vars = vars - n;
21end
22
23t   = recover(vars);
24loc = recover(vars+n);
25
26[M,m] = derivebounds(X);
27X = reshape(X,1,n);
28
29% Standard model
30F = set(sum(D,1) == 1) + set(sum(D,2) == 1);
31F = F + set(t == sum(V,2));
32F = F + set(diff(t) > 0);
33for i = 1:n
34   di = D(i,:);
35   vi = V(i,:);
36   F = F + set(-(M-m)'.*(1-di) < X-vi < (M-m)'.*(1-di));
37   F = F + set(m'.*di <  vi < M'.*di);   
38end
39
40% Cuts
41F = F + set(X == sum(V,1));
42F = F + set(sum(t) == sum(X));
43
44% Definition of location
45F = F + set(loc == D*[(1:n)']) + set(1 <= loc <= n);
46
Note: See TracBrowser for help on using the repository browser.