Shocks.hh 3.47 KB
Newer Older
1
/*
Sébastien Villemot's avatar
Sébastien Villemot committed
2
 * Copyright (C) 2003-2010 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
  typedef map<int, vector<DetShockElement> > det_shocks_t;
43
44
45
protected:
  //! Is this statement a "mshocks" statement ? (instead of a "shocks" statement)
  const bool mshocks;
46
  const det_shocks_t det_shocks;
47
48
49
50
  const SymbolTable &symbol_table;
  void writeDetShocks(ostream &output) const;

  AbstractShocksStatement(bool mshocks_arg,
51
                          const det_shocks_t &det_shocks_arg,
52
53
54
55
56
                          const SymbolTable &symbol_table_arg);
};

class ShocksStatement : public AbstractShocksStatement
{
57
public:
58
59
  typedef map<int, expr_t> var_and_std_shocks_t;
  typedef map<pair<int, int>, expr_t> covar_and_corr_shocks_t;
60
private:
61
62
63
  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;
64
  void writeVarAndStdShocks(ostream &output) const;
65
  void writeCovarOrCorrShock(ostream &output, covar_and_corr_shocks_t::const_iterator &it, bool corr) const;
66
  void writeCovarAndCorrShocks(ostream &output) const;
67
public:
68
69
70
71
72
  ShocksStatement(const det_shocks_t &det_shocks_arg,
                  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,
73
74
                  const SymbolTable &symbol_table_arg);
  virtual void writeOutput(ostream &output, const string &basename) const;
75
  virtual void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings);
76
77
78
79
80
};

class MShocksStatement : public AbstractShocksStatement
{
public:
81
  MShocksStatement(const det_shocks_t &det_shocks_arg,
82
83
                   const SymbolTable &symbol_table_arg);
  virtual void writeOutput(ostream &output, const string &basename) const;
84
  virtual void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings);
85
86
};

87
88
89
class ConditionalForecastPathsStatement : public Statement
{
private:
90
  const AbstractShocksStatement::det_shocks_t paths;
91
92
93
  const SymbolTable &symbol_table;
  int path_length;
public:
94
  ConditionalForecastPathsStatement(const AbstractShocksStatement::det_shocks_t &paths_arg,
95
                                    const SymbolTable &symbol_table_arg);
96
  virtual void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings);
97
98
99
  virtual void writeOutput(ostream &output, const string &basename) const;
};

100
#endif