From c4998f93d398142084df71b4fdeab6a0c821f2a8 Mon Sep 17 00:00:00 2001 From: Johannes Pfeifer Date: Mon, 24 Jun 2013 22:52:10 +0200 Subject: [PATCH] Transfer hardcoded osr options to options structure Implements #423. To be done: add preprocessor options for tolf and maxit. --- doc/dynare.texi | 16 +++++++++++++--- matlab/global_initialization.m | 5 +++++ matlab/osr1.m | 6 +++--- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/doc/dynare.texi b/doc/dynare.texi index f03665332..4318a33db 100644 --- a/doc/dynare.texi +++ b/doc/dynare.texi @@ -5521,12 +5521,22 @@ The parameters to be optimized must be listed with @code{osr_params}. The quadratic objectives must be listed with @code{optim_weights}. -This problem is solved using a numerical optimizer. +This problem is solved using the numerical optimizer @code{csminwel} of Chris Sims. @optionshead -This command accept the same options than @code{stoch_simul} -(@pxref{Computing the stochastic solution}). +This command accepts the same options as @code{stoch_simul} +(@pxref{Computing the stochastic solution}) plus + +@table @code + +@item maxit = = @var{INTEGER} +Determines the maximum number of iterations used in the non-linear solver. Default: @code{1000} + +@item tolf = = @var{DOUBLE} +Convergence criterion for termination based on the function value. Iteration will +cease when it proves impossible to improve the function value by more than tolf. Default: @code{1e-7} +@end table The value of the objective is stored in the variable @code{oo_.osr.objective_function}, which is described below. diff --git a/matlab/global_initialization.m b/matlab/global_initialization.m index 177482ef9..3b497efb2 100644 --- a/matlab/global_initialization.m +++ b/matlab/global_initialization.m @@ -565,6 +565,11 @@ options_.risky_steadystate = 0; options_.endogenous_prior = 0; options_.endogenous_prior_restrictions.irf={}; +% OSR Optimal Simple Rules +options_.osr.tolf=1e-7; +options_.osr.maxit=1000; +options_.osr.verbose=2; + % use GPU options_.gpu = 0; diff --git a/matlab/osr1.m b/matlab/osr1.m index 822ae69ac..601355f7c 100644 --- a/matlab/osr1.m +++ b/matlab/osr1.m @@ -48,9 +48,9 @@ t0 = M_.params(i_params); inv_order_var = oo_.dr.inv_order_var; H0 = 1e-4*eye(np); -crit = 1e-7; -nit = 1000; -verbose = 2; +crit=options_.osr.tolf; +nit=options_.osr.maxit; +verbose=options_.osr.verbose; [f,p]=csminwel1('osr_obj',t0,H0,[],crit,nit,options_.gradient_method,options_.gradient_epsilon,i_params,... inv_order_var(i_var),weights(i_var,i_var));