www.gusucode.com > mbcdata 工具箱 matlab 源码程序 > mbcdata/@cgoptimrunner/getConstraintSummary.m

    function [feasSummary, descSummary, conSummary, leftSummary, rightSummary] = ...
    getConstraintSummary(or, ItemNames, feasValue, conValue, leftValue, ...
    rightValue, freeValue, runIdx)
%GETCONSTRAINTSUMMARY Get summarized evaluation of a constraint
%
%   [FEASSUMMARY, VALUEDESC, CONSUMMARY, LEFTSUMMARY, RIGHTSUMMARY] =
%   GETCONSTRAINTSUMMARY(OR, ITEMNAMES, FEASVALUE, CONVALUE, LEFTVALUE,
%   RIGHTVALUE, FREEVALUE, RUNIDX) returns the summarized evaluation of the
%   specified constraints at the specified run. FEASVALUE, CONVALUE,
%   LEFTVALUE, RIGHTVALUE and FREEVALUE are assumed to come from the output
%   CGOPTIMOUTPUT/GETSINGLESOLUTION for the specified constraints. All
%   inputs except OR, RUNIDX and FREEVALUE should be passed as 1-by-N cell
%   arrays. 
%
%   FEASSUMMARY = GETCONSTRAINTSUMMARY(OR, ITEMNAMES, FEASVALUE) returns 
%   the summarized feasible status only.

%   Copyright 2007-2011 The MathWorks, Inc.

% Initialise outputs
nCon = length(ItemNames);
feasSummary = cell(1, nCon);
if nargout > 1
    descSummary = cell(1, nCon);
    conSummary = cell(1, nCon);
    leftSummary = cell(1, nCon);
    rightSummary = cell(1, nCon);
end

% Get static data for all the constraints
ItemData = pGetItemDataFor(or.Constraints, 'LHSEvaluate');

% Create the combined free/fixed variable matrix (i.e. all inputs)
XAll = pCreateEvalInputs(or, freeValue, 'runs', runIdx);

for i = 1:nCon
    idx = find( strcmp( ItemNames{ i },getConstraintNames( or ) ) );
    if isempty(idx)
        error(message('mbc:cgoptimrunner:InvalidArgument2'));
    end
    
    % Retrieve the input matrix from the static cache
    InpIdx = ItemData.InputIndices{idx};
    if ItemData.Datasets(i)
        % have to interpolate to get correct inputs
        DS = or.DataSetData(ItemData.Datasets(i));
        Xinterp = interpolateInputs(DS,XAll);
        InputValues = Xinterp(InpIdx);
        DS = or.DataSetData(ItemData.Datasets(i));
    else
        % use raw input data
        InputValues = XAll(InpIdx);
        DS = [];
    end
    
    if nargout > 1
        % note that descSummary is altered for dataset
        [feasSummary{i}, descSummary{i}, conSummary{i}, leftSummary{i},  ...
            rightSummary{i}] = getSummary(or.Constraints.Items{idx}, ...
            InputValues, feasValue{i}, conValue{i}, leftValue{i}, rightValue{i},DS);
    else
        feasSummary{i} = getSummary(or.Constraints.Items{idx}, ...
            InputValues, feasValue{i}, conValue{i}, leftValue{i}, rightValue{i},DS);
    end
end