📄 searchlhs.m
字号:
function [successSearch,nextIterate,FunEval] = searchlhs(FUN,Xin,Iterate,ToL,A,L,U, ...
FunEval,maxFun,searchoptions,objFcnArg,iterLimit,factors)
%SEARCHLHS: Search technique using latin hypercube search.
% [SUCCESSSEARCH,NEXTITERATE,FUNEVAL] = SEARCHLHS(FUN,ITERATE,TOL,A, ...
% L,U,FUNEVAL,MAXFUN,SEARCHOPTIONS,OBJFCNARG,ITERLIMIT,FACTORS) searches
% for the next iterate in a latin hypercube design space.
%
% FUN: The objective function on which SEARCH step is implemented.
%
% ITERATE: Current point in the iteration. ITERATE is a structure which
% contains current point 'x' and the function value 'f'.
%
% TOL: Tolerance used for determining whether constraints are active or not.
%
% A,L,U: Defines the feasible region in case of linear/bound constraints
% as L<=A*X<=U.
%
% FUNEVAL: Counter for number of function evaluations. FunEval is always less
% than 'MAXFUN', which is maximum number of function evaluation.
%
% MAXFUN: Limit on number of function evaluation.
%
% SEARCHOPTIONS is a structure containing the following information:
% completesearch: If 'off' indicates that SEARCH can be called off as
% soon as a better point is found, i.e., no sufficient
% decrease condition is imposed; Default
% is 'on'. See PSOPTIMSET for a description.
% meshsize: Current mesh size used in SEARCH step.
% iteration: Current iteration number.
% scale: Scale factor used to scale the design points.
% indineqcstr: Indices of inequality constraints.
% indeqcstr: Indices of equality constraints.
% problemtype: This flag is passed to the SEARCH routines, indicating
% that the problem is 'unconstrained', 'boundconstraints',
% or 'linearconstraints'.
% notvectorized: A flag indicating FUN is not evaluated as vectorized.
% cache: A flag for using CACHE. If 'off', no cache is used.
% cachetol: Tolerance used in cache in order to determine whether
% two points are same or not.
% cachelimit: Limit the cache size to 'cachelimit'.
%
% OBJFCNARG: Cell array of additional arguments for objective function.
%
% ITERLIMIT: No search above this iteration number (Optional argument).
%
% FACTORS: The design level for LHS (Optional argument).
%
% NEXTITERATE: Successful iterate after polling is done. If POLL is not
% successful, NEXTITERATE is same as ITERATE.
%
% SUCCESSSEARCH: A boolean identifier indicating whether SEARCH is
% successful or not.
%
% See also PATTERNSEARCH, GA, PSOPTIMSET SEARCHFCNTEMPLATE.
% Copyright 2004 The MathWorks, Inc.
% $Revision: 1.13.6.3 $ $Date: 2004/04/06 01:10:04 $
successSearch = 0;
nextIterate = Iterate;
numberofVariables = size(Iterate.x,1);
if nargin < 13 || isempty(factors)
factors = 15*numberofVariables;
end
if nargin <12 || isempty(iterLimit)
iterLimit = 1;
end
%Use search step only till iterLimit.
if searchoptions.iteration >= iterLimit
return;
end
%Get information from the searchoptions structure
Completesearch = searchoptions.completesearch;
IndEqcstr = searchoptions.indeqcstr;
NotVectorized = searchoptions.notvectorized;
Cache = searchoptions.cache;
cachetol = searchoptions.cachetol;
cachelimit = searchoptions.cachelimit;
MeshSize = searchoptions.meshsize;
scale = searchoptions.scale;
%LHS design calculations for 'maximin' criterion
Points = lhspoint(factors,numberofVariables);
if ~isempty(searchoptions.indineqcstr)
range = [L(~searchoptions.indineqcstr & ~searchoptions.indeqcstr) ...
U(~searchoptions.indineqcstr & ~searchoptions.indeqcstr)]';
else
range = [L U]';
end
if ~isempty(range) && ~any(isinf(range(:)))
limit = range(2,:) - range(1,:);
Points = repmat(range(1,:)',1,size(Points,2)) + repmat(limit',1,size(Points,2)) .* Points;
span = size(Points,2);
sites = struct('x',cell(span,1,1),'f',cell(span,1,1));
for k = 1:span
sites(k).x = Points(:,k);
end
else
Points = -1 + Points*2;
span = size(Points,2);
sites = struct('x',cell(span,1,1),'f',cell(span,1,1));
for k = 1:span
sites(k).x = Iterate.x + MeshSize*scale.*Points(:,k);
end
end
%Find an iterate with lower objective
[successSearch,nextIterate,direction,FunEval] = nextfeasible(FUN,Xin,sites,Iterate,A,L,U, ...
FunEval,maxFun,Completesearch,ToL,IndEqcstr,NotVectorized,Cache,cachetol,cachelimit,objFcnArg{:});
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -