Statement.hh 5.58 KB
Newer Older
sebastien's avatar
sebastien committed
1
/*
2
 * Copyright (C) 2006-2012 Dynare Team
sebastien's avatar
sebastien committed
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
 *
 * 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/>.
 */

sebastien's avatar
sebastien committed
20
21
22
23
24
25
26
27
28
#ifndef _STATEMENT_HH
#define _STATEMENT_HH

using namespace std;

#include <ostream>
#include <string>
#include <map>

sebastien's avatar
sebastien committed
29
#include "SymbolList.hh"
30
#include "WarningConsolidation.hh"
sebastien's avatar
sebastien committed
31

sebastien's avatar
sebastien committed
32
33
34
35
class ModFileStructure
{
public:
  ModFileStructure();
Houtan Bastani's avatar
Houtan Bastani committed
36
  //! Whether check is present
37
  bool check_present;
Houtan Bastani's avatar
Houtan Bastani committed
38
  //! Whether steady is present
39
  bool steady_present;
sebastien's avatar
sebastien committed
40
41
  //! Whether a simul statement is present
  bool simul_present;
sebastien's avatar
sebastien committed
42
43
44
45
46
47
  //! Whether a stoch_simul statement is present
  bool stoch_simul_present;
  //! Whether an estimation statement is present
  bool estimation_present;
  //! Whether an osr statement is present
  bool osr_present;
48
49
50
51
  //! Whether an osr params statement is present
  bool osr_params_present;
  //! Whether an optim weight statement is present
  bool optim_weights_present;
sebastien's avatar
sebastien committed
52
53
  //! Whether a ramsey_policy statement is present
  bool ramsey_policy_present;
54
55
  //! Whether a discretionary_objective statement is present
  bool discretionary_policy_present;
56
57
  //! Whether a planner_objective statement is present
  bool planner_objective_present;
58
  //! The value of the "order" option of stoch_simul, estimation, osr, ramsey_policy
59
60
  //! 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 */
sebastien's avatar
sebastien committed
61
  int order_option;
62
63
  //! Whether a bvar_density, bvar_forecast, sbvar, ms_sbvar statement is present
  bool bvar_present;
houtanb's avatar
houtanb committed
64
65
  //! Whether an svar_identification statement is present
  bool svar_identification_present;
sebastien's avatar
sebastien committed
66
  //! Whether an identification statement is present or the identification option of dynare_sensitivity statement is equal to one
sebastien's avatar
sebastien committed
67
  bool identification_present;
68
69
  //! Whether the option analytic_derivation is given to estimation
  bool estimation_analytic_derivation;
70
71
  //! Whether the option partial_information is given to stoch_simul/estimation/osr/ramsey_policy
  bool partial_information;
72
73
74
75
76
  //! Whether a shocks or mshocks block has been parsed and no simul command yet run
  /*! Used for the workaround for trac ticket #35. When a simul command is
      seen, this flag is cleared in order to allow a sequence
      shocks+endval+simul in a loop */
  bool shocks_present_but_simul_not_yet;
77
78
79
  //! Whether a histval bloc is present
  /*! Used for the workaround for trac ticket #157 */
  bool histval_present;
sebastien's avatar
sebastien committed
80
81
  //! Whether the "k_order_solver" option is used (explictly, or implicitly if order >= 3)
  bool k_order_solver;
Sébastien Villemot's avatar
Sébastien Villemot committed
82
83
  //! Whether there is a calibrated measurement error
  bool calibrated_measurement_errors;
84
85
  //! Whether dsge_prior_weight was initialized as a parameter
  bool dsge_prior_weight_initialized;
86
87
88
89
90
91
92
93
  //! Whether dsge_prior_weight is in the estimated_params block
  bool dsge_prior_weight_in_estimated_params;
  //! 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
  bool dsge_var_estimated;
  //! Whether there is a bayesian_irf option passed to the estimation statement
  bool bayesian_irf_present;
94
95
  //! Whether there is a data statement present
  bool estimation_data_statement_present;
96
97
  //! Last chain number for Markov Switching statement
  int last_markov_switching_chain;
sebastien's avatar
sebastien committed
98
99
};

sebastien's avatar
sebastien committed
100
101
102
103
class Statement
{
public:
  virtual ~Statement();
sebastien's avatar
sebastien committed
104
  //! Do some internal check, and fill the ModFileStructure class
105
106
107
108
  /*! 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. */
109
  virtual void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings);
sebastien's avatar
sebastien committed
110
  virtual void computingPass();
111
  //! Write Matlab output code
sebastien's avatar
sebastien committed
112
113
114
115
116
  /*!
    \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
  */
  virtual void writeOutput(ostream &output, const string &basename) const = 0;
sebastien's avatar
sebastien committed
117
118
119
120
121
122
123
124
};

class NativeStatement : public Statement
{
private:
  const string native_statement;
public:
  NativeStatement(const string &native_statement_arg);
sebastien's avatar
sebastien committed
125
  virtual void writeOutput(ostream &output, const string &basename) const;
sebastien's avatar
sebastien committed
126
127
128
129
130
};

class OptionsList
{
public:
131
132
133
  typedef map<string, string> num_options_t;
  typedef map<string, pair<string, string> > paired_num_options_t;
  typedef map<string, string> string_options_t;
134
  typedef map<string, string> date_options_t;
135
136
137
138
139
  typedef map<string, SymbolList> symbol_list_options_t;
  typedef map<string, vector<int> > vec_int_options_t;
  num_options_t num_options;
  paired_num_options_t paired_num_options;
  string_options_t string_options;
140
  date_options_t date_options;
141
142
  symbol_list_options_t symbol_list_options;
  vec_int_options_t vector_int_options;
sebastien's avatar
sebastien committed
143
  void writeOutput(ostream &output) const;
144
  void writeOutput(ostream &output, const string &option_group) const;
sebastien's avatar
sebastien committed
145
146
147
148
  void clear();
};

#endif // ! _STATEMENT_HH