Statement.cc 5.38 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
#include "Statement.hh"

sebastien's avatar
sebastien committed
22
ModFileStructure::ModFileStructure() :
23
  check_present(false),
24
  steady_present(false),
sebastien's avatar
sebastien committed
25
  simul_present(false),
sebastien's avatar
sebastien committed
26
27
28
  stoch_simul_present(false),
  estimation_present(false),
  osr_present(false),
29
30
  osr_params_present(false),
  optim_weights_present(false),
sebastien's avatar
sebastien committed
31
  ramsey_policy_present(false),
32
  discretionary_policy_present(false),
33
  planner_objective_present(false),
34
  order_option(0),
35
  bvar_present(false),
houtanb's avatar
houtanb committed
36
  svar_identification_present(false),
37
  identification_present(false),
Sébastien Villemot's avatar
Sébastien Villemot committed
38
  estimation_analytic_derivation(false),
39
  partial_information(false),
40
  shocks_present_but_simul_not_yet(false),
41
  histval_present(false),
Sébastien Villemot's avatar
Sébastien Villemot committed
42
  k_order_solver(false),
43
44
45
46
  calibrated_measurement_errors(false),
  dsge_prior_weight_in_estimated_params(false),
  dsge_var_calibrated(""),
  dsge_var_estimated(false),
47
48
  bayesian_irf_present(false),
  estimation_data_statement_present(false),
49
  last_markov_switching_chain(0)
sebastien's avatar
sebastien committed
50
51
52
{
}

sebastien's avatar
sebastien committed
53
54
55
56
Statement::~Statement()
{
}

sebastien's avatar
sebastien committed
57
void
58
Statement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings)
sebastien's avatar
sebastien committed
59
60
61
{
}

sebastien's avatar
sebastien committed
62
63
64
65
66
void
Statement::computingPass()
{
}

sebastien's avatar
sebastien committed
67
68
69
70
71
72
NativeStatement::NativeStatement(const string &native_statement_arg) :
  native_statement(native_statement_arg)
{
}

void
sebastien's avatar
sebastien committed
73
NativeStatement::writeOutput(ostream &output, const string &basename) const
sebastien's avatar
sebastien committed
74
75
76
77
78
79
80
{
  output << native_statement << endl;
}

void
OptionsList::writeOutput(ostream &output) const
{
81
  for (num_options_t::const_iterator it = num_options.begin();
82
       it != num_options.end(); it++)
sebastien's avatar
sebastien committed
83
84
    output << "options_." << it->first << " = " << it->second << ";" << endl;

85
  for (paired_num_options_t::const_iterator it = paired_num_options.begin();
86
       it != paired_num_options.end(); it++)
sebastien's avatar
sebastien committed
87
88
89
    output << "options_." << it->first << " = [" << it->second.first << "; "
           << it->second.second << "];" << endl;

90
  for (string_options_t::const_iterator it = string_options.begin();
91
       it != string_options.end(); it++)
sebastien's avatar
sebastien committed
92
    output << "options_." << it->first << " = '" << it->second << "';" << endl;
93

94
95
96
97
  for (date_options_t::const_iterator it = date_options.begin();
       it != date_options.end(); it++)
    output << "options_." << it->first << " = dynDate('" << it->second << "');" << endl;

98
  for (symbol_list_options_t::const_iterator it = symbol_list_options.begin();
99
       it != symbol_list_options.end(); it++)
sebastien's avatar
sebastien committed
100
    it->second.writeOutput("options_." + it->first, output);
101

102
  for (vec_int_options_t::const_iterator it = vector_int_options.begin();
103
       it != vector_int_options.end(); it++)
104
105
106
107
108
    {
      output << "options_." << it->first << " = ";
      if (it->second.size() > 1)
        {
          output << "[";
109
110
          for (vector<int>::const_iterator viit = it->second.begin();
               viit != it->second.end(); viit++)
111
112
113
114
115
116
            output << *viit << ";";
          output << "];" << endl;
        }
      else
        output << it->second.front() << ";" << endl;
    }
sebastien's avatar
sebastien committed
117
118
}

119
120
121
122
123
void
OptionsList::writeOutput(ostream &output, const string &option_group) const
{
  output << option_group << " = struct();" << endl;

124
  for (num_options_t::const_iterator it = num_options.begin();
125
       it != num_options.end(); it++)
126
127
    output << option_group << "." << it->first << " = " << it->second << ";" << endl;

128
  for (paired_num_options_t::const_iterator it = paired_num_options.begin();
129
       it != paired_num_options.end(); it++)
130
131
132
    output << option_group << "." << it->first << " = [" << it->second.first << "; "
           << it->second.second << "];" << endl;

133
  for (string_options_t::const_iterator it = string_options.begin();
134
       it != string_options.end(); it++)
135
136
    output << option_group << "." << it->first << " = '" << it->second << "';" << endl;

137
138
139
140
  for (date_options_t::const_iterator it = date_options.begin();
       it != date_options.end(); it++)
    output << option_group << "." << it->first << " = dynDate('" << it->second << "');" << endl;

141
  for (symbol_list_options_t::const_iterator it = symbol_list_options.begin();
142
       it != symbol_list_options.end(); it++)
sebastien's avatar
sebastien committed
143
    it->second.writeOutput(option_group + "." + it->first, output);
144

145
  for (vec_int_options_t::const_iterator it = vector_int_options.begin();
146
       it != vector_int_options.end(); it++)
147
148
149
150
151
    {
      output << option_group << "." << it->first << " = ";
      if (it->second.size() > 1)
        {
          output << "[";
152
153
          for (vector<int>::const_iterator viit = it->second.begin();
               viit != it->second.end(); viit++)
154
155
156
157
158
159
            output << *viit << ";";
          output << "];" << endl;
        }
      else
        output <<  it->second.front() << ";" << endl;
    }
160
161
}

sebastien's avatar
sebastien committed
162
163
164
165
166
167
void
OptionsList::clear()
{
  num_options.clear();
  paired_num_options.clear();
  string_options.clear();
168
  date_options.clear();
sebastien's avatar
sebastien committed
169
  symbol_list_options.clear();
170
  vector_int_options.clear();
sebastien's avatar
sebastien committed
171
}