Merge branch 'master' into particle_mode_compute

time-shift
Stéphane Adjemian (Charybdis) 2013-07-10 16:04:19 +02:00
commit ab00257c3b
12 changed files with 116 additions and 48 deletions

View File

@ -743,6 +743,13 @@ Activate console mode. In addition to the behavior of
@code{nodisplay}, Dynare will not use graphical waitbars for long
computations.
@item nograph
Activate the @code{nograph} option (@xref{nograph}), so that Dynare will not produce any
graph
@item nointeractive
Instructs Dynare to not request user input
@item cygwin
Tells Dynare that your MATLAB is configured for compiling MEX files with
Cygwin (@pxref{Software requirements}). This option is only available

View File

@ -93,30 +93,35 @@ if isempty(varlist)
string = [ cas , ' will be computed for the ' num2str(M_.endo_nbr) ' endogenous variables'];
string = [ string ' of your model, this can be very long....'];
format_text(string, 10)
choice = [];
while isempty(choice)
disp(' ')
disp(' ')
disp('Choose one of the following options:')
disp(' ')
disp(' [1] Consider all the endogenous variables.')
disp(' [2] Consider all the observed endogenous variables.')
disp(' [3] Stop Dynare and change the mod file.')
disp(' ')
choice = input('options [default is 1] = ');
if isempty(choice)
choice=1;
end
if choice==1
varlist = M_.endo_names(1:M_.orig_endo_nbr, :);
elseif choice==2
varlist = options_.varobs;
elseif choice==3
varlist = NaN;
else
disp('')
disp('YOU HAVE TO ANSWER 1, 2 or 3!')
disp('')
if options_.nointeractive
% Default behaviour is to consider all the endogenous variables.
varlist = M_.endo_names(1:M_.orig_endo_nbr, :);
else
choice = [];
while isempty(choice)
disp(' ')
disp(' ')
disp('Choose one of the following options:')
disp(' ')
disp(' [1] Consider all the endogenous variables.')
disp(' [2] Consider all the observed endogenous variables.')
disp(' [3] Stop Dynare and change the mod file.')
disp(' ')
choice = input('options [default is 1] = ');
if isempty(choice)
choice=1;
end
if choice==1
varlist = M_.endo_names(1:M_.orig_endo_nbr, :);
elseif choice==2
varlist = options_.varobs;
elseif choice==3
varlist = NaN;
else
disp('')
disp('YOU HAVE TO ANSWER 1, 2 or 3!')
disp('')
end
end
end
end

View File

