Make simplex_optimization_routine.m usable outside of estimation

Removes hard-coded parameter names extracted from bayestopt_ by handing them over explicitly
time-shift
Johannes Pfeifer 2014-11-10 19:47:59 +01:00
parent c3467ddca2
commit 7c59edead2
2 changed files with 8 additions and 6 deletions

View File

@ -519,7 +519,7 @@ if ~isequal(options_.mode_compute,0) && ~options_.mh_posterior_mode_estimation
end
end
end
[xparam1,fval,exitflag] = simplex_optimization_routine(objective_function,xparam1,simplexOptions,dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,bounds,oo_);
[xparam1,fval,exitflag] = simplex_optimization_routine(objective_function,xparam1,simplexOptions,bayestopt_.name,dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,bounds,oo_);
case 9
% Set defaults
H0 = 1e-4*ones(nx,1);

View File

@ -1,4 +1,4 @@
function [x,fval,exitflag] = simplex_optimization_routine(objective_function,x,options,varargin)
function [x,fval,exitflag] = simplex_optimization_routine(objective_function,x,options,var_names,varargin)
% Nelder-Mead like optimization routine (see http://en.wikipedia.org/wiki/Nelder-Mead_method)
%
@ -11,6 +11,8 @@ function [x,fval,exitflag] = simplex_optimization_routine(objective_function,x,o
% o objective_function [string] Name of the objective function to be minimized.
% o x [double] n*1 vector, starting guess of the optimization routine.
% o options [structure] Options of this implementation of the simplex algorithm.
% o var_names [cell] Names of parameters
% for verbose output
% o varargin [cell of structures] Structures to be passed to the objective function.
%
% varargin{1} --> DynareDataset
@ -194,7 +196,7 @@ else
disp(['Current parameter values: '])
fprintf(1,'%s: \t\t\t %s \t\t\t %s \t\t\t %s \t\t\t %s \t\t\t %s \n','Names','Best point', 'Worst point', 'Mean values', 'Min values', 'Max values');
for i=1:number_of_variables
fprintf(1,'%s: \t\t\t %+8.6f \t\t\t %+8.6f \t\t\t %+8.6f \t\t\t %+8.6f \t\t\t %+8.6f \n',varargin{6}.name{i},v(i,1), v(i,end), mean(v(i,:),2), min(v(i,:),[],2), max(v(i,:),[],2));
fprintf(1,'%s: \t\t\t %+8.6f \t\t\t %+8.6f \t\t\t %+8.6f \t\t\t %+8.6f \t\t\t %+8.6f \n',var_names{i},v(i,1), v(i,end), mean(v(i,:),2), min(v(i,:),[],2), max(v(i,:),[],2));
end
skipline()
end
@ -406,7 +408,7 @@ while (func_count < max_func_calls) && (iter_count < max_iterations) && (simplex
disp(['Current parameter values: '])
fprintf(1,'%s: \t\t\t %s \t\t\t %s \t\t\t %s \t\t\t %s \t\t\t %s \n','Names','Best point', 'Worst point', 'Mean values', 'Min values', 'Max values');
for i=1:number_of_variables
fprintf(1,'%s: \t\t\t %+8.6f \t\t\t %+8.6f \t\t\t %+8.6f \t\t\t %+8.6f \t\t\t %+8.6f \n',varargin{6}.name{i}, v(i,1), v(i,end), mean(v(i,:),2), min(v(i,:),[],2), max(v(i,:),[],2));
fprintf(1,'%s: \t\t\t %+8.6f \t\t\t %+8.6f \t\t\t %+8.6f \t\t\t %+8.6f \t\t\t %+8.6f \n',var_names{i}, v(i,1), v(i,end), mean(v(i,:),2), min(v(i,:),[],2), max(v(i,:),[],2));
end
skipline()
end
@ -432,7 +434,7 @@ while (func_count < max_func_calls) && (iter_count < max_iterations) && (simplex
disp(['values for the control variables. '])
disp(['New value of delta (size of the new simplex) is: '])
for i=1:number_of_variables
fprintf(1,'%s: \t\t\t %+8.6f \n',varargin{6}.name{i}, delta(i));
fprintf(1,'%s: \t\t\t %+8.6f \n',var_names{i}, delta(i));
end
end
% Reset counters
@ -479,7 +481,7 @@ while (func_count < max_func_calls) && (iter_count < max_iterations) && (simplex
disp(['values for the control variables. '])
disp(['New value of delta (size of the new simplex) is: '])
for i=1:number_of_variables
fprintf(1,'%s: \t\t\t %+8.6f \n',varargin{6}.name{i}, delta(i));
fprintf(1,'%s: \t\t\t %+8.6f \n',var_names{i}, delta(i));
end
end
% Reset counters