www.gusucode.com > mbcview 工具箱matlab源码程序 > mbcview/+cageview/+optimoutput/ParetoViewData.m
classdef ParetoViewData < mbcgui.widget.ScrollTableData %cageview.optimoutput.ParetoViewData class % cageview.optimoutput.ParetoViewData extends mbcgui.widget.ScrollTableData. % % cageview.optimoutput.ParetoViewData properties: % MessageService - Property is of type 'handle' % ObjectiveNames - Property is of type 'MATLAB array' (read only) % ObjectiveData - Property is of type 'MATLAB array' (read only) % RGBValues - Property is of type 'MATLAB array' (read only) % ObjectiveLimitsRows - Property is of type 'MATLAB array' (read only) % ObjectiveLimitsCols - Property is of type 'MATLAB array' (read only) % DisplayResults - Property is of type 'MATLAB array' % Solution - Property is of type 'MATLAB array' (read only) % % cageview.optimoutput.ParetoViewData methods: % getCellData - Indexing interface for scrolling tables % getColumnCount - Return the number of columns in the data model. % getRowCount - Return the number of rows in the data model. % getStandardColumnHeaderData - Get data structure for specified column header. % getStandardRowHeaderData - Get data structure for specified row header. % reset - Reset the objective data % Copyright 2005-2015 The MathWorks, Inc. properties (AbortSet) %MESSAGESERVICE Property is of type 'handle' MessageService = []; %DISPLAYRESULTS Property is of type 'MATLAB array' DisplayResults = 'All'; end properties (SetAccess=protected, AbortSet) %OBJECTIVENAMES Property is of type 'MATLAB array' (read only) ObjectiveNames = []; %OBJECTIVEDATA Property is of type 'MATLAB array' (read only) ObjectiveData = []; %RGBVALUES Property is of type 'MATLAB array' (read only) RGBValues = []; %OBJECTIVELIMITSROWS Property is of type 'MATLAB array' (read only) ObjectiveLimitsRows = []; %OBJECTIVELIMITSCOLS Property is of type 'MATLAB array' (read only) ObjectiveLimitsCols = []; %SOLUTION Property is of type 'MATLAB array' (read only) Solution = 0; end methods % public methods %---------------------------------------- function val = getCellData(obj, R, C) %GETCELLDATA Indexing interface for scrolling tables % DATA = GETCELLDATA(OBJ, R, C) creates a structure of data for the cell % at the specified row and column. if length(obj.ObjectiveNames)<2 || R>C x = []; y = []; xlim = [-1 1]; ylim = [-1 1]; Xlab = ''; Ylab = ''; selpoints = []; sol = 0; else if R==obj.getRowCount Xlab = obj.ObjectiveNames{C+1}; else Xlab = ''; end if C==1 Ylab = obj.ObjectiveNames{R}; else Ylab = ''; end x = obj.ObjectiveData(:, C+1); y = obj.ObjectiveData(:, R); x = repmat(x,1,3); y = repmat(y,1,3); x(~obj.RGBValues) = NaN; y(~obj.RGBValues) = NaN; switch obj.DisplayResults case 'Green' x(:,2:3) = NaN; case 'Orange' x(:,[1 3]) = NaN; case 'Red' x(:,1:2) = NaN; end xlim = obj.ObjectiveLimitsCols{C+1}; ylim = obj.ObjectiveLimitsRows{R}; selpoints = obj.MessageService.CurrentSolution; sol = obj.Solution; end val = struct('xdata', x.', ... 'ydata', y.', ... 'xlim', xlim, ... 'ylim', ylim, ... 'xlabel', Xlab, ... 'ylabel', Ylab, ... 'SelectedPoints', selpoints,... 'Solution',sol); end % getCellData %---------------------------------------- function nC = getColumnCount(obj) %GETCOLUMNCOUNT Return the number of columns in the data model. % NC = GETCOLUMNCOUNT(OBJ) returns the number of columns in the data model. nC = max(length(obj.ObjectiveNames)-1,0); end % getColumnCount %---------------------------------------- function nR = getRowCount(obj) %GETROWCOUNT Return the number of rows in the data model. % NR = GETROWCOUNT(OBJ) returns the number of rows in the data model. nR = max(length(obj.ObjectiveNames)-1,0); end % getRowCount %---------------------------------------- function val = getStandardColumnHeaderData(obj, C) %GETSTANDARDCOLUMNHEADERDATA Get data structure for specified column header. % VAL = GETSTANDARDCOLUMNHEADERDATA(OBJ, C) returns a structure of data % for the column header at location C. SelIdx = obj.MessageService.getFocusSolution; if SelIdx>0 IndicatedValue = obj.ObjectiveData(SelIdx, C+1); else IndicatedValue = NaN; end val = struct('Value', num2cell(IndicatedValue, 1), ... 'Limits', obj.ObjectiveLimitsCols(C+1), ... 'Label', obj.ObjectiveNames(C+1)); end % getStandardColumnHeaderData %---------------------------------------- function val = getStandardRowHeaderData(obj, R) %GETSTANDARDROWHEADERDATA Get data structure for specified row header. % VAL = GETSTANDARDROWHEADERDATA(OBJ, R) returns a structure of data for % the row header at location R. SelIdx = obj.MessageService.getFocusSolution; if SelIdx>0 IndicatedValue = obj.ObjectiveData(SelIdx, R); else IndicatedValue = NaN; end val = struct('Value', num2cell(IndicatedValue, 1)', ... 'Limits', obj.ObjectiveLimitsRows(R)', ... 'Label', obj.ObjectiveNames(R)'); end % getStandardRowHeaderData %---------------------------------------- function reset(obj) %RESET Reset the objective data % % RESET(OBJ) re-calculates the objective data from the message service % and resets the view limits. Data = []; Names = {}; rgbValues = []; sol = 0; if ~isempty(obj.MessageService) && obj.MessageService.hasData out = obj.MessageService.getOptimOutput; if strcmpi(obj.MessageService.CurrentSliceDirection, 'WeightedSolution') [Data, Names] = getWeightedSolution(out, ... 'OutputFormat', 'matrix', 'OutputContents', {'Objectives'}); % Display weighted point objective data. The exit flag for a solution % is taken to be the minimum exit flag over all runs exitFlags = getExitFlag(out); exitFlags = min(exitFlags,[], 1); rgbValues = [exitFlags>0 exitFlags==0 exitFlags<0]; switch obj.DisplayResults case 'Acceptable' AcceptArray = all(isAcceptable(out,':',':'),1); otherwise AcceptArray = true(size(Data,1),1); end Data(~AcceptArray,:) = NaN; else RunIdx = obj.MessageService.getFocusRun; if RunIdx>0 % Show standard pareto surface [Data, Names] = getParetoSolution(out, RunIdx, ... 'OutputFormat', 'matrix', 'OutputContents', {'Objectives'}); exitFlags = getExitFlag( out, RunIdx, ':' )'; rgbValues = [exitFlags>0 exitFlags==0 exitFlags<0]; switch obj.DisplayResults case 'Acceptable' AcceptArray = isAcceptable(out, RunIdx, ':'); otherwise AcceptArray = true(size(Data,1),1); end Data(~AcceptArray,:) = NaN; sol = getSelectedSolutionNumber(out,RunIdx); end end end obj.ObjectiveData = Data; obj.ObjectiveNames = Names; obj.RGBValues = rgbValues; obj.Solution = sol; lims = cell(size(Names)); for n = 1:length(lims) lims{n} = mbcmakelimits(Data(:,n)); end obj.ObjectiveLimitsRows = lims; obj.ObjectiveLimitsCols = lims; end % reset end % public methods end % classdef