www.gusucode.com > mbcexpr 工具箱 matlab 源码程序 > mbcexpr/@cgmodexpr/ceval.m

    function cvals = ceval(mod)
%CEVAL Evaluate constraints
%
%  DATA = CEVAL(M)
%    DATA<0 is feasible

%  Copyright 2000-2007 The MathWorks, Inc. and Ford Global Technologies, Inc.


if isempty(mod)
    cvals = -1;
else
    % Generate the inputs for the function.
    inp = getinputs(mod);
    if all(isvalid(inp))
        inputs = pveceval(inp,@i_eval);

        % Evaluate model
        cvals = ceval(mod.model, inputs);
    else
        cvals = -1;
    end

    % If any of the constraint values are -ve, ie ok, we need to also check
    % the default superclass constraining behaviour to allow for the inputs
    % being constrained out.
    if any(cvals<0)
        cvals = max(cvals, ceval(mod.cgexpr));
    end
end