[37] | 1 | function [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 |
---|
| 21 | for i = 1:nargin |
---|
| 22 | varargin{i} = convertquadratics(varargin{i}); |
---|
| 23 | end |
---|
| 24 | |
---|
| 25 | variables = []; |
---|
| 26 | for 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})]); |
---|
| 33 | end |
---|
| 34 | |
---|
| 35 | if nargin == 1 |
---|
| 36 | Fhull = varargin{1}; |
---|
| 37 | return |
---|
| 38 | end |
---|
| 39 | |
---|
| 40 | y = sdpvar(repmat(length(variables),1,nargin),repmat(1,1,nargin)); |
---|
| 41 | t = sdpvar(nargin,1); |
---|
| 42 | |
---|
| 43 | Fhull = set([]); |
---|
| 44 | for 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; |
---|
| 56 | end |
---|
| 57 | Fhull = Fhull + set(sum([y{:}],2) == recover(variables)); |
---|
| 58 | Fhull = Fhull + set(sum(t)==1) + set(t>0); |
---|