diff --git a/doc/dynare.texi b/doc/dynare.texi index 4b5ffbb6a..3ce0fb5f8 100644 --- a/doc/dynare.texi +++ b/doc/dynare.texi @@ -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 diff --git a/matlab/check_list_of_variables.m b/matlab/check_list_of_variables.m index 4b1b69384..75d83f7dc 100644 --- a/matlab/check_list_of_variables.m +++ b/matlab/check_list_of_variables.m @@ -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 diff --git a/matlab/dyn_risky_steadystate_solver.m b/matlab/dyn_risky_steadystate_solver.m index 114e2c1b0..5557c98ad 100644 --- a/matlab/dyn_risky_steadystate_solver.m +++ b/matlab/dyn_risky_steadystate_solver.m @@ -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,... diff --git a/matlab/global_initialization.m b/matlab/global_initialization.m index 3b497efb2..dae49c300 100644 --- a/matlab/global_initialization.m +++ b/matlab/global_initialization.m @@ -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; diff --git a/matlab/metropolis_hastings_initialization.m b/matlab/metropolis_hastings_initialization.m index 3e75c78da..e42407b24 100644 --- a/matlab/metropolis_hastings_initialization.m +++ b/matlab/metropolis_hastings_initialization.m @@ -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 diff --git a/matlab/simplex_optimization_routine.m b/matlab/simplex_optimization_routine.m index fb170c250..5c19b270d 100644 --- a/matlab/simplex_optimization_routine.m +++ b/matlab/simplex_optimization_routine.m @@ -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; diff --git a/matlab/utilities/general/skipline.m b/matlab/utilities/general/skipline.m new file mode 100644 index 000000000..feb5bd83f --- /dev/null +++ b/matlab/utilities/general/skipline.m @@ -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 . + +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 \ No newline at end of file diff --git a/matlab/utilities/tests/build_report_summary.m b/matlab/utilities/tests/build_report_summary.m index 9e2fc0eae..b4a1dcd20 100644 --- a/matlab/utilities/tests/build_report_summary.m +++ b/matlab/utilities/tests/build_report_summary.m @@ -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 diff --git a/preprocessor/DynareMain.cc b/preprocessor/DynareMain.cc index 79201e391..f62f60399 100644 --- a/preprocessor/DynareMain.cc +++ b/preprocessor/DynareMain.cc @@ -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 ¶llel_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[=]]" #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 diff --git a/preprocessor/DynareMain2.cc b/preprocessor/DynareMain2.cc index f50436f5c..aed6e4e6a 100644 --- a/preprocessor/DynareMain2.cc +++ b/preprocessor/DynareMain2.cc @@ -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 ¶llel_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 diff --git a/preprocessor/ModFile.cc b/preprocessor/ModFile.cc index d8a6e2c1e..13a7641f9 100644 --- a/preprocessor/ModFile.cc +++ b/preprocessor/ModFile.cc @@ -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); diff --git a/preprocessor/ModFile.hh b/preprocessor/ModFile.hh index aa7ccc616..28a4a2f43 100644 --- a/preprocessor/ModFile.hh +++ b/preprocessor/ModFile.hh @@ -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