From 8dadd1519edb503f71f1f795cd799e06f6b86a52 Mon Sep 17 00:00:00 2001 From: Johannes Pfeifer Date: Fri, 22 Jul 2016 08:58:46 +0200 Subject: [PATCH] Restore backward compatibility of OSR command with maxit and tolf options Translates these options into optim_opt structure --- doc/dynare.texi | 9 +++++++++ matlab/osr1.m | 21 +++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/doc/dynare.texi b/doc/dynare.texi index 329716516..974f5ab90 100644 --- a/doc/dynare.texi +++ b/doc/dynare.texi @@ -7452,6 +7452,15 @@ Specifies the optimizer for minimizing the objective function. The same solvers @item optim = (@var{NAME}, @var{VALUE}, ...) A list of @var{NAME} and @var{VALUE} pairs. Can be used to set options for the optimization routines. The set of available options depends on the selected optimization routine (i.e. on the value of option @ref{opt_algo}). @xref{optim}. +@item maxit = @var{INTEGER} +Determines the maximum number of iterations used in @code{opt_algo=4}. This option is now deprecated and will be +removed in a future release of Dynare. Use @code{optim} instead to set optimizer-specific values. Default: @code{1000} + +@item tolf = @var{DOUBLE} +Convergence criterion for termination based on the function value used in @code{opt_algo=4}. Iteration will cease when it proves impossible to +improve the function value by more than tolf. This option is now deprecated and will be +removed in a future release of Dynare. Use @code{optim} instead to set optimizer-specific values. Default: @code{e-7} + @item silent_optimizer @pxref{silent_optimizer} diff --git a/matlab/osr1.m b/matlab/osr1.m index 51fd5475f..641e5fda9 100644 --- a/matlab/osr1.m +++ b/matlab/osr1.m @@ -62,6 +62,27 @@ if any(isnan(M_.params(i_params))) error ('OSR: At least one of the initial parameter values for osr_params is NaN') ; end +%restore backward compatibility with maxit and tolf +if isfield(options_.osr,'maxit') || isfield(options_.osr,'tolf') + warning('OSR: The use of maxit and tolf is now deprecated. Please use the optim-option instead.') + if options_.osr.opt_algo~=4 + error ('OSR: The maxit and tolf options are not supported when not using the default opt_algo=4. Use the optim-option instead.') ; + else + if isfield(options_.osr,'maxit') + if ~isempty(options_.optim_opt) + options_.optim_opt=[options_.optim_opt,',']; + end + options_.optim_opt=[options_.optim_opt,'''MaxIter'',',num2str(options_.osr.maxit),'']; + end + if isfield(options_.osr,'tolf') + if ~isempty(options_.optim_opt) + options_.optim_opt=[options_.optim_opt,',']; + end + options_.optim_opt=[options_.optim_opt,'''TolFun'',',num2str(options_.osr.tolf),'']; + end + end +end + exe =zeros(M_.exo_nbr,1); oo_.dr = set_state_space(oo_.dr,M_,options_);