diff --git a/doc/dynare.texi b/doc/dynare.texi index e52dc33a36ebef9d93894e73af68c451fec937ef..6463236a9e671fe97839ba2b9f73e18c41410957 100644 --- a/doc/dynare.texi +++ b/doc/dynare.texi @@ -2059,9 +2059,9 @@ period (unless some of these initial values are modified by Second, in the absence of an @code{endval} block, it sets the terminal conditions for all the periods succeeding the last simulation period. -Third, in the absence of an @code{endval} block, it provides initial -guess values at all simulation dates for the non-linear solver -implemented in @code{simul}. +Third, in the absence of an @code{endval} block, it provides initial guess +values at all simulation dates for the perfect foresight solver, and is +therefore used by @code{perfect_foresight_setup} and @code{simul}. For this last reason, it necessary to provide values for all the endogenous variables in an @code{initval} block (even though, @@ -2147,8 +2147,9 @@ serves two purposes. First, it sets the terminal conditions for all the periods succeeding the last simulation period. -Second, it provides initial guess values at all the simulation dates -for the non-linear solver implemented in @code{simul}. +Second, it provides initial guess values at all the simulation dates for the +perfect foresight solver, and is therefore used by +@code{perfect_foresight_setup} and @code{simul}. For this last reason, it necessary to provide values for all the endogenous variables in an @code{endval} block (even though, @@ -2653,9 +2654,9 @@ Reduces the number of periods considered in subsequent output commands. @descriptionhead -This command is now deprecated (but will still work for older model -files). It is not necessary when no simulation is performed and is -replaced by an option @code{periods} in @code{simul} and +This command is now deprecated (but will still work for older model files). It +is not necessary when no simulation is performed and is replaced by an option +@code{periods} in @code{perfect_foresight_setup}, @code{simul} and @code{stoch_simul}. This command sets the number of periods in the simulation. The periods @@ -2716,10 +2717,11 @@ add new variables one by one. @table @code @item maxit = @var{INTEGER} -Determines the maximum number of iterations used in the non-linear solver. -The default value of @code{maxit} is 10. The @code{maxit} option is shared with the -@code{simul} command. So a change in @code{maxit} in a @code{steady} command will -also be considered in the following @code{simul} commands. +Determines the maximum number of iterations used in the non-linear solver. The +default value of @code{maxit} is 10. The @code{maxit} option is shared with the +@code{perfect_foresight_solver} and @code{simul} commands. So a change in +@code{maxit} in a @code{steady} command will also be considered in the +following @code{perfect_foresight_solver} and @code{simul} commands. @item solve_algo = @var{INTEGER} @@ -3292,15 +3294,17 @@ aid the solution process. These solution algorithms can provide a significant speed-up on large models. - - -@deffn Command simul ; -@deffnx Command simul (@var{OPTIONS}@dots{}); +@deffn Command perfect_foresight_setup ; +@deffnx Command perfect_foresight_setup (@var{OPTIONS}@dots{}); @descriptionhead -Triggers the computation of a deterministic simulation of the model -for the number of periods set in the option @code{periods}. +Prepares a perfect foresight simulation, by extracting the information in the +@code{initval}, @code{endval} and @code{shocks} blocks and converting them into +simulation paths for exogenous and endogenous variables. + +This command must always be called before running the simulation with +@code{perfect_foresight_solver}. @optionshead @@ -3309,23 +3313,43 @@ for the number of periods set in the option @code{periods}. @item periods = @var{INTEGER} Number of periods of the simulation -@item endogenous_terminal_period -The number of periods is not constant across Newton iterations when -solving the perfect foresight model. The size of the nonlinear system of -equations is reduced by removing the portion of the paths (and -associated equations) for which the solution has already been identified -(up to the tolerance parameter). This strategy can be interpreted as a -mix of the shooting and relaxation approaches. Note that round off -errors are more important with this mixed strategy (user should check -the reported value of the maximum absolute error). Only available with -option @code{stack_solve_algo==0}. +@item datafile = @var{FILENAME} +If the variables of the model are not constant over time, their +initial values, stored in a text file, could be loaded, using that +option, as initial values before a deterministic simulation. +@end table -@item maxit = @var{INTEGER} -Determines the maximum number of iterations used in the non-linear solver. -The default value of @code{maxit} is 10. The @code{maxit} option is shared with the -@code{steady} command. So a change in @code{maxit} in a @code{simul} command will -also be considered in the following @code{steady} commands. +@outputhead + +The paths for the exogenous variables are stored into @code{oo_.exo_simul}. + +The initial and terminal conditions for the endogenous variables and the +initial guess for the path of endogenous variables are stored into +@code{oo_.endo_simul}. +@end deffn + + +@deffn Command perfect_foresight_solver ; +@deffnx Command perfect_foresight_solver (@var{OPTIONS}@dots{}); + +@descriptionhead + +Computes the perfect foresight (or deterministic) simulation of the model. + +Note that @code{perfect_foresight_setup} must be called before this command, in +order to setup the environment for the simulation. + +@optionshead + +@table @code + +@item maxit = @var{INTEGER} +Determines the maximum number of iterations used in the non-linear solver. The +default value of @code{maxit} is 10. The @code{maxit} option is shared with the +@code{steady} command. So a change in @code{maxit} in a +@code{perfect_foresight_solver} command will also be considered in the +following @code{steady} commands. @item stack_solve_algo = @var{INTEGER} Algorithm used for computing the solution. Possible values are: @@ -3378,10 +3402,17 @@ Specify the minimal number of periods where the model has to be solved, before using a constant set of operations for the remaining periods. Only used when @code{stack_solve_algo = 5}. Default: @code{1}. -@item datafile = @var{FILENAME} -If the variables of the model are not constant over time, their -initial values, stored in a text file, could be loaded, using that -option, as initial values before a deterministic simulation. +@item endogenous_terminal_period +The number of periods is not constant across Newton iterations when +solving the perfect foresight model. The size of the nonlinear system of +equations is reduced by removing the portion of the paths (and +associated equations) for which the solution has already been identified +(up to the tolerance parameter). This strategy can be interpreted as a +mix of the shooting and relaxation approaches. Note that round off +errors are more important with this mixed strategy (user should check +the reported value of the maximum absolute error). Only available with +option @code{stack_solve_algo==0}. + @end table @outputhead @@ -3391,11 +3422,28 @@ The simulated endogenous variables are available in global matrix @end deffn +@deffn Command simul ; +@deffnx Command simul (@var{OPTIONS}@dots{}); + +@descriptionhead + +Short-form command for triggering the computation of a deterministic simulation +of the model. It is strictly equivalent to a call to +@code{perfect_foresight_setup} followed by a call to +@code{perfect_foresight_solver}. + +@optionshead + +Accepts all the options of @code{perfect_foresight_setup} and +@code{perfect_foresight_solver}. + +@end deffn + @anchor{oo_.endo_simul} @defvr {MATLAB/Octave variable} oo_.endo_simul -This variable stores the result of a deterministic simulation -(computed by @code{simul}) or of a stochastic simulation (computed by -@code{stoch_simul} with the @code{periods} option or by +This variable stores the result of a deterministic simulation (computed by +@code{perfect_foresight_solver} or @code{simul}) or of a stochastic simulation +(computed by @code{stoch_simul} with the @code{periods} option or by @code{extended_path}). The variables are arranged row by row, in order of declaration (as in @@ -3406,9 +3454,9 @@ and terminal conditions, so it has more columns than the value of @anchor{oo_.exo_simul} @defvr {MATLAB/Octave variable} oo_.exo_simul -This variable stores the path of exogenous variables during a -simulation (computed by @code{simul}, @code{stoch_simul} or -@code{extended_path}). +This variable stores the path of exogenous variables during a simulation +(computed by @code{perfect_foresight_solver}, @code{simul}, @code{stoch_simul} +or @code{extended_path}). The variables are arranged in columns, in order of declaration (as in @code{M_.endo_names}). Periods are in rows. Note that this convention @@ -7919,10 +7967,10 @@ Dynare has comments to plot the results of a simulation and to save the results. @deffn Command rplot @var{VARIABLE_NAME}@dots{}; Plots the simulated path of one or several variables, as stored in -@var{oo_.endo_simul} by either @var{simul} (@pxref{Deterministic -simulation}) or @var{stoch_simul} with -option @var{periods} (@pxref{Computing the stochastic solution}). The -variables are plotted in levels. +@code{oo_.endo_simul} by either @code{perfect_foresight_solver}, @code{simul} +(@pxref{Deterministic simulation}) or @code{stoch_simul} with option +@code{periods} (@pxref{Computing the stochastic solution}). The variables are +plotted in levels. @end deffn diff --git a/matlab/perfect_foresight_setup.m b/matlab/perfect_foresight_setup.m new file mode 100644 index 0000000000000000000000000000000000000000..da03d46a68cf949e19f3ab7b3c32253d12ab5ae2 --- /dev/null +++ b/matlab/perfect_foresight_setup.m @@ -0,0 +1,53 @@ +function perfect_foresight_setup() +% Prepares a deterministic simulation, by filling oo_.exo_simul and oo_.endo_simul +% +% INPUTS +% None +% +% OUTPUTS +% none +% +% ALGORITHM +% +% SPECIAL REQUIREMENTS +% none + +% Copyright (C) 1996-2014 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/>. + +global M_ options_ oo_ + +test_for_deep_parameters_calibration(M_); + +if size(M_.lead_lag_incidence,2)-nnz(M_.lead_lag_incidence(M_.maximum_endo_lag+1,:)) > 0 + mess = ['PERFECT_FORESIGHT_SETUP: error in model specification : variable ' M_.endo_names(find(M_.lead_lag_incidence(M_.maximum_lag+1,:)==0),:)]; + mess = [mess ' doesn''t appear as current variable.']; + error(mess) +end + +if options_.periods == 0 + error('PERFECT_FORESIGHT_SETUP: number of periods for the simulation isn''t specified') +end + +if ~options_.initval_file + if isempty(options_.datafile) + make_ex_; + make_y_; + else + read_data_; + end +end diff --git a/matlab/simul.m b/matlab/perfect_foresight_solver.m similarity index 75% rename from matlab/simul.m rename to matlab/perfect_foresight_solver.m index 4285c906da8a3c8e0f93185f68467b22fe56988e..ce9d94306d4d8bf31d282766a3673cf898ccc5dd 100644 --- a/matlab/simul.m +++ b/matlab/perfect_foresight_solver.m @@ -1,4 +1,4 @@ -function simul() +function perfect_foresight_solver() % Computes deterministic simulations % % INPUTS @@ -12,7 +12,7 @@ function simul() % SPECIAL REQUIREMENTS % none -% Copyright (C) 1996-2013 Dynare Team +% Copyright (C) 1996-2014 Dynare Team % % This file is part of Dynare. % @@ -31,48 +31,37 @@ function simul() global M_ options_ oo_ -test_for_deep_parameters_calibration(M_); - if options_.stack_solve_algo < 0 || options_.stack_solve_algo > 6 - error('SIMUL: stack_solve_algo must be between 0 and 6') + error('PERFECT_FORESIGHT_SOLVER: stack_solve_algo must be between 0 and 6') end if ~options_.block && ~options_.bytecode && options_.stack_solve_algo ~= 0 ... && options_.stack_solve_algo ~= 6 - error('SIMUL: you must use stack_solve_algo=0 or stack_solve_algo=6 when not using block nor bytecode option') + error('PERFECT_FORESIGHT_SOLVER: you must use stack_solve_algo=0 or stack_solve_algo=6 when not using block nor bytecode option') end if options_.block && ~options_.bytecode && options_.stack_solve_algo == 5 - error('SIMUL: you can''t use stack_solve_algo = 5 without bytecode option') + error('PERFECT_FORESIGHT_SOLVER: you can''t use stack_solve_algo = 5 without bytecode option') end if (options_.block || options_.bytecode) && options_.stack_solve_algo == 6 - error('SIMUL: you can''t use stack_solve_algo = 6 with block or bytecode option') + error('PERFECT_FORESIGHT_SOLVER: you can''t use stack_solve_algo = 6 with block or bytecode option') end if isoctave && options_.stack_solve_algo == 2 - error('SIMUL: you can''t use stack_solve_algo = 2 under Octave') + error('PERFECT_FORESIGHT_SOLVER: you can''t use stack_solve_algo = 2 under Octave') end -if size(M_.lead_lag_incidence,2)-nnz(M_.lead_lag_incidence(M_.maximum_endo_lag+1,:)) > 0 - mess = ['SIMUL: error in model specification : variable ' M_.endo_names(find(M_.lead_lag_incidence(M_.maximum_lag+1,:)==0),:)]; - mess = [mess ' doesn''t appear as current variable.']; - error(mess) -end -if options_.periods == 0 - error('SIMUL: number of periods for the simulation isn''t specified') +if isempty(oo_.endo_simul) || any(size(oo_.endo_simul) ~= [ M_.endo_nbr, M_.maximum_endo_lag+options_.periods+M_.maximum_endo_lead ]) + error('PERFECT_FORESIGHT_SOLVER: ''oo_.endo_simul'' has wrong size. Did you run ''perfect_foresight_setup'' ?') end -if ~options_.initval_file - if isempty(options_.datafile) - make_ex_; - make_y_; - else - read_data_; - end +if isempty(oo_.exo_simul) || any(size(oo_.exo_simul) ~= [ M_.maximum_lag+options_.periods+M_.maximum_lead, M_.exo_nbr ]) + error('PERFECT_FORESIGHT_SOLVER: ''oo_.exo_simul'' has wrong size. Did you run ''perfect_foresight_setup'' ?') end + if isempty(options_.scalv) || options_.scalv == 0 options_.scalv = oo_.steady_state; end diff --git a/preprocessor/ComputingTasks.cc b/preprocessor/ComputingTasks.cc index d3777117ba18d34d3f76afa48dd556662cb45192..e9292f90174e86d63734304cbba8bcf0b2749d41 100644 --- a/preprocessor/ComputingTasks.cc +++ b/preprocessor/ComputingTasks.cc @@ -94,14 +94,45 @@ SimulStatement::SimulStatement(const OptionsList &options_list_arg) : void SimulStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) { - mod_file_struct.simul_present = true; + mod_file_struct.perfect_foresight_solver_present = true; } void SimulStatement::writeOutput(ostream &output, const string &basename) const { options_list.writeOutput(output); - output << "simul();\n"; + output << "perfect_foresight_setup;" << endl + << "perfect_foresight_solver;" << endl; +} + +PerfectForesightSetupStatement::PerfectForesightSetupStatement(const OptionsList &options_list_arg) : + options_list(options_list_arg) +{ +} + +void +PerfectForesightSetupStatement::writeOutput(ostream &output, const string &basename) const +{ + options_list.writeOutput(output); + output << "perfect_foresight_setup;" << endl; +} + +PerfectForesightSolverStatement::PerfectForesightSolverStatement(const OptionsList &options_list_arg) : + options_list(options_list_arg) +{ +} + +void +PerfectForesightSolverStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) +{ + mod_file_struct.perfect_foresight_solver_present = true; +} + +void +PerfectForesightSolverStatement::writeOutput(ostream &output, const string &basename) const +{ + options_list.writeOutput(output); + output << "perfect_foresight_solver;" << endl; } StochSimulStatement::StochSimulStatement(const SymbolList &symbol_list_arg, diff --git a/preprocessor/ComputingTasks.hh b/preprocessor/ComputingTasks.hh index c04f2f7051d2e27a0f261f4a7613edcaf9e67dfe..b1a009ffac7e2ed92df869624d27a4762adadd44 100644 --- a/preprocessor/ComputingTasks.hh +++ b/preprocessor/ComputingTasks.hh @@ -58,6 +58,25 @@ public: virtual void writeOutput(ostream &output, const string &basename) const; }; +class PerfectForesightSetupStatement : public Statement +{ +private: + const OptionsList options_list; +public: + PerfectForesightSetupStatement(const OptionsList &options_list_arg); + virtual void writeOutput(ostream &output, const string &basename) const; +}; + +class PerfectForesightSolverStatement : public Statement +{ +private: + const OptionsList options_list; +public: + PerfectForesightSolverStatement(const OptionsList &options_list_arg); + virtual void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings); + virtual void writeOutput(ostream &output, const string &basename) const; +}; + class ModelInfoStatement : public Statement { private: diff --git a/preprocessor/DynareBison.yy b/preprocessor/DynareBison.yy index bedda79b712c9d19470891d2f1d4ef14eeb1c3cc..3449cc6fdb878c7816dd1aefcd20e6f5234add5d 100644 --- a/preprocessor/DynareBison.yy +++ b/preprocessor/DynareBison.yy @@ -112,6 +112,7 @@ class ParsingDriver; %token NOGRAPH NOMOMENTS NOPRINT NORMAL_PDF SAVE_DRAWS %token OBSERVATION_TRENDS OPTIM OPTIM_WEIGHTS ORDER OSR OSR_PARAMS MAX_DIM_COVA_GROUP ADVANCED OUTFILE OUTVARS %token PARALLEL_LOCAL_FILES PARAMETERS PARAMETER_SET PARTIAL_INFORMATION PERFECT_FORESIGHT PERIODS PERIOD PLANNER_OBJECTIVE PLOT_CONDITIONAL_FORECAST PLOT_PRIORS PREFILTER PRESAMPLE +%token PERFECT_FORESIGHT_SETUP PERFECT_FORESIGHT_SOLVER %token PRINT PRIOR_MC PRIOR_TRUNC PRIOR_MODE PRIOR_MEAN POSTERIOR_MODE POSTERIOR_MEAN POSTERIOR_MEDIAN PRUNING %token <string_val> QUOTED_STRING %token QZ_CRITERIUM QZ_ZERO_THRESHOLD FULL DSGE_VAR DSGE_VARLAG DSGE_PRIOR_WEIGHT TRUNCATE @@ -272,6 +273,8 @@ statement : parameters | irf_calibration | smoother2histval | histval_file + | perfect_foresight_setup + | perfect_foresight_solver ; dsample : DSAMPLE INT_NUMBER ';' @@ -970,6 +973,37 @@ model_info_options_list : model_info_options_list COMMA model_info_options ; model_info_options : +perfect_foresight_setup : PERFECT_FORESIGHT_SETUP ';' + { driver.perfect_foresight_setup(); } + | PERFECT_FORESIGHT_SETUP '(' perfect_foresight_setup_options_list ')' ';' + { driver.perfect_foresight_setup(); } + ; + +perfect_foresight_setup_options_list : perfect_foresight_setup_options_list COMMA perfect_foresight_setup_options + | perfect_foresight_setup_options + ; + +perfect_foresight_setup_options : o_periods + | o_datafile + ; + +perfect_foresight_solver : PERFECT_FORESIGHT_SOLVER ';' + { driver.perfect_foresight_solver(); } + | PERFECT_FORESIGHT_SOLVER '(' perfect_foresight_solver_options_list ')' ';' + { driver.perfect_foresight_solver(); } + ; + +perfect_foresight_solver_options_list : perfect_foresight_solver_options_list COMMA perfect_foresight_solver_options + | perfect_foresight_solver_options + ; + +perfect_foresight_solver_options : o_stack_solve_algo + | o_markowitz + | o_minimal_solving_periods + | o_simul_maxit + | o_endogenous_terminal_period + ; + simul : SIMUL ';' { driver.simul(); } | SIMUL '(' simul_options_list ')' ';' @@ -980,13 +1014,8 @@ simul_options_list : simul_options_list COMMA simul_options | simul_options ; -simul_options : o_periods - | o_datafile - | o_stack_solve_algo - | o_markowitz - | o_minimal_solving_periods - | o_simul_maxit - | o_endogenous_terminal_period +simul_options : perfect_foresight_setup_options + | perfect_foresight_solver_options ; external_function : EXTERNAL_FUNCTION '(' external_function_options_list ')' ';' diff --git a/preprocessor/DynareFlex.ll b/preprocessor/DynareFlex.ll index eafa637eca407b83ac8a771629d43bda8aacf85d..4834afeee446522e2083f846800ff212813fabe4 100644 --- a/preprocessor/DynareFlex.ll +++ b/preprocessor/DynareFlex.ll @@ -168,6 +168,8 @@ DATE -?[0-9]+([YyAa]|[Mm]([1-9]|1[0-2])|[Qq][1-4]|[Ww]([1-9]{1}|[1-4][0-9]|5[0-2 <INITIAL>model_diagnostics {BEGIN DYNARE_STATEMENT; return token::MODEL_DIAGNOSTICS;} <INITIAL>extended_path {BEGIN DYNARE_STATEMENT; return token::EXTENDED_PATH;} <INITIAL>smoother2histval {BEGIN DYNARE_STATEMENT; return token::SMOOTHER2HISTVAL;} +<INITIAL>perfect_foresight_setup {BEGIN DYNARE_STATEMENT; return token::PERFECT_FORESIGHT_SETUP;} +<INITIAL>perfect_foresight_solver {BEGIN DYNARE_STATEMENT; return token::PERFECT_FORESIGHT_SOLVER;} <DYNARE_STATEMENT>; { if (!sigma_e) diff --git a/preprocessor/ModFile.cc b/preprocessor/ModFile.cc index f5c20837c02aeec7c698ffdcf52f366b4173dac9..7f31e86ff05e89a1a78db8aa18c53434d5be6477 100644 --- a/preprocessor/ModFile.cc +++ b/preprocessor/ModFile.cc @@ -129,7 +129,7 @@ ModFile::checkPass() // Allow empty model only when doing a standalone BVAR estimation if (dynamic_model.equation_number() == 0 && (mod_file_struct.check_present - || mod_file_struct.simul_present + || mod_file_struct.perfect_foresight_solver_present || stochastic_statement_present)) { cerr << "ERROR: At least one model equation must be declared!" << endl; @@ -153,9 +153,9 @@ ModFile::checkPass() exit(EXIT_FAILURE); } - if (mod_file_struct.simul_present && stochastic_statement_present) + if (mod_file_struct.perfect_foresight_solver_present && stochastic_statement_present) { - cerr << "ERROR: A .mod file cannot contain both a simul command and one of {stoch_simul, estimation, osr, ramsey_policy, discretionary_policy}" << endl; + cerr << "ERROR: A .mod file cannot contain both one of {perfect_foresight_solver,simul} and one of {stoch_simul, estimation, osr, ramsey_policy, discretionary_policy}. This is not possible: one cannot mix perfect foresight context with stochastic context in the same file." << endl; exit(EXIT_FAILURE); } @@ -407,9 +407,9 @@ ModFile::transformPass(bool nostrict) exit(EXIT_FAILURE); } - if (symbol_table.exo_det_nbr() > 0 && mod_file_struct.simul_present) + if (symbol_table.exo_det_nbr() > 0 && mod_file_struct.perfect_foresight_solver_present) { - cerr << "ERROR: A .mod file cannot contain both a simul command and varexo_det declaration (all exogenous variables are deterministic in this case)" << endl; + cerr << "ERROR: A .mod file cannot contain both one of {perfect_foresight_solver,simul} and varexo_det declaration (all exogenous variables are deterministic in this case)" << endl; exit(EXIT_FAILURE); } @@ -473,13 +473,13 @@ ModFile::computingPass(bool no_tmp_terms, FileOutputType output) false, paramsDerivatives, block, byte_code); } // Set things to compute for dynamic model - if (mod_file_struct.simul_present || mod_file_struct.check_present + if (mod_file_struct.perfect_foresight_solver_present || mod_file_struct.check_present || mod_file_struct.stoch_simul_present || mod_file_struct.estimation_present || mod_file_struct.osr_present || mod_file_struct.ramsey_model_present || mod_file_struct.identification_present || mod_file_struct.calib_smoother_present) { - if (mod_file_struct.simul_present) + if (mod_file_struct.perfect_foresight_solver_present) dynamic_model.computingPass(true, false, false, false, global_eval_context, no_tmp_terms, block, use_dll, byte_code); else { diff --git a/preprocessor/ParsingDriver.cc b/preprocessor/ParsingDriver.cc index fe48e41a888577e18d2b7b94afbdb9191fb330e3..cda8804258f762ead726bb9a36a52e1587d7d90c 100644 --- a/preprocessor/ParsingDriver.cc +++ b/preprocessor/ParsingDriver.cc @@ -2692,3 +2692,18 @@ ParsingDriver::histval_file(string *filename) mod_file->addStatement(new HistvalFileStatement(*filename)); delete filename; } + + +void +ParsingDriver::perfect_foresight_setup() +{ + mod_file->addStatement(new PerfectForesightSetupStatement(options_list)); + options_list.clear(); +} + +void +ParsingDriver::perfect_foresight_solver() +{ + mod_file->addStatement(new PerfectForesightSolverStatement(options_list)); + options_list.clear(); +} diff --git a/preprocessor/ParsingDriver.hh b/preprocessor/ParsingDriver.hh index 464938791709315d63207d0c628d08572eb039c6..6218776e8f05900dffeaadec94a210807a1889bf 100644 --- a/preprocessor/ParsingDriver.hh +++ b/preprocessor/ParsingDriver.hh @@ -668,6 +668,8 @@ public: void smoother2histval(); void histval_file(string *filename); + void perfect_foresight_setup(); + void perfect_foresight_solver(); }; #endif // ! PARSING_DRIVER_HH diff --git a/preprocessor/Statement.cc b/preprocessor/Statement.cc index 688883cc3879f084d7a7cc78827d66877b0c01b3..50d8ccefb0f998f94f2a748534ea4bfaf7c5a5bd 100644 --- a/preprocessor/Statement.cc +++ b/preprocessor/Statement.cc @@ -23,7 +23,7 @@ ModFileStructure::ModFileStructure() : check_present(false), steady_present(false), - simul_present(false), + perfect_foresight_solver_present(false), stoch_simul_present(false), estimation_present(false), osr_present(false), diff --git a/preprocessor/Statement.hh b/preprocessor/Statement.hh index 0f5838653d75d6c4bde50cf7e2dabf24c22f577f..5bdade3910b8a77ee145856a92084ae05f13d9e6 100644 --- a/preprocessor/Statement.hh +++ b/preprocessor/Statement.hh @@ -36,8 +36,8 @@ public: bool check_present; //! Whether steady is present bool steady_present; - //! Whether a simul statement is present - bool simul_present; + //! Whether a perfect_foresight_solver/simul statement is present + bool perfect_foresight_solver_present; //! Whether a stoch_simul statement is present bool stoch_simul_present; //! Whether an estimation statement is present diff --git a/tests/ramst.mod b/tests/ramst.mod index f5637b3d228355ceacbe8b12b7ac2d6fa424803a..cd05cc619abd04bdbbc3ddd5701486e9b0d1ec2e 100644 --- a/tests/ramst.mod +++ b/tests/ramst.mod @@ -30,7 +30,8 @@ periods 1; values 1.2; end; -simul(periods=200); +perfect_foresight_setup(periods=200); +perfect_foresight_solver; rplot c; rplot k;