Rewrote the portion of code requesting a user input when non linear filters are used with a gradient based optimization routine.

Closes issues #442 and #443.
time-shift
Stéphane Adjemian (Charybdis) 2013-07-10 16:03:49 +02:00
parent aeda8d17ff
commit 2fae989131
1 changed files with 16 additions and 18 deletions

View File

@ -37,27 +37,25 @@ if options_.order > 1
disp(' ')
disp('Estimation using a non linear filter!')
disp(' ')
if ismember(options_.mode_compute,[1,3,4]) %gradient-based optimizers
warning('You are using a gradient-based mode-finder. Particle filtering introduces discontinuities in the objective function w.r.t the parameters. Thus, should use a non-gradient based optimizer (e.g. mode_compute=8 or 9)!')
if ~options_.nointeractive && ismember(options_.mode_compute,[1,3,4]) % Known gradient-based optimizers
warning('You are using a gradient-based mode-finder. Particle filtering introduces discontinuities in the objective function w.r.t the parameters. Thus, should use a non-gradient based optimizer.')
fprintf('\nPlease choose a mode-finder:\n')
fprintf('\t 1 - Continue using gradient-based method (not recommended)\n')
fprintf('\t 0 - Continue using gradient-based method (it is most likely that you will no get any sensible result).\n')
fprintf('\t 6 - Monte Carlo based algorithm\n')
fprintf('\t 8 - Nelder-Mead simplex based optimization routine\n')
fprintf('\t 7 - Nelder-Mead simplex based optimization routine (Matlab optimization toolbox required)\n')
fprintf('\t 8 - Nelder-Mead simplex based optimization routine (Dynare''s implementation)\n')
fprintf('\t 9 - CMA-ES (Covariance Matrix Adaptation Evolution Strategy) algorithm\n')
reply = input('Please enter your choice: ', 's');
try
mode_finder=str2double(reply(1,1));
invalid_choice_dummy=0;
catch err_menu
invalid_choice_dummy=1;
end
if ~invalid_choice_dummy && ismember(mode_finder,[6,8,9])
options_.mode_compute=mode_finder;
elseif ~invalid_choice_dummy && mode_finder==1
% keep mode finder, i.e. do nothing
else
fprintf('\n Invalid choice, continue using Nelder-Mead simplex based optimization routine.\n')
options_.mode_compute=8;
choice = [];
while isempty(choice)
choice = input('Please enter your choice: ');
if isnumeric(choice) && isint(choice) && ismember(choice,[0 6 7 8 9])
if choice
options_.mode_compute = choice;
end
else
fprintf('\nThis is an invalid choice (you have to choose between 0, 6, 7, 8 and 9).\n')
choice = [];
end
end
end
elseif options_.particle.status && options_.order>2