check_posterior_sampler_options: make global variable an input

Does not properly work for scale_file-option as caller has variable not global
trustregion
Johannes Pfeifer 2022-02-02 16:20:12 +01:00
parent e1d0ce28d2
commit 217de5084c
3 changed files with 9 additions and 7 deletions

View File

@ -1,19 +1,23 @@
function [posterior_sampler_options, options_] = check_posterior_sampler_options(posterior_sampler_options, options_, bounds)
function [posterior_sampler_options, options_, bayestopt_] = check_posterior_sampler_options(posterior_sampler_options, options_, bounds, bayestopt_)
% function [posterior_sampler_options, options_] = check_posterior_sampler_options(posterior_sampler_options, options_, bounds)
% function [posterior_sampler_options, options_, bayestopt_] = check_posterior_sampler_options(posterior_sampler_options, options_, bounds, bayestopt_)
% initialization of posterior samplers
%
% INPUTS
% posterior_sampler_options: posterior sampler options
% options_: structure storing the options
% bounds: structure containing prior bounds
% bayestopt_: structure storing information about priors
% OUTPUTS
% posterior_sampler_options: checked posterior sampler options
% options_: structure storing the options
% bayestopt_: structure storing information about priors
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2015-2017 Dynare Team
% Copyright (C) 2015-2022 Dynare Team
%
% This file is part of Dynare.
%
@ -86,7 +90,6 @@ if init
% will overwrite jscale from set_prior.m
if exist(options_list{i,2},'file') || exist([options_list{i,2},'.mat'],'file')
tmp = load(options_list{i,2},'Scale');
global bayestopt_
bayestopt_.mh_jscale = tmp.Scale;
options_.mh_jscale = tmp.Scale;
bayestopt_.jscale = ones(size(bounds.lb,1),1)*tmp.Scale;
@ -152,7 +155,6 @@ if init
% will overwrite jscale from set_prior.m
if exist(options_list{i,2},'file') || exist([options_list{i,2},'.mat'],'file')
tmp = load(options_list{i,2},'Scale');
global bayestopt_
bayestopt_.mh_jscale = tmp.Scale;
options_.mh_jscale = tmp.Scale;
bayestopt_.jscale = ones(size(bounds.lb,1),1)*tmp.Scale;

View File

@ -465,7 +465,7 @@ if (any(bayestopt_.pshape >0 ) && options_.mh_replic) || ...
if options_.mh_replic || options_.load_mh_file
posterior_sampler_options = options_.posterior_sampler_options.current_options;
posterior_sampler_options.invhess = invhess;
[posterior_sampler_options, options_] = check_posterior_sampler_options(posterior_sampler_options, options_);
[posterior_sampler_options, options_, bayestopt_] = check_posterior_sampler_options(posterior_sampler_options, options_, bounds, bayestopt_);
% store current options in global
options_.posterior_sampler_options.current_options = posterior_sampler_options;
if options_.mh_replic

View File

@ -649,7 +649,7 @@ if options_.load_results_after_load_mh
end
if options_.mh_replic || options_.load_mh_file
[current_options, options_] = check_posterior_sampler_options([], options_, bounds);
[current_options, options_, bayestopt_] = check_posterior_sampler_options([], options_, bounds, bayestopt_);
options_.posterior_sampler_options.current_options = current_options;
end