2008-02-03 11:28:36 +01:00
/*
2021-02-22 15:53:09 +01:00
* Copyright © 2006 - 2021 Dynare Team
2008-02-03 11:28:36 +01:00
*
* 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
2021-06-09 16:52:20 +02:00
* along with Dynare . If not , see < https : //www.gnu.org/licenses/>.
2008-02-03 11:28:36 +01:00
*/
# ifndef _STATEMENT_HH
# define _STATEMENT_HH
# include <ostream>
# include <string>
# include <map>
2013-11-29 14:50:58 +01:00
# include <set>
2008-02-03 11:28:36 +01:00
2008-04-07 15:14:40 +02:00
# include "SymbolList.hh"
2012-01-23 16:52:27 +01:00
# include "WarningConsolidation.hh"
2008-04-07 15:14:40 +02:00
2008-02-03 11:28:36 +01:00
class ModFileStructure
{
public :
2019-01-15 11:08:47 +01:00
ModFileStructure ( ) = default ;
2010-06-11 10:31:13 +02:00
//! Whether check is present
2018-06-04 12:46:34 +02:00
bool check_present { false } ;
2010-06-11 10:31:13 +02:00
//! Whether steady is present
2018-06-04 12:46:34 +02:00
bool steady_present { false } ;
2014-04-09 17:57:17 +02:00
//! Whether a perfect_foresight_solver/simul statement is present
2018-06-04 12:46:34 +02:00
bool perfect_foresight_solver_present { false } ;
2008-09-29 12:16:13 +02:00
//! Whether a stoch_simul statement is present
2018-06-04 12:46:34 +02:00
bool stoch_simul_present { false } ;
2008-09-29 12:16:13 +02:00
//! Whether an estimation statement is present
2018-06-04 12:46:34 +02:00
bool estimation_present { false } ;
2008-09-29 12:16:13 +02:00
//! Whether an osr statement is present
2018-06-04 12:46:34 +02:00
bool osr_present { false } ;
2011-03-03 16:30:53 +01:00
//! Whether an osr params statement is present
2018-06-04 12:46:34 +02:00
bool osr_params_present { false } ;
2011-03-03 16:30:53 +01:00
//! Whether an optim weight statement is present
2018-06-04 12:46:34 +02:00
bool optim_weights_present { false } ;
2014-03-09 09:52:44 +01:00
//! Whether a ramsey_model statement is present
2018-06-04 12:46:34 +02:00
bool ramsey_model_present { false } ;
2008-09-29 12:16:13 +02:00
//! Whether a ramsey_policy statement is present
2018-06-04 12:46:34 +02:00
bool ramsey_policy_present { false } ;
2011-03-13 21:19:55 +01:00
//! Whether a discretionary_objective statement is present
2018-06-04 12:46:34 +02:00
bool discretionary_policy_present { false } ;
2011-03-03 16:03:21 +01:00
//! Whether a planner_objective statement is present
2018-06-04 12:46:34 +02:00
bool planner_objective_present { false } ;
2013-04-25 18:07:32 +02:00
//! Whether an extended_path statement is present
2018-06-04 12:46:34 +02:00
bool extended_path_present { false } ;
2009-10-20 18:17:27 +02:00
//! The value of the "order" option of stoch_simul, estimation, osr, ramsey_policy
2008-04-24 12:55:26 +02:00
//! Derivation order
/*! First initialized to zero. If user sets order option somewhere in the MOD file, it will be equal to the maximum of order options. Otherwise will default to 2 */
2018-06-04 12:46:34 +02:00
int order_option { 0 } ;
2009-11-26 18:25:04 +01:00
//! Whether a bvar_density, bvar_forecast, sbvar, ms_sbvar statement is present
2018-06-04 12:46:34 +02:00
bool bvar_present { false } ;
2009-12-04 22:32:19 +01:00
//! Whether an svar_identification statement is present
2018-06-04 12:46:34 +02:00
bool svar_identification_present { false } ;
2009-10-14 18:16:43 +02:00
//! Whether an identification statement is present or the identification option of dynare_sensitivity statement is equal to one
2018-06-04 12:46:34 +02:00
bool identification_present { false } ;
2019-07-05 17:44:10 +02:00
//! The maximum of the “order” option in identification statements
int identification_order { 0 } ;
2019-01-09 14:48:25 +01:00
//! Whether a sensitivity statement is present
bool sensitivity_present { false } ;
2012-06-07 15:26:49 +02:00
//! Whether the option analytic_derivation is given to estimation
2018-06-04 12:46:34 +02:00
bool estimation_analytic_derivation { false } ;
2009-10-20 18:55:31 +02:00
//! Whether the option partial_information is given to stoch_simul/estimation/osr/ramsey_policy
2018-06-04 12:46:34 +02:00
bool partial_information { false } ;
2009-12-09 12:50:58 +01:00
//! Whether the "k_order_solver" option is used (explictly, or implicitly if order >= 3)
2018-06-04 12:46:34 +02:00
bool k_order_solver { false } ;
2020-07-08 18:42:14 +02:00
//! Whether an method_of_moments statement is present
bool mom_estimation_present { false } ;
2020-12-11 13:27:23 +01:00
//! Whether an GMM-option is present
bool GMM_present { false } ;
//! Whether an analytic_standard_errors-option is present
bool analytic_standard_errors_present { false } ;
2021-01-08 15:04:13 +01:00
//! Whether an analytic_jacobian-option is present
bool analytic_jacobian_present { false } ;
2020-12-11 13:27:23 +01:00
//! The maximum of the “order” option in method_of_moments statements
int mom_order { 0 } ;
2010-04-14 15:03:41 +02:00
//! Whether there is a calibrated measurement error
2018-06-04 12:46:34 +02:00
bool calibrated_measurement_errors { false } ;
2010-06-21 18:40:36 +02:00
//! Whether dsge_prior_weight was initialized as a parameter
bool dsge_prior_weight_initialized ;
2010-06-11 21:19:30 +02:00
//! Whether dsge_prior_weight is in the estimated_params block
2018-06-04 12:46:34 +02:00
bool dsge_prior_weight_in_estimated_params { false } ;
2010-06-11 21:19:30 +02:00
//! Whether there is a dsge_var, with calibrated prior weight
string dsge_var_calibrated ;
//! Whether there is a dsge_var, with prior weight that must be estimated
2018-06-04 12:46:34 +02:00
bool dsge_var_estimated { false } ;
2010-06-11 21:19:30 +02:00
//! Whether there is a bayesian_irf option passed to the estimation statement
2018-06-04 12:46:34 +02:00
bool bayesian_irf_present { false } ;
2011-12-06 15:42:57 +01:00
//! Whether there is a data statement present
2018-06-04 12:46:34 +02:00
bool estimation_data_statement_present { false } ;
2016-03-14 07:56:16 +01:00
//! Last chain number for Markov Switching statement2
2018-06-04 12:46:34 +02:00
int last_markov_switching_chain { 0 } ;
2013-10-29 12:47:40 +01:00
//! Whether a calib_smoother statement is present
2018-06-04 12:46:34 +02:00
bool calib_smoother_present { false } ;
2013-12-09 16:23:49 +01:00
//! Whether there is an estimated_params_init with use_calibration
2018-06-04 12:46:34 +02:00
bool estim_params_use_calib { false } ;
2013-11-29 14:50:58 +01:00
//! Set of parameters used within shocks blocks, inside the expressions
//! defining the values of covariances (stored as symbol ids)
set < int > parameters_within_shocks_values ;
//! Set of estimated parameters (stored as symbol ids)
set < int > estimated_parameters ;
2013-08-06 21:20:36 +02:00
//! Whether there is a prior statement present
2018-06-04 12:46:34 +02:00
bool prior_statement_present { false } ;
2013-08-06 21:20:36 +02:00
//! Whether there is a std prior statement present
2018-06-04 12:46:34 +02:00
bool std_prior_statement_present { false } ;
2013-08-06 21:20:36 +02:00
//! Whether there is a corr prior statement present
2018-06-04 12:46:34 +02:00
bool corr_prior_statement_present { false } ;
2013-08-06 21:20:36 +02:00
//! Whether there is a options statement present
2018-06-04 12:46:34 +02:00
bool options_statement_present { false } ;
2013-08-06 21:20:36 +02:00
//! Whether there is a std options statement present
2018-06-04 12:46:34 +02:00
bool std_options_statement_present { false } ;
2013-08-06 21:20:36 +02:00
//! Whether there is a corr options statement present
2018-06-04 12:46:34 +02:00
bool corr_options_statement_present { false } ;
2013-08-06 21:20:36 +02:00
//! Whether a Markov Switching DSGE is present
2018-06-04 12:46:34 +02:00
bool ms_dsge_present { false } ;
2016-03-14 07:56:16 +01:00
//! Stores the original number of equations in the model_block
2018-06-04 12:46:34 +02:00
int orig_eq_nbr { 0 } ;
2017-06-14 07:01:31 +02:00
//! Stores the number of equations added to the Ramsey model
2018-06-04 12:46:34 +02:00
int ramsey_eq_nbr { 0 } ;
2017-08-30 15:46:17 +02:00
//! Whether there was a steady_state_model block
2018-06-04 12:46:34 +02:00
bool steady_state_model_present { false } ;
2017-08-30 15:46:17 +02:00
//! Whether there is a write_latex_steady_state_model statement present
2018-06-04 12:46:34 +02:00
bool write_latex_steady_state_model_present { false } ;
2018-03-28 18:46:15 +02:00
//! Pac growth and discount
set < int > pac_params ;
2019-12-12 16:03:59 +01:00
//! Instruments if ramsey_model, ramsey_policy or discretionary_policy is present
SymbolList instruments ;
2019-12-20 11:10:32 +01:00
/* Whether any of shock_decomposition, realtime_shock_decomposition and
initial_condition_decomposition has the “ with_epilogue ” option */
bool with_epilogue_option { false } ;
2020-02-04 17:48:37 +01:00
/* Lists symbol IDs of parameters that appear in a “planner_discount” option.
See dynare # 1173 for more details . */
set < int > parameters_in_planner_discount ;
2008-02-03 11:28:36 +01:00
} ;
class Statement
{
public :
2018-10-04 17:57:56 +02:00
Statement ( ) = default ;
2018-10-11 17:08:44 +02:00
virtual ~ Statement ( ) = default ;
2018-10-04 17:57:56 +02:00
Statement ( const Statement & ) = delete ;
Statement ( Statement & & ) = delete ;
2019-12-20 16:59:30 +01:00
Statement & operator = ( const Statement & ) = delete ;
Statement & operator = ( Statement & & ) = delete ;
2018-10-04 17:57:56 +02:00
2008-02-03 11:28:36 +01:00
//! Do some internal check, and fill the ModFileStructure class
2012-02-06 12:16:38 +01:00
/*! Don't forget to update ComputingTasks.hh, Shocks.hh and
NumericalInitialization . hh if you modify the signature of this
method . Otherwise the default implementation ( i . e . a no - op ) will apply and
some checks won ' t be run . */
2012-01-23 16:52:27 +01:00
virtual void checkPass ( ModFileStructure & mod_file_struct , WarningConsolidation & warnings ) ;
2021-06-04 16:20:29 +02:00
virtual void computingPass ( const ModFileStructure & mod_file_struct ) ;
2009-03-24 17:29:58 +01:00
//! Write Matlab output code
2008-02-03 11:28:36 +01:00
/*!
\ param output is the output stream of the main matlab file
\ param basename is the name of the modfile ( without extension ) which can be used to build auxiliary files
*/
2015-05-28 11:42:12 +02:00
virtual void writeOutput ( ostream & output , const string & basename , bool minimal_workspace ) const = 0 ;
2020-11-26 16:23:26 +01:00
virtual void writeJsonOutput ( ostream & output ) const = 0 ;
2008-02-03 11:28:36 +01:00
} ;
class NativeStatement : public Statement
{
private :
2013-10-10 11:04:56 +02:00
const string native_statement ;
2008-02-03 11:28:36 +01:00
public :
2018-10-04 15:17:13 +02:00
explicit NativeStatement ( string native_statement_arg ) ;
2018-06-04 12:53:26 +02:00
void writeOutput ( ostream & output , const string & basename , bool minimal_workspace ) const override ;
void writeJsonOutput ( ostream & output ) const override ;
2008-02-03 11:28:36 +01:00
} ;
2015-06-16 12:48:32 +02:00
class VerbatimStatement : public Statement
{
private :
const string verbatim_statement ;
public :
2018-10-04 15:17:13 +02:00
explicit VerbatimStatement ( string verbatim_statement_arg ) ;
2018-06-04 12:53:26 +02:00
void writeOutput ( ostream & output , const string & basename , bool minimal_workspace ) const override ;
void writeJsonOutput ( ostream & output ) const override ;
2015-06-16 12:48:32 +02:00
} ;
2008-02-03 11:28:36 +01:00
class OptionsList
{
public :
2018-06-04 14:31:26 +02:00
using num_options_t = map < string , string > ;
using paired_num_options_t = map < string , pair < string , string > > ;
using string_options_t = map < string , string > ;
using date_options_t = map < string , string > ;
using symbol_list_options_t = map < string , SymbolList > ;
using vec_int_options_t = map < string , vector < int > > ;
using vec_str_options_t = map < string , vector < string > > ;
2020-07-08 18:42:14 +02:00
using vec_cellstr_options_t = map < string , vector < string > > ;
2010-09-16 19:00:48 +02:00
num_options_t num_options ;
paired_num_options_t paired_num_options ;
string_options_t string_options ;
2011-11-29 17:14:26 +01:00
date_options_t date_options ;
2010-09-16 19:00:48 +02:00
symbol_list_options_t symbol_list_options ;
vec_int_options_t vector_int_options ;
2018-01-12 16:54:17 +01:00
vec_str_options_t vector_str_options ;
2020-07-08 18:42:14 +02:00
vec_cellstr_options_t vector_cellstr_options ;
2017-02-08 18:29:57 +01:00
int getNumberOfOptions ( ) const ;
2008-02-03 11:28:36 +01:00
void writeOutput ( ostream & output ) const ;
2008-04-05 12:52:58 +02:00
void writeOutput ( ostream & output , const string & option_group ) const ;
2017-02-08 18:29:57 +01:00
void writeJsonOutput ( ostream & output ) const ;
2008-02-03 11:28:36 +01:00
void clear ( ) ;
} ;
# endif // ! _STATEMENT_HH