isfeasible.m

来自「一个matlab的将军模型」· M 代码 · 共 42 行

M
42
字号
function result = isfeasible(a,b)

% Determine whether or not the intersection of two linear constraint objects
% exists.
%
% Syntax:
%   "C = isfeasible(a,b)"
%
% Description:
%   "isfeasible(a,b)" returns a "0" if the intersection of "a" and "b" is
%   empty, otherwise, "isfeasible(a,b)" returns "1".
%
% Examples:
%   Given two linear constraint objects, "a" representing a square in the
%   x3 = 0 plane with corners at (x1,x2) pairs (2,1), (2,3), (4,3), and
%   (4,1) and "b", another square in the same plane with corners at (2,1),
%   (2,2), (3,1), and (3,2), 
%
%
%
%   "C = isfeasible(a,b)"
%
%
%
%   returns "1".
%
% See Also:
%   linearcon,and

if isa(b,'polyhedron')
  b = linearcon(b);
end

if isa(b,'linearcon')
  c = intersect(a,b,0);
else
  c = linearcon;
end

result = ~isempty(c);

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?