@ -182,7 +182,7 @@ function [resid,dr] = risky_residuals(ys,pm,M,dr,options,oo)
pm = model_structure(M,options);
[dr,info] = dyn_first_order_solver(d1,M,dr,options,0);
if info
print_info();
print_info(info,options.noprint,options);
end
dr = dyn_second_order_solver(d1,d2,dr,M,...
options.threads.kronecker.A_times_B_kronecker_C,...

View File

@ -107,6 +107,9 @@ gmhmaxlik.nclimb = 200000;
gmhmaxlik.nscale = 200000;
options_.gmhmaxlik = gmhmaxlik;
% Request user input.
options_.nointeractive = 0;
% Graphics
options_.graphics.nrows = 3;
options_.graphics.ncols = 3;

View File

@ -127,9 +127,15 @@ if ~options_.load_mh_file && ~options_.mh_recover
init_iter = init_iter + 1;
if init_iter > 100 && validate == 0
disp(['MH: I couldn''t get a valid initial value in 100 trials.'])
disp(['MH: You should Reduce mh_init_scale...'])
disp(sprintf('MH: Parameter mh_init_scale is equal to %f.',options_.mh_init_scale))
options_.mh_init_scale = input('MH: Enter a new value... ');
if options_.nointeractive
disp(['MH: I reduce mh_init_scale by ten percent:'])
options_.mh_init_scale = .9*options_.mh_init_scale;
disp(sprintf('MH: Parameter mh_init_scale is now equal to %f.',options_.mh_init_scale))
else
disp(['MH: You should Reduce mh_init_scale...'])
disp(sprintf('MH: Parameter mh_init_scale is equal to %f.',options_.mh_init_scale))
options_.mh_init_scale = input('MH: Enter a new value... ');
end
trial = trial+1;
end
end

View File

@ -1,4 +1,4 @@
Xfunction [x,fval,exitflag] = simplex_optimization_routine(objective_function,x,options,varargin)
function [x,fval,exitflag] = simplex_optimization_routine(objective_function,x,options,varargin)
% Nelder-Mead like optimization routine.
% By default, we use standard values for the reflection, the expansion, the contraction and the shrink coefficients (alpha = 1, chi = 2, psi = 1 / 2 and σ = 1 / 2).
% See http://en.wikipedia.org/wiki/Nelder-Mead_method
@ -9,7 +9,7 @@ Xfunction [x,fval,exitflag] = simplex_optimization_routine(objective_function,x,
% amelioration is possible.
%
% INPUTS
% objective_function [string] Name of the iobjective function to be minimized.
% objective_function [string] Name of the objective function to be minimized.
% x [double] n*1 vector, starting guess of the optimization routine.
% options [structure]
%
@ -17,7 +17,7 @@ Xfunction [x,fval,exitflag] = simplex_optimization_routine(objective_function,x,
%
%
% Copyright (C) 2010-2012 Dynare Team
% Copyright (C) 2010-2013 Dynare Team
%
% This file is part of Dynare.
%
@ -178,7 +178,7 @@ initial_point = x;
if ~nopenalty
error('simplex_optimization_routine:: Initial condition is wrong!')
else
[v,fv,delta] = simplex_initialization(objective_function,initial_point,initial_score,delta,1,varargin{:});
[v,fv,delta] = simplex_initialization(objective_function,initial_point,initial_score,delta,zero_delta,1,varargin{:});
func_count = number_of_variables + 1;
iter_count = 1;
if verbose
@ -420,7 +420,7 @@ while (func_count < max_func_calls) && (iter_count < max_iterations) && (simplex
% Compute the size of the simplex
delta = delta*1.05;
% Compute the new initial simplex.
[v,fv,delta] = simplex_initialization(objective_function,best_point,best_point_score,delta,1,varargin{:});
[v,fv,delta] = simplex_initialization(objective_function,best_point,best_point_score,delta,zero_delta,1,varargin{:});
if verbose
disp(['(Re)Start with a lager simplex around the based on the best current '])
disp(['values for the control variables. '])
@ -441,7 +441,7 @@ while (func_count < max_func_calls) && (iter_count < max_iterations) && (simplex
end
end
if ((func_count==max_func_calls) || (iter_count==max_iterations) || (iter_no_improvement_break==max_no_improvement_break) || convergence || tooslow)
[v,fv,delta] = simplex_initialization(objective_function,best_point,best_point_score,DELTA,1,varargin{:});
[v,fv,delta] = simplex_initialization(objective_function,best_point,best_point_score,DELTA,zero_delta,1,varargin{:});
if func_count==max_func_calls
if verbose
disp(['MAXIMUM NUMBER OF OBJECTIVE FUNCTION CALLS EXCEEDED (' int2str(max_func_calls) ')!'])
@ -468,7 +468,7 @@ while (func_count < max_func_calls) && (iter_count < max_iterations) && (simplex
% Compute the size of the simplex
delta = delta*1.05;
% Compute the new initial simplex.
[v,fv,delta] = simplex_initialization(objective_function,best_point,best_point_score,delta,1,varargin{:});
[v,fv,delta] = simplex_initialization(objective_function,best_point,best_point_score,delta,zero_delta,1,varargin{:});
if verbose
disp(['(Re)Start with a lager simplex around the based on the best current '])
disp(['values for the control variables. '])
@ -511,7 +511,7 @@ end
function [v,fv,delta] = simplex_initialization(objective_function,point,point_score,delta,check_delta,varargin)
function [v,fv,delta] = simplex_initialization(objective_function,point,point_score,delta,zero_delta,check_delta,varargin)
n = length(point);
v = zeros(n,n+1);
v(:,1) = point;

View File

@ -0,0 +1,34 @@
function skipline(n,fid)
% Copyright (C) 2013 Dynare Team
%
% This file is part of Dynare.
%
% Dynare is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% Dynare is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
if nargin<2
fid = 1;
end
if nargin<1
fid = 1;
end
if ~nargin || isequal(n,1)
fprintf(fid,'\n');
else
for i=1:n
fprintf(fid,'\n');
end
end

View File

@ -49,17 +49,17 @@ gitlastcommithash = reportfilecontent.gitlastcommithash;
str = 'Hi,';
str = char(str,'');
str = char(str,'This is a summary report for the unitary tests in Dynare. Full report can be found at');
str = char(str,'This is a summary report for the unitary tests in Dynare. Full report can be found at:');
str = char(str,'');
str = char(str,'');
str = char(str,['http://www.dynare.org/stepan/dynare/tests/' reportfile]);
str = char(str,'');
str = char(str,['http://www.dynare.org/stepan/dynare/tests/' reportfile(1:end-3) 'log']);
str = char(str,'');
str = char(str,gitinfo(1,:));
str = char(str,gitinfo(2,:));
str = char(str,'');
str = char(str,'');
str = char(str,['===========================']);
str = char(str,'DYNARE/MATLAB UNITARY TESTS');
str = char(str,'===========================');
@ -75,9 +75,9 @@ for i=1:size(reportcell,1)
end
if printonscreen
fprintf('\n\n')
skipline(2);
disp(str)
fprintf('\n\n')
skipline(2);
end
if mailreport

View File

@ -36,7 +36,7 @@ using namespace std;
Splitting main() in two parts was necessary because ParsingDriver.h and MacroDriver.h can't be
included simultaneously (because of Bison limitations).
*/
void main2(stringstream &in, string &basename, bool debug, bool clear_all, bool no_tmp_terms, bool no_log, bool no_warn, bool warn_uninit, bool console,
void main2(stringstream &in, string &basename, bool debug, bool clear_all, bool no_tmp_terms, bool no_log, bool no_warn, bool warn_uninit, bool console, bool nograph, bool nointeractive,
bool parallel, const string &parallel_config_file, const string &cluster_name, bool parallel_slave_open_mode,
bool parallel_test
#if defined(_WIN32) || defined(__CYGWIN32__)
@ -48,7 +48,7 @@ void
usage()
{
cerr << "Dynare usage: dynare mod_file [debug] [noclearall] [savemacro[=macro_file]] [onlymacro] [nolinemacro] [notmpterms] [nolog] [warn_uninit]"
<< " [console] [parallel[=cluster_name]] [conffile=parallel_config_path_and_filename] [parallel_slave_open_mode] [parallel_test] "
<< " [console] [nograph] [nointeractive] [parallel[=cluster_name]] [conffile=parallel_config_path_and_filename] [parallel_slave_open_mode] [parallel_test] "
<< " [-D<variable>[=<value>]]"
#if defined(_WIN32) || defined(__CYGWIN32__)
<< " [cygwin] [msvc]"
@ -84,6 +84,8 @@ main(int argc, char **argv)
bool no_warn = false;
bool warn_uninit = false;
bool console = false;
bool nograph = false;
bool nointeractive = false;
#if defined(_WIN32) || defined(__CYGWIN32__)
bool cygwin = false;
bool msvc = false;
@ -129,6 +131,10 @@ main(int argc, char **argv)
warn_uninit = true;
else if (!strcmp(argv[arg], "console"))
console = true;
else if (!strcmp(argv[arg], "nograph"))
nograph = true;
else if (!strcmp(argv[arg], "nointeractive"))
nointeractive = true;
#if defined(_WIN32) || defined(__CYGWIN32__)
else if (!strcmp(argv[arg], "cygwin"))
cygwin = true;
@ -221,7 +227,7 @@ main(int argc, char **argv)
return EXIT_SUCCESS;
// Do the rest
main2(macro_output, basename, debug, clear_all, no_tmp_terms, no_log, no_warn, warn_uninit, console,
main2(macro_output, basename, debug, clear_all, no_tmp_terms, no_log, no_warn, warn_uninit, console, nograph, nointeractive,
parallel, parallel_config_file, cluster_name, parallel_slave_open_mode, parallel_test
#if defined(_WIN32) || defined(__CYGWIN32__)
, cygwin, msvc

View File

@ -26,7 +26,7 @@ using namespace std;
#include "ConfigFile.hh"
void
main2(stringstream &in, string &basename, bool debug, bool clear_all, bool no_tmp_terms, bool no_log, bool no_warn, bool warn_uninit, bool console,
main2(stringstream &in, string &basename, bool debug, bool clear_all, bool no_tmp_terms, bool no_log, bool no_warn, bool warn_uninit, bool console, bool nograph, bool nointeractive,
bool parallel, const string &parallel_config_file, const string &cluster_name, bool parallel_slave_open_mode,
bool parallel_test
#if defined(_WIN32) || defined(__CYGWIN32__)
@ -58,7 +58,7 @@ main2(stringstream &in, string &basename, bool debug, bool clear_all, bool no_tm
mod_file->computingPass(no_tmp_terms);
// Write outputs
mod_file->writeOutputFiles(basename, clear_all, no_log, no_warn, console, config_file
mod_file->writeOutputFiles(basename, clear_all, no_log, no_warn, console, nograph, nointeractive, config_file
#if defined(_WIN32) || defined(__CYGWIN32__)
, cygwin, msvc
#endif

View File

@ -455,7 +455,7 @@ ModFile::computingPass(bool no_tmp_terms)
}
void
ModFile::writeOutputFiles(const string &basename, bool clear_all, bool no_log, bool no_warn, bool console, const ConfigFile &config_file
ModFile::writeOutputFiles(const string &basename, bool clear_all, bool no_log, bool no_warn, bool console, bool nograph, bool nointeractive, const ConfigFile &config_file
#if defined(_WIN32) || defined(__CYGWIN32__)
, bool cygwin, bool msvc
#endif
@ -509,7 +509,12 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool no_log, b
if (console)
mOutputFile << "options_.console_mode = 1;" << endl
<< "options_.nodisplay = 1;" << endl;
if (nograph)
mOutputFile << "options_.nograph = 1;" << endl;
if (nointeractive)
mOutputFile << "options_.nointeractive = 1;" << endl;
cout << "Processing outputs ...";
symbol_table.writeOutput(mOutputFile);

View File

@ -127,10 +127,12 @@ public:
\param basename The base name used for writing output files. Should be the name of the mod file without its extension
\param clear_all Should a "clear all" instruction be written to output ?
\param console Are we in console mode ?
\param nograph Should we build the figures?
\param nointeractive Should Dynare request user input?
\param cygwin Should the MEX command of use_dll be adapted for Cygwin?
\param msvc Should the MEX command of use_dll be adapted for MSVC?
*/
void writeOutputFiles(const string &basename, bool clear_all, bool no_log, bool no_warn, bool console, const ConfigFile &config_file
void writeOutputFiles(const string &basename, bool clear_all, bool no_log, bool no_warn, bool console, bool nograph, bool nointeractive, const ConfigFile &config_file
#if defined(_WIN32) || defined(__CYGWIN32__)
, bool cygwin, bool msvc
#endif