📄 constraint.m
字号:
function F = constraint(X,quantifier,Y)
% Internal class for constraint list
% Author Johan L鰂berg
% $Id: constraint.m,v 1.7 2007/09/12 14:28:29 joloef Exp $
superiorto('sdpvar');
superiorto('double');
if isa(X,'blkvar')
X = sdpvar(X);
end
if isa(Y,'blkvar')
Y = sdpvar(Y);
end
% Evaluate and save a SET object
switch quantifier
case '>'
Z = X - Y;
% C = set(X > 0);
case '>='
Z = X - Y;
% C = set(X >= 0);
case '<'
Z = Y - X;
% C = set(Z > 0);
case '<='
Z = Y - X;
% C = set(Z >= 0);
case '=='
Z = Y - X;
% C = set(Z == 0);
%case {'>','>='}
% Z = X - Y;
%case {'<','<=','=='}
% Z = Y - X;
otherwise
error('Quantifier not supported')
end
if isequal(Z,0)
warning('Constraint evaluated to trivial true.')
F = set([]);
return
end
switch quantifier
case {'>','<'}
F.strict(1) = 1;
case {'>=','<=','=='}
F.strict(1) = 0;
otherwise
error('Quantifier not supported')
end
F.List={X,quantifier,Y};
F.Evaluated{1} = Z;
F.ConstraintID = yalmip('ConstraintID');
F = class(F,'constraint');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -