www.gusucode.com > mbcdata 工具箱 matlab 源码程序 > mbcdata/@cgoptimstore/gridEvaluate.m
function y = gridEvaluate(optimstore, X, varargin) %GRIDEVALUATE Grid evaluation of optimization objectives and constraints % % Y = GRIDEVALUATE(OPTIMSTORE, X) evaluates all the objectives and % constraints at the points X for the current run. This call produces % identical results to the equivalent call to CGOPTIMSTORE/EVALUATE. % % Y = GRIDEVALUATE(OPTIMSTORE, X, OBJCONNAME) evaluates the % objectives/constraints specified in the cell array OBJCONNAME as % described above. % % Y = GRIDEVALUATE(OPTIMSTORE, X, OBJCONNAME, DATASETNAME) evaluates the % specified objectives/constraints at all combinations of the points in % DATASETNAME with X. The return matrix, Y, is of size % SIZE(X,1)-by-length(OBJCONNAME)-by-NPTS, where NOBJ is the number of % objectives, NCON is the number of constraints and NPTS is the number of % rows in P. Further, Y(I, J, K) is the value of the J-th % objective/constraint at X(I, :) and P(K, :). % % Note that if the user enables scaling of the optimization items, then % the evaluation of Y is approximately scaled onto [-1 1]. See 'Scale % Optimization' in the Using CAGE section of the documentation for more % information on scaling. % % Example: % % Objectives : O1, O2 % Constraints : C1, C2 % % Specified dataset: % A | B % ----- % 4 | 5 % 1 | 3 % % Free variables: % x1 x2 x3 % (2 4 8) % X = (1 9 3) % (6 2 7) % % In this case Y = GRIDEVALUATE(OPTIMSTORE, X) will evaluate objectives % and constraints at the following points, % % A B X1 X2 X3 % 4 5 2 4 8 % 4 5 1 9 3 % 4 5 6 2 7 % 1 3 2 4 8 % 1 3 1 9 3 % 1 3 6 2 7 % % Y will be a 3 by 4 by 2 matrix, where % % Y(:, 1, 1) = Values of 01 at A = 4, B = 5 % Y(:, 2, 1) = Values of 02 at A = 4, B = 5 % Y(:, 3, 1) = Values of C1 at A = 4, B = 5 % Y(:, 4, 1) = Values of C2 at A = 4, B = 5 % Y(:, 1, 2) = Values of 01 at A = 1, B = 3 % Y(:, 2, 2) = Values of 02 at A = 1, B = 3 % Y(:, 3, 2) = Values of C1 at A = 1, B = 3 % Y(:, 4, 2) = Values of C2 at A = 1, B = 3 % % % Y = GRIDEVALUATE(OPTIMSTORE, X, DATASETNAME, OBJCONNAME, ROWIND) % evaluates the specified objectives/constraints at the points of % DATASETNAME given by ROWIND as described above. Y is a LENGTH(ROWIND) by % LENGTH(OBJCONNAME) by NPTS matrix. % % See also CGOPTIMSTORE/EVALUATE % Copyright 2000-2008 The MathWorks, Inc. and Ford Global Technologies, Inc. % Prepare for evaluation [datasetName, reqObj, reqNcon, reqLcon, itemNamesInd, rowInd] = ... pPrepareEvaluate(optimstore, varargin{:}); % Force all runs to be used for MBC Version 2.0 scripts with no data set % specified if isempty(datasetName) && isv2mode(optimstore) rowInd = getRunIndices(optimstore.OptimRunner); end if nargin > 3 || isv2mode(optimstore) % Grid evaluation is now only supported if the evaluation occurs over % an operating point set or the script is from MBC Version 2.0 nrX = size(X, 1); nrowInd = length(rowInd); X = repmat(X, nrowInd, 1); rowInd = repmat(rowInd(:), 1, nrX); rowInd = rowInd'; rowInd = rowInd(:); end % Perform evaluation y = pEvaluate(optimstore, X, reqObj, reqNcon, reqLcon, datasetName, rowInd); % Evaluation is returned as [Objs, Nonlcon, Lcon]. Return to the order % specified by the user y = y(:, itemNamesInd);