From 835cba484f5059e647edd38146fa9db982fc21c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org> Date: Mon, 7 Jan 2013 14:51:45 +0100 Subject: [PATCH] Document when mode_compute={1,3,7} are available, and error with an informative message if not (cherry picked from commit 8c7e3d46ed184f774af713fcfac2b3de28e1404a) --- doc/dynare.texi | 10 +++++++--- matlab/dynare_estimation_1.m | 20 +++++++++++++++++++- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/doc/dynare.texi b/doc/dynare.texi index a935e677c..8c9837e8a 100644 --- a/doc/dynare.texi +++ b/doc/dynare.texi @@ -59,7 +59,7 @@ @c %**end of header @copying -Copyright @copyright{} 1996-2012, Dynare Team. +Copyright @copyright{} 1996-2013, Dynare Team. @quotation Permission is granted to copy, distribute and/or modify this document @@ -4039,13 +4039,17 @@ but the @code{smoother} option is used, it is a roundabout way to compute the smoothed value of the variables of a model with calibrated parameters. @item 1 -Uses @code{fmincon} optimization routine (not available under Octave) +Uses @code{fmincon} optimization routine (available under MATLAB if +the optimization toolbox is installed; not available under Octave) @item 2 Value no longer used @item 3 -Uses @code{fminunc} optimization routine +Uses @code{fminunc} optimization routine (available under MATLAB if +the optimization toolbox is installed; available under Octave if the +@uref{http://octave.sourceforge.net/optim/,optim} package from +Octave-Forge is installed) @item 4 Uses Chris Sims's @code{csminwel} diff --git a/matlab/dynare_estimation_1.m b/matlab/dynare_estimation_1.m index fdcda8009..6fbf06caa 100644 --- a/matlab/dynare_estimation_1.m +++ b/matlab/dynare_estimation_1.m @@ -12,7 +12,7 @@ function dynare_estimation_1(var_list_,dname) % SPECIAL REQUIREMENTS % none -% Copyright (C) 2003-2012 Dynare Team +% Copyright (C) 2003-2013 Dynare Team % % This file is part of Dynare. % @@ -189,6 +189,12 @@ end if ~isequal(options_.mode_compute,0) && ~options_.mh_posterior_mode_estimation switch options_.mode_compute case 1 + if exist('OCTAVE_VERSION') + error('Option mode_compute=1 is not available under Octave') + elseif ~user_has_matlab_license('optimization_toolbox') + error('Option mode_compute=1 requires the Optimization Toolbox') + end + optim_options = optimset('display','iter','LargeScale','off', ... 'MaxFunEvals',100000,'TolFun',1e-8,'TolX',1e-6); if isfield(options_,'optim_opt') @@ -202,6 +208,12 @@ if ~isequal(options_.mode_compute,0) && ~options_.mh_posterior_mode_estimation case 2 error('ESTIMATION: mode_compute=2 option (Lester Ingber''s Adaptive Simulated Annealing) is no longer available') case 3 + if exist('OCTAVE_VERSION') && ~user_has_octave_forge_package('optim') + error('Option mode_compute=3 requires the optim package') + elseif ~exist('OCTAVE_VERSION') && ~user_has_matlab_license('optimization_toolbox') + error('Option mode_compute=3 requires the Optimization Toolbox') + end + optim_options = optimset('display','iter','MaxFunEvals',100000,'TolFun',1e-8,'TolX',1e-6); if isfield(options_,'optim_opt') eval(['optim_options = optimset(optim_options,' options_.optim_opt ');']); @@ -326,6 +338,12 @@ if ~isequal(options_.mode_compute,0) && ~options_.mh_posterior_mode_estimation end case 7 % Matlab's simplex (Optimization toolbox needed). + if exist('OCTAVE_VERSION') && ~user_has_octave_forge_package('optim') + error('Option mode_compute=7 requires the optim package') + elseif ~exist('OCTAVE_VERSION') && ~user_has_matlab_license('optimization_toolbox') + error('Option mode_compute=7 requires the Optimization Toolbox') + end + optim_options = optimset('display','iter','MaxFunEvals',1000000,'MaxIter',6000,'TolFun',1e-8,'TolX',1e-6); if isfield(options_,'optim_opt') eval(['optim_options = optimset(optim_options,' options_.optim_opt ');']); -- GitLab