Dynamic-Calibration/utils/YALMIP-master/@sdpvar/or.m

30 lines
830 B
Mathematica
Raw Normal View History

2019-12-18 11:25:45 +00:00
function varargout = or(varargin)
%OR (overloaded)
%
% z = or(x,y)
% z = x | y
%
% It is assumed that x and y are binary variables (either explicitely
% declared using BINVAR, or constrained using BINARY.)
%
% See also SDPVAR/AND, SDPVAR/XOR, SDPVAR/NOT, BINVAR, BINARY
switch class(varargin{1})
case 'char'
z = varargin{2};
xy = [];
for i = 3:nargin
xy = [xy varargin{i}];
end
varargout{1} = (sum(xy) >= z) + (z >= xy) +(binary(z));
varargout{2} = struct('convexity','none','monotonicity','none','definiteness','none','model','integer');
varargout{3} = xy;
case {'sdpvar','double','logical'}
varargout{1} = vectorizedlogic(@or,varargin{:});
otherwise
end