function [xmin, ... % minimum search point of last iteration
fmin, ... % function value of xmin
counteval, ... % number of function evaluations done
stopflag, ... % stop criterion reached
out, ... % struct with various histories and solutions
bestever ... % struct containing overall best solution (for convenience)
] = cmaes( ...
fitfun, ... % name of objective/fitness function
xstart, ... % objective variables initial point, determines N
insigma, ... % initial coordinate wise standard deviation(s)
inopts, ... % options struct, see defopts below
varargin ... % arguments passed to objective function
)
% Version for VFI Toolkit, lightly edited from:
% cmaes.m, Version 3.61.beta, last change: April, 2012
% CMAES implements an Evolution Strategy with Covariance Matrix Adaptation (CMA-ES) for nonlinear function minimization. For
% introductory comments and copyright (GPL) see end of file (type 'type cmaes'). cmaes_vfitoolkit.m runs with MATLAB (Windows, Linux).
%
% OPTS = CMAES returns default options.
% OPTS = CMAES('defaults') returns default options quietly.
% OPTS = CMAES('displayoptions') displays options.
% OPTS = CMAES('defaults', OPTS) supplements options OPTS with default
% options.
%
% XMIN = CMAES(FUN, X0, SIGMA[, OPTS]) locates an approximate minimum
% XMIN of function FUN starting from column vector X0 with the initial
% coordinate wise search standard deviation SIGMA.
%
% Input arguments:
%
% FUN is a string function name like 'frosen'. FUN takes as argument
% a column vector of size of X0 and returns a scalar. An easy way to
% implement a hard non-linear constraint is to return NaN. Then,
% this function evaluation is not counted and a newly sampled
% point is tried immediately.
%
% X0 is a column vector, or a matrix, or a string. If X0 is a matrix,
% mean(X0, 2) is taken as initial point. If X0 is a string like
% '2*rand(10,1)-1', the string is evaluated first.
%
% SIGMA is a scalar, or a column vector of size(X0,1), or a string
% that can be evaluated into one of these. SIGMA determines the
% initial coordinate wise standard deviations for the search.
% Setting SIGMA one third of the initial search region is
% appropriate, e.g., the initial point in [0, 6]^10 and SIGMA=2
% means cmaes('myfun', 3*rand(10,1), 2). If SIGMA is missing and
% size(X0,2) > 1, SIGMA is set to sqrt(var(X0')'). That is, X0 is
% used as a sample for estimating initial mean and variance of the
% search distribution.
%
% OPTS (an optional argument) is a struct holding additional input
% options. Valid field names and a short documentation can be
% discovered by looking at the default options (type 'cmaes'
% without arguments, see above). Empty or missing fields in OPTS
% invoke the default value, i.e. OPTS needs not to have all valid
% field names. Capitalization does not matter and unambiguous
% abbreviations can be used for the field names. If a string is
% given where a numerical value is needed, the string is evaluated
% by eval, where 'N' expands to the problem dimension
% (==size(X0,1)) and 'popsize' to the population size.
%
% [XMIN, FMIN, COUNTEVAL, STOPFLAG, OUT, BESTEVER] = ...
% CMAES(FITFUN, X0, SIGMA)
% returns the best (minimal) point XMIN (found in the last generation); function value FMIN of XMIN; the number of needed
% function evaluations COUNTEVAL; a STOPFLAG value as cell array, where possible entries are 'fitness', 'tolx', 'tolupx', 'tolfun',
% 'maxfunevals', 'maxiter', 'stoptoresume', 'manual', 'warnconditioncov', 'warnnoeffectcoord', 'warnnoeffectaxis',
% 'warnequalfunvals', 'warnequalfunvalhist', 'bug' (use e.g. any(strcmp(STOPFLAG, 'tolx')) or findstr(strcat(STOPFLAG,
% 'tolx')) for further processing); a record struct OUT with some more output, where the struct SOLUTIONS.BESTEVER contains the overall
% best evaluated point X with function value F evaluated at evaluation count EVALS. The last output argument BESTEVER equals
% OUT.SOLUTIONS.BESTEVER. Moreover a history of solutions and parameters is written to files according to the Log-options.
%
% A regular manual stop can be achieved via the file signals.par. The program is terminated if the first two non-white sequences in any
% line of this file are 'stop' and the value of the LogFilenamePrefix option (by default 'outcmaes'). Also a run can be skipped.
% Given, for example, 'skip outcmaes run 2', skips the second run if option Restarts is at least 2, and another run will be started.
%
% To run the code completely silently set Disp, Save, and Log options to 0. With OPTS.LogModulo > 0 (1 by default) the most important
% data are written to ASCII files permitting to investigate the results (e.g. plot with function plotcmaesdat) even while CMAES is
% still running (which can be quite useful on expensive objective functions). When OPTS.SaveVariables==1 (default) everything is saved
% in file OPTS.SaveFilename (default 'variablescmaes.mat') allowing to resume the search afterwards by using the resume option.
%
% To find the best ever evaluated point load the variables typing "es=load('variablescmaes')" and investigate the variable es.out.solutions.bestever.
%
% In case of a noisy objective function (uncertainties) set OPTS.Noise.on = 1. This option interferes presumably with some
% termination criteria, because the step-size sigma will presumably not converge to zero anymore. If CMAES was provided with a
% fifth argument (P1 in the below example, which is passed to the objective function FUN), this argument is multiplied with the
% factor given in option Noise.alphaevals, each time the detected noise exceeds a threshold. This argument can be used within
% FUN, for example, as averaging number to reduce the noise level.
%
% OPTS.DiagonalOnly > 1 defines the number of initial iterations, where the covariance matrix remains diagonal and the algorithm has
% internally linear time complexity. OPTS.DiagonalOnly = 1 means keeping the covariance matrix always diagonal and this setting
% also exhibits linear space complexity. This can be particularly useful for dimension > 100. The default is OPTS.DiagonalOnly = 0.
%
% OPTS.CMA.active = 1 turns on "active CMA" with a negative update of the covariance matrix and checks for positive definiteness.
% OPTS.CMA.active = 2 does not check for pos. def. and is numerically faster. Active CMA usually speeds up the adaptation and might
% become a default in near future.
%
% The primary strategy parameter to play with is OPTS.PopSize, which can be increased from its default value. Increasing the population
% size (by default linked to increasing parent number OPTS.ParentNumber) improves global search properties in exchange to speed. Speed
% decreases, as a rule, at most linearely with increasing population size. It is advisable to begin with the default small population
% size. The options Restarts and IncPopSize can be used for an automated multistart where the population size is increased by the
% factor IncPopSize (two by default) before each restart. X0 (given as string) is reevaluated for each restart. Stopping options
% StopFunEvals, StopIter, MaxFunEvals, and Fitness terminate the program, all others including MaxIter invoke another restart, where
% the iteration counter is reset to zero.
%
% Examples:
%
% XMIN = cmaes('myfun', 5*ones(10,1), 1.5);
%
% starts the search at 10D-point 5 and initially searches mainly
% between 5-3 and 5+3 (+- two standard deviations), but this is not
% a strict bound. 'myfun' is a name of a function that returns a
% scalar from a 10D column vector.
%
% opts.LBounds = 0; opts.UBounds = 10;
% opts.Restarts = 3; % doubles the popsize for each restart
%
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
matlab算法,工具源码,适合毕业设计、课程设计作业,所有源码均经过严格测试,可以直接运行,可以放心下载使用。 Matlab(Matrix Laboratory)是一种专为数值计算和科学与工程应用而设计的高级编程语言和环境。在算法开发和实现方面,Matlab具有以下一些好处: 1. 丰富的数学和科学函数库:Matlab提供了广泛的数学、信号处理、图像处理、优化、统计等领域的函数库,这些函数库可以帮助开发者快速实现各种复杂的数值计算算法。这些函数库提供了许多常用的算法和工具,可以大大简化算法开发的过程。 2. 易于学习和使用:Matlab具有简单易用的语法和直观的编程环境,使得算法开发者可以更快速地实现和测试他们的算法。Matlab的语法与数学表达式和矩阵操作非常相似,这使得算法的表达更加简洁、清晰。 3. 快速原型开发:Matlab提供了一个交互式的开发环境,可以快速进行算法的原型开发和测试。开发者可以实时查看和修改变量、绘制图形、调试代码等,从而加快了算法的迭代和优化过程。这种快速原型开发的特性使得算法开发者可以更快地验证和修改他们的想法。 4. 可视化和绘图功能:Matlab具有强大的可视化和绘图功能,可以帮助开发者直观地展示和分析算法的结果。开发者可以使用Matlab绘制各种图形、曲线、图像,以及创建动画和交互式界面,从而更好地理解和传达算法的工作原理和效果。 5. 并行计算和加速:Matlab提供了并行计算和加速工具,如并行计算工具箱和GPU计算功能。这些工具可以帮助开发者利用多核处理器和图形处理器(GPU)来加速算法的计算过程,提高算法的性能和效率
资源推荐
资源详情
资源评论
收起资源包目录
使用值函数迭代的宏观经济模型的Matlab工具包.zip (761个子文件)
.directory 121B
.directory 121B
.directory 121B
.directory 121B
.directory 121B
.directory 120B
LICENSE 34KB
LICENSE 1KB
cmaes_vfitoolkit.m 119KB
CreateReturnFnMatrix_Case1_Disc_Par2e.m 101KB
CreateReturnFnMatrix_Case1_ExpAsset_Disc_Par2e.m 90KB
LifeCycleProfiles_FHorz_Case2_PType.m 86KB
EvalFnOnAgentDist_Grid_Case1e.m 74KB
CreateReturnFnMatrix_Case2_Disc_Par2e.m 70KB
CreateReturnFnMatrix_Case1_Disc_Par2_fastOLGe.m 63KB
ValueFnIter_Case2_FHorz_QuasiHyperbolic_raw.m 57KB
ValueFnIter_Case2_FHorz_AgeDepGrids_Dynasty_Par2_raw.m 49KB
EvalFnOnAgentDist_Grid_Case1_SDP.m 47KB
CreateReturnFnMatrix_Case1_Disc_Par2_SDP.m 46KB
ValueFnIter_Case1_FHorz.m 42KB
CreateReturnFnMatrix_Case1_ResidAsset_Disc_Par2.m 40KB
TransitionPath_Case1_EntryExit_shooting.m 40KB
EstimateModel.m 39KB
ValueFnIter_Case2_FHorz_AgeDepGrids_Par2_raw.m 39KB
EvalFnOnAgentDist_Grid_J.m 39KB
TransitionPath_Case1_EntryExit_no_d_shooting.m 38KB
TransitionPath_Case1_EntryExit_subfn.m 37KB
LifeCycleProfiles_FHorz_Case1_PType.m 36KB
TransitionPath_Case1_FHorz.m 36KB
TransitionPath_Case1_FHorz_PType.m 36KB
ValueFnIter_Case2_FHorz_nphi_Dynasty_Par2_raw.m 34KB
CreateReturnFnMatrix_Case1_Disc_Par2_LowMem2.m 34KB
ValueFnIter_Case3_FHorz_EpsteinZin_raw.m 34KB
CreatePhiaprimeMatrix_Case2_Disc_Par2.m 34KB
TransitionPath_Case1_EntryExit_no_d_subfn.m 33KB
ValueFnIter_Case1.m 33KB
ValueFnOnTransPath_Case1_FHorz.m 33KB
ValueFnIter_Case2_FHorz_Dynasty_Par2_raw.m 33KB
ValueFnIter_FHorz_RiskyAsset_EpsteinZin_raw.m 32KB
ValueFnIter_Case2_FHorz_Par2_raw.m 31KB
TransitionPath_Case1_PType.m 31KB
ValueFnIter_Case3_FHorz_EpsteinZin_e_raw.m 30KB
ValueFnIter_FHorz_RiskyAsset_EpsteinZin_noa1_raw.m 30KB
HeteroAgentStationaryEqm_Case1_FHorz_PType.m 30KB
AgentDistOnTransPath_Case1_FHorz.m 27KB
LifeCycleProfiles_FHorz_Case1.m 27KB
ValueFnIter_FHorz_RiskyAsset_EpsteinZin_e_raw.m 27KB
HeteroAgentStationaryEqm_Case1_PType.m 26KB
ValueFnIter_FHorz_RiskyAsset_EpsteinZin_noa1_e_raw.m 26KB
ValueFnIter_Case1_EndoType_TPath_SingleStep_Refine2_raw.m 25KB
StationaryDist_FHorz_Case2_3_Iteration_e_raw.m 25KB
ValueFnIter_Case1_EndoType_Refine2.m 25KB
TransitionPath_Case1_FHorz_e_shooting.m 25KB
EvalFnOnAgentDist_AggVars_Case1.m 25KB
getIMFData.m 25KB
TransitionPath_Case1_EntryExit_no_d.m 25KB
LifeCycleProfiles_FHorz_Case2_AgeDepGrids.m 24KB
TransitionPath_Case2.m 24KB
EstimateModel_DistanceFn.m 24KB
getHDRData.m 24KB
TransitionPath_Case1_FHorz_e_shooting_fastOLG.m 24KB
HeteroAgentStationaryEqm_PType.m 24KB
CreateReturnFnMatrix_Case1_Disc_DC1_Par2e.m 24KB
TransitionPath_Case1_FHorz_shooting.m 24KB
TransitionPath_Case1_FHorz_shooting_fastOLG.m 23KB
ValueFnIter_Case2_FHorz_raw.m 23KB
ValueFnIter_Case1_FHorz_QuasiHyperbolic_e_raw.m 22KB
ValueFnIter_Case1_FHorz_QuasiHyperbolic_raw.m 22KB
CalibrateLifeCycleModel_PType.m 22KB
ValueFnIter_Case1_Refine2.m 22KB
TransitionPath_Case1_lowmem.m 22KB
EvalFnOnTransPath_AggVars_Case1_FHorz.m 22KB
ValueFnIter_Case1_FHorz_QuasiHyperbolic_nod_e_raw.m 22KB
EvalFnOnAgentDist_Grid.m 22KB
TransitionPath_Case1_shooting_endotype.m 22KB
TransitionPath_Case1_FHorz_StockVar_shooting.m 21KB
TransitionPath_Case1_FHorz_StockVar_shooting_fastOLG.m 21KB
CreaterprimePolicyResidualAsset_Case1.m 21KB
TransitionPath_Case1_FHorz_shooting_noz.m 21KB
SimPanelValues_Case1.m 21KB
TransitionPath_Case1_shooting.m 21KB
ValueFnIter_Case1_FHorz_QuasiHyperbolic_nod_raw.m 21KB
StationaryDist_FHorz_Case2_AgeDepGrids_Dynasty_Iteration_raw.m 21KB
ValueFnIter_Case2_FHorz_Dynasty_raw.m 21KB
EvalFnOnAgentDist_AllStats_FHorz_Case1_PType.m 20KB
LifeCycleProfiles_FHorz_Case2.m 20KB
TransitionPath_Case1_no_d_lowmem.m 20KB
EvalFnOnAgentDist_Grid_Case1_withV.m 20KB
EvalFnOnTransPath_AggVars_Case1_FHorz_Direct.m 20KB
LifeCycleProfiles_FHorz_Case1_noz.m 20KB
EvalFnOnAgentDist_AggVars_FHorz_Case1_FieldExp_PType.m 20KB
EvalFnOnAgentDist_Grid_fastOLG.m 20KB
EvalFnOnAgentDist_Grid_Case1.m 20KB
ValueFnIter_Case3_FHorz_raw.m 20KB
StationaryDist_FHorz_Case2_AgeDepGrids_DynastyStoreP_Iter_raw.m 20KB
CreateExperienceAssetuFnMatrix_Case1.m 20KB
CreateReturnFnMatrix_Case1_Disc_Par2.m 20KB
TransitionPath_Case1_FHorz_shooting_fastOLG_noz.m 19KB
ValueFnIter_Case1_FHorz_EpsteinZin_raw.m 19KB
EvalFnOnTransPath_AggVars_Case2.m 19KB
共 761 条
- 1
- 2
- 3
- 4
- 5
- 6
- 8
资源评论
若明天不见
- 粉丝: 1w+
- 资源: 273
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功