www.gusucode.com > mbcdata 工具箱 matlab 源码程序 > mbcdata/@cgtabgradconstraint/getSummary.m
function [feasSummary, valueDesc, conSummary, leftSummary, rightSummary] = ... getSummary( obj, inputValues, feasValue, conValue, leftValue, rightValue,DS) %GETSUMMARY Return a summarised evaluation of the constraint % % [FEASSUMMARY, VALUEDESC, CONSUMMARY, LEFTSUMMARY, RIGHTSUMMARY] = % GETSUMMARY(OBJ, INPUTVALUES, FEASVALUE, CONVALUE, LEFTVALUE, % RIGHTVALUE) returns a summarised evaluation of OBJ. % % CONVALUE, LEFTVALUE, RIGHTVALUE and FEASVALUE are evaluations of OBJ % from which the summarized values are generated. The input values at % which OBJ was evaluated are also supplied through INPUTVALUES. % % DS is a cgstaticdataset object if the constraint is evaluated over a % dataset. Otherwise it is empty. % % GETSUMMARY returns three values per axis; values at the maximum, median % and minimum gradient in that axis direction. VALUEDESC is a 1-by-NAXES % cell array of descriptions of each constraint value. CONSUMMARY is a % 1-by-NAXES vector containing the maximum constraint distance for each % axis. LEFTSUMMARY and RIGHTSUMMARY are 1-by-NAXES vectors containing % the LHS and RHS values of the constraint at the above values. % FEASSUMMARY is a 1-by-NAXES logical vector indicating the feasibility % of the constraint at the above values. % % FEASSUMMARY = GETSUMMARY(OBJ, FEASVALUE, CONVALUE, LEFTVALUE, % RIGHTVALUE) returns a summarised feasibility status of the constraints % only. % % See also CGOPTIMCONSTRAINT/GETSUMMARY % Copyright 2007-2009 The MathWorks, Inc. NAXES = length(obj.pAxisVariables); axLen = cellfun('length', obj.AxisBreakpoints); if NAXES == 2 % Row gradients nRowGrad = 2*axLen(2)*(axLen(1) - 1); nRow = nRowGrad/2; if ~isfinite(obj.Bounds(1, 2)/obj.Bounds(1, 3)) nRowGrad = nRowGrad-nRow; end if ~isfinite(obj.Bounds(1, 1)/obj.Bounds(1, 3)) nRowGrad = nRowGrad-nRow; end [conRowSummary, leftRowSummary, rightRowSummary, feasRowSummary] = ... i_generateSummaryValue(conValue(1:nRowGrad), leftValue(1:nRowGrad), ... rightValue(1:nRowGrad), feasValue(1:nRowGrad)); % Column gradients [conColSummary, leftColSummary, rightColSummary, feasColSummary] = ... i_generateSummaryValue(conValue(nRowGrad+1:end), ... leftValue(nRowGrad+1:end), rightValue(nRowGrad+1:end), feasValue(nRowGrad+1:end)); % Concatenate the results feasSummary = [feasRowSummary, feasColSummary]; if nargout > 1 conSummary = [conRowSummary, conColSummary]; leftSummary = [leftRowSummary, leftColSummary]; rightSummary = [rightRowSummary, rightColSummary]; % Base description baseDesc = char(obj); baseDesc(1) = 'g'; baseDesc = strrep(baseDesc, 'constraint ', ''); % Set up constraint description if ~isempty(DS) DSlabel = [DS.Name,': ']; else DSlabel = ''; end valueDesc={}; if ~isempty(feasRowSummary) valueDesc{end+1} = sprintf('%sMaximum row %s', DSlabel,baseDesc); end if ~isempty(feasColSummary) valueDesc{end+1} = sprintf('%sMaximum column %s', DSlabel,baseDesc); end end else % Row gradients [conSummary, leftSummary, rightSummary, feasSummary] = ... i_generateSummaryValue(conValue, leftValue, rightValue, feasValue); if nargout > 1 % Base description baseDesc = char(obj); baseDesc(1) = 'g'; baseDesc = strrep(baseDesc, 'constraint ', ''); % Set up constraint description if ~isempty(DS) DSlabel = [DS.Name,': ']; else DSlabel = ''; end if ~isempty(feasSummary) valueDesc{1} = sprintf('%sMaximum %s', DSlabel,baseDesc); else valueDesc = {}; end end end %-------------------------------------------------------------------------- function [conSummary, leftSummary, rightSummary, feasSummary] = ... i_generateSummaryValue(conValue, leftValue, rightValue, feasValue) %-------------------------------------------------------------------------- [maxLeftValue, idxMax] = max(leftValue); conSummary = conValue(idxMax); leftSummary = maxLeftValue; rightSummary = rightValue(idxMax); feasSummary = feasValue(idxMax);