function varargout = or(varargin) %OR (overloaded) % % z = or(x,y) % z = x | y % % The OR operator is implemented using the concept of nonlinear operators % in YALMIP. X|Y defines a new so called derived variable that can be % treated as any other variable in YALMIP. When SOLVESDP is issued, % constraints are added to the problem to model the OR operator. The new % constraints add constraints to ensure that z,x and y satisfy the % truth-table for OR. % % The model for OR is set(z>x) + set(z>y) + set(z z) + set(z > xy) +set(binary(z)) ; varargout{2} = struct('convexity','milp','monotonicity','milp','definiteness','milp'); varargout{3} = xy; case 'sdpvar' x = varargin{1}; y = varargin{2}; varargout{1} = yalmip('addextendedvariable','or',varargin{:}); otherwise end function x = expandor(x,allextvars) xmodel = yalmip('extstruct',getvariables(x)); if isequal(xmodel.fcn,'or') x1 = xmodel.arg{1}; x2 = xmodel.arg{2}; if ismembc(getvariables(xmodel.arg{1}),allextvars) x1 = expandor(xmodel.arg{1},allextvars); end if ismembc(getvariables(xmodel.arg{2}),allextvars) x2 = expandor(xmodel.arg{2},allextvars); end x = [x1 x2]; end