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

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

Added original make3d

File size: 2.5 KB
Line 
1function varargout = or(varargin)
2%OR (overloaded)
3
4% Author Johan Löfberg
5% $Id: or.m,v 1.8 2006/05/14 17:21:09 joloef Exp $   
6
7% Models OR using a nonlinear operator definition
8switch class(varargin{1})
9    case 'char'
10        z = varargin{2};
11        X = varargin{3};
12        Y = varargin{4};       
13     
14        F = set([]);               
15        switch class(X)
16            case 'sdpvar'
17                x = X;
18                xvars = getvariables(x);               
19                allextvars = yalmip('extvariables');
20                if (length(xvars)==1) & ismembc(xvars,allextvars)
21                    [x,F] = expandor(x,allextvars,F);
22                end
23
24            case 'constraint'
25                x = binvar(1,1);
26                F = F + set(implies_internal(x,X));
27            otherwise
28        end
29        switch class(Y)
30            case 'sdpvar'
31                y = Y;
32                yvars = getvariables(y);
33                allextvars = yalmip('extvariables');
34                if (length(yvars)==1) & ismembc(yvars,allextvars)
35                    [y,F] = expandor(y,allextvars,F);
36                end
37            case 'constraint'
38                y = binvar(1,1);
39                F = F + set(implies_internal(y,Y));
40            otherwise
41        end
42
43        xy = [x y];
44       
45        varargout{1} = F + set(sum(xy) > z) + set(z > xy) +set(binary(z));
46        varargout{2} = struct('convexity','none','monotonicity','exact','definiteness','none');
47        varargout{3} = xy;
48
49    case {'sdpvar','constraint'}
50        x = varargin{1};
51        y = varargin{2};
52        varargout{1} = yalmip('addextendedvariable','or',varargin{:});
53
54    otherwise
55end
56
57
58function [x,F] = expandor(x,allextvars,F)
59
60xmodel = yalmip('extstruct',getvariables(x));
61
62if isequal(xmodel.fcn,'or')
63    X1 = xmodel.arg{1};
64    X2 = xmodel.arg{2};
65
66    switch class(X1)
67        case 'sdpvar'
68            x1 = X1;
69            xvars = getvariables(x1);
70            if ismembc(xvars,allextvars)
71                [x1,F] = expandor(x1,allextvars,F);
72            end
73
74        case 'constraint'
75            x1 = binvar(1,1);
76            F = F + set(iff_internal(X1,x1));
77        otherwise
78    end
79    switch class(X2)
80        case 'sdpvar'
81            x2 = X2;
82            yvars = getvariables(x2);
83            if ismembc(yvars,allextvars)
84                [x2,F] = expandor(x2,allextvars,F);
85            end
86        case 'constraint'
87            x2 = binvar(1,1);
88            F = F + set(iff_internal(X2,x2));
89        otherwise
90    end
91    x = [x1 x2];
92end
Note: See TracBrowser for help on using the repository browser.