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

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

Added original make3d

File size: 1.7 KB
Line 
1function sys = optimizer(F,h,ops,x,u)
2%OPTIMIZER  Container for optimization problem
3%
4%   [OPT,PROBLEM] = OPTIMIZER(F,h,options,x,u) exports an object that
5%   contains precompiled numerical data to be solved for varying arguments
6%   x, returning the optimal value of the variable u.
7%
8%   OPTIMIZER typically only makes sense if the varying data x enters the
9%   optmization problem affinely.
10%
11%   Example
12%    The following problem creates an LP with varying upper and lower
13%    bounds on the decision variable.
14%
15%    The optimizing argument is obtained by indexing the optimizer object
16%    with the point of interest. The argument should be a column vector (if
17%    the argument has a width larger than 1, YALMIP assumes that the
18%    optimal solution should be computed in several points)
19%   
20%     A = randn(10,3);
21%     b = rand(10,1)*19;
22%     c = randn(3,1);
23%
24%     z = sdpvar(3,1);
25%     sdpvar UB LB
26%
27%     F = set(A*z < b) + set(LB < z < UB);
28%     h = c'*z
29%     optZ = optimizer(F,h,[],[LB; UB],z);
30%     
31%     % Solve for LB=1, UB = 3;
32%     zopt = optZ([1; 3])
33%
34%     % Solve for (LB,UB) [1;3] and (LB,UB) [2;6]
35%     zopt = optZ([[1; 3], [2;6]])
36
37if nargin < 5
38    error('OPTIMIZER requires 5 inputs');
39end
40
41x = x(:);
42n = length(x);
43[aux1,aux2,aux3,model] = export(set(x == repmat(pi,n,1))+F,h,ops,[],[],0);
44
45if norm(model.F_struc(1:n,1)-repmat(pi,length(x),1),inf) > 1e-10
46    error('Failed exporting the model (try to specify another solver)')   
47end
48
49map = [];
50for i = 1:length(u)
51    var = getvariables(u(i));
52    map = [map;find(var == model.used_variables)];
53end
54
55sys.recover = aux2;
56sys.model = model;
57sys.n = n;
58sys.map = map;
59sys = class(sys,'optimizer');
Note: See TracBrowser for help on using the repository browser.