Shocks.hh 5.27 KB
Newer Older
1
/*
Houtan Bastani's avatar
Houtan Bastani committed
2
 * Copyright (C) 2003-2016 Dynare Team
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
 *
 * 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/>.
 */

#ifndef _SHOCKS_HH
#define _SHOCKS_HH

using namespace std;

#include <string>
#include <vector>
#include <map>

#include "Statement.hh"
#include "SymbolTable.hh"
#include "ExprNode.hh"

class AbstractShocksStatement : public Statement
{
public:
  struct DetShockElement
  {
    int period1;
    int period2;
40
    expr_t value;
41
  };
42
43
  //The boolean element indicates if the shock is a surprise (false) or a perfect foresight (true) shock.
  //This boolean is used only in case of conditional forecast with extended path method (simulation_type = deterministic).
44
  typedef map<int, vector<DetShockElement> > det_shocks_t;
45
46
47
protected:
  //! Is this statement a "mshocks" statement ? (instead of a "shocks" statement)
  const bool mshocks;
48
49
  //! Does this "shocks" statement replace the previous ones?
  const bool overwrite;
50
  const det_shocks_t det_shocks;
51
52
  const SymbolTable &symbol_table;
  void writeDetShocks(ostream &output) const;
53

54
  AbstractShocksStatement(bool mshocks_arg, bool overwrite_arg,
55
                          const det_shocks_t &det_shocks_arg,
56
57
58
59
60
                          const SymbolTable &symbol_table_arg);
};

class ShocksStatement : public AbstractShocksStatement
{
61
public:
62
63
  typedef map<int, expr_t> var_and_std_shocks_t;
  typedef map<pair<int, int>, expr_t> covar_and_corr_shocks_t;
64
private:
65
66
67
  const var_and_std_shocks_t var_shocks, std_shocks;
  const covar_and_corr_shocks_t covar_shocks, corr_shocks;
  void writeVarOrStdShock(ostream &output, var_and_std_shocks_t::const_iterator &it, bool stddev) const;
68
  void writeVarAndStdShocks(ostream &output) const;
69
  void writeCovarOrCorrShock(ostream &output, covar_and_corr_shocks_t::const_iterator &it, bool corr) const;
70
  void writeCovarAndCorrShocks(ostream &output) const;
71
  bool has_calibrated_measurement_errors() const;
72
public:
73
74
  ShocksStatement(bool overwrite_arg,
                  const det_shocks_t &det_shocks_arg,
75
76
77
78
                  const var_and_std_shocks_t &var_shocks_arg,
                  const var_and_std_shocks_t &std_shocks_arg,
                  const covar_and_corr_shocks_t &covar_shocks_arg,
                  const covar_and_corr_shocks_t &corr_shocks_arg,
79
                  const SymbolTable &symbol_table_arg);
80
  virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const;
81
  virtual void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings);
82
83
84
85
86
};

class MShocksStatement : public AbstractShocksStatement
{
public:
87
88
  MShocksStatement(bool overwrite_arg,
                   const det_shocks_t &det_shocks_arg,
89
                   const SymbolTable &symbol_table_arg);
90
  virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const;
91
92
};

93
94
95
class ConditionalForecastPathsStatement : public Statement
{
private:
96
  const AbstractShocksStatement::det_shocks_t paths;
97
98
  int path_length;
public:
99
  ConditionalForecastPathsStatement(const AbstractShocksStatement::det_shocks_t &paths_arg);
100
  virtual void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings);
101
  virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const;
102
103
};

104
105
106
107
108
109
class MomentCalibration : public Statement
{
public:
  struct Constraint
  {
    int endo1, endo2;
110
    string lags;
111
112
113
114
115
116
117
118
119
    string lower_bound, upper_bound;
  };
  typedef vector<Constraint> constraints_t;
private:
  constraints_t constraints;
  const SymbolTable &symbol_table;
public:
  MomentCalibration(const constraints_t &constraints_arg,
                    const SymbolTable &symbol_table_arg);
120
  virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const;
121
122
123
124
125
126
127
};

class IrfCalibration : public Statement
{
public:
  struct Constraint
  {
128
    int endo;
129
    int exo;
130
    string periods, lower_bound, upper_bound;
131
132
133
134
135
  };
  typedef vector<Constraint> constraints_t;
private:
  constraints_t constraints;
  const SymbolTable &symbol_table;
136
  const OptionsList options_list;
137
138
public:
  IrfCalibration(const constraints_t &constraints_arg,
139
140
                 const SymbolTable &symbol_table_arg,
                 const OptionsList &options_list_arg);
141
  virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const;
142
143
};

144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
class ShockGroupsStatement : public Statement
{
public:
  struct Group
  {
    string name;
    vector<string> list;
  };
  typedef vector<Group> group_t;
private:
  group_t shock_groups;
  vector<string> group_names;
  string name;
public:
  ShockGroupsStatement(const group_t &shock_groups_arg, const string &name_arg);
  virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const;
};
  
162
#endif