source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/opt/yalmip/extras/@lmi/hull.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 [Fhull,t] = hull(varargin)
2% HULL  Construct a model of the convex hull
3%
4% H = hull(F1,F2,...)
5%
6% OUTPUT
7%   H   : SET object describing the convex hull of the input constraints
8%
9% INPUT
10%   Fi  : SET objects with constraints
11%
12% Note that the convex representation of the convex hull requires a lifting
13% (introduction of auxially variables). Hence, if you have many set of
14% constraints, your problem rapidly grows large.
15
16% $Id: hull.m,v 1.7 2006/06/21 13:31:03 joloef Exp $   
17
18
19% Pre-process to convert convex quadratic constraints to socp constraints.
20% This makes the perspective code easier
21for i = 1:nargin
22    varargin{i} = convertquadratics(varargin{i});
23end
24
25variables = [];
26for i = 1:nargin
27    if ~(isa(varargin{i},'lmi') | isa(varargin{i},'socc'))
28        error('Hull can only be applied to linear constraints');
29    elseif ~(islinear(varargin{i}))
30        error('Hull can only be applied to linear and convex quadratic constraints');
31    end
32    variables = unique([variables depends(varargin{i})]);
33end
34
35if nargin == 1
36    Fhull = varargin{1};
37    return
38end
39
40y = sdpvar(repmat(length(variables),1,nargin),repmat(1,1,nargin));
41t = sdpvar(nargin,1);
42
43Fhull = set([]);
44for i = 1:nargin
45    Fi = varargin{i};
46    tvariable = getvariables(t(i));
47    for j = 1:length(Fi.clauses)
48        local_variables = getvariables(Fi);
49        Xi = Fi.clauses{j}.data;
50        local_variables = getvariables(Xi);
51        local_index = find(ismember(variables,local_variables));
52        new_variables = getvariables(y{i}(local_index));
53        Fi.clauses{j}.data = brutepersp(Fi.clauses{j}.data,tvariable,new_variables);       
54    end
55    Fhull = Fhull + Fi;
56end
57Fhull = Fhull + set(sum([y{:}],2) == recover(variables));
58Fhull = Fhull + set(sum(t)==1) + set(t>0);
Note: See TracBrowser for help on using the repository browser.