www.gusucode.com > mbcdata 工具箱 matlab 源码程序 > mbcdata/@cgoptimstore/evaluateConstraint.m
function varargout = evaluateConstraint(optimstore, X, varargin) %EVALUATECONSTRAINT Evaluate optimization constraints % % Y = EVALUATECONSTRAINT(OPTIMSTORE, X) evaluates all of the optimization % constraints at the free variable values X. X must be a % (NPoints-by-NFreeVar) matrix where NPoints is the number of points to % be evaluated and NFreeVar is the number of free variables in the % optimization. The values of the constraints are returned in Y, which is % of size (NPoints-by-NItems) where NItems is the number of constraints % in the optimization. % % 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. % % Y = EVALUATECONSTRAINT(OPTIMSTORE, X, ITEMNAMES) evaluates the % constraints specified in the cell array of strings, ITEMNAMES, at the % free variable values X. The values of the constraints are returned in % Y, which is of size (NPoints-by-NItems) where NItems is the number of % objectives listed in ITEMNAMES. % % [Y, YG] = EVALUATECONSTRAINT(OPTIMSTORE, X, ITEMNAMES) also evaluates % the gradient of the specified constraints in YG (if ITEMNAMES is not % specified, then the gradient of all constraints is returned). YG is of % size NFreeVar-by-NItems-by-NPoints, where NFreeVar is the number of % free variables in the optimization. % % See also CGOPTIMSTORE/EVALUATEOBJECTIVE, CGOPTIMSTORE/EVALUATENONLCON % Copyright 2006-2008 The MathWorks, Inc. % Check the inputs [ok, msg] = pCheckEvaluateXXXInputs(optimstore, 'constraint', ... X, varargin{:}); % Evaluate the required constraints if ok [varargout{1:nargout}] = evaluateConstraint(optimstore.OptimRunner, ... X, varargin{:}); else error('mbc:cgoptimstore:InvalidArgument', msg); end