From 03563e012b9a95cabad000e342842ea86cd62e19 Mon Sep 17 00:00:00 2001 From: Johannes Pfeifer Date: Fri, 20 May 2016 20:02:06 +0200 Subject: [PATCH] Allow for pass OSR parameter bounds to optimizer --- doc/dynare.texi | 32 +++++++++++++++++++++++++++++++- matlab/osr1.m | 8 +++++++- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/doc/dynare.texi b/doc/dynare.texi index cc2427546..42e8a4593 100644 --- a/doc/dynare.texi +++ b/doc/dynare.texi @@ -665,7 +665,7 @@ Dynare unusable. In order to give instructions to Dynare, the user has to write a @emph{model file} whose filename extension must be @file{.mod}. This file contains the description of the model and the computing tasks -required by the user. Its contents is described in @ref{The Model file}. +required by the user. Its contents are described in @ref{The Model file}. @menu * Dynare invocation:: @@ -7365,6 +7365,36 @@ osr_params gammax0 gammac0 gamma_y_ gamma_inf_; osr y; @end example + +@anchor{osr_params_bounds} +@deffn Block osr_params_bounds ; + +This block declares lower and upper bounds for parameters in the optimal simple rule. If not specified +the optimization is unconstrained. + +Each line has the following syntax: + +@example +PARAMETER_NAME, LOWER_BOUND, UPPER_BOUND; +@end example + +Note that the use of this block requires the use of a constrained optimizer, i.e. setting @ref{opt_algo} to +1,2,5, or 9. + +@examplehead + +@example + +osr_param_bounds; +gamma_inf_, 0, 2.5; +end; + +osr(solve_algo=9) y; +@end example + +@end deffn + + @defvr {MATLAB/Octave variable} oo_.osr.objective_function After an execution of the @code{osr} command, this variable contains the value of the objective under optimal policy. diff --git a/matlab/osr1.m b/matlab/osr1.m index a96c618fb..d5070cdbb 100644 --- a/matlab/osr1.m +++ b/matlab/osr1.m @@ -97,9 +97,15 @@ elseif isequal(options_.osr.opt_algo,6) error('OSR: OSR does not support opt_algo=6.') elseif isequal(options_.osr.opt_algo,10) error('OSR: OSR does not support opt_algo=10.') +elseif isequal(options_.osr.opt_algo,11) + error('OSR: OSR does not support opt_algo=11.') else + +if ~isempty(M_.osr.param_bounds) && ~(ismember(options_.osr.opt_algo,[1,2,5,9]) || ischar(options_.osr.opt_algo)) + error('OSR: OSR with bounds on parameters requires a constrained optimizer, i.e. 1,2,5, or 9.') +end %%do actual optimization -[p, f, exitflag] = dynare_minimize_objective(str2func('osr_obj'),t0,options_.osr.opt_algo,options_,[],cellstr(M_.param_names(i_params,:)),[],[], i_params,... +[p, f, exitflag] = dynare_minimize_objective(str2func('osr_obj'),t0,options_.osr.opt_algo,options_,M_.osr.param_bounds,cellstr(M_.param_names(i_params,:)),[],[], i_params,... inv_order_var(i_var),weights(i_var,i_var)); end