ComputingTasks.hh 13.3 KB
Newer Older
1
/*
2
 * Copyright (C) 2003-2009 Dynare Team
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
 *
 * 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 _COMPUTINGTASKS_HH
#define _COMPUTINGTASKS_HH

#include <ostream>

sebastien's avatar
sebastien committed
25
#include "SymbolList.hh"
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include "SymbolTable.hh"
#include "Statement.hh"
#include "ModelTree.hh"

class SteadyStatement : public Statement
{
private:
  const OptionsList options_list;
public:
  SteadyStatement(const OptionsList &options_list_arg);
  virtual void writeOutput(ostream &output, const string &basename) const;
};

class SteadySparseStatement : public Statement
{
private:
  const OptionsList options_list;
public:
  SteadySparseStatement(const OptionsList &options_list_arg);
  virtual void writeOutput(ostream &output, const string &basename) const;
};

class CheckStatement : public Statement
{
private:
  const OptionsList options_list;
public:
  CheckStatement(const OptionsList &options_list_arg);
  virtual void checkPass(ModFileStructure &mod_file_struct);
  virtual void writeOutput(ostream &output, const string &basename) const;
};

class SimulStatement : public Statement
{
private:
  const OptionsList options_list;
public:
  SimulStatement(const OptionsList &options_list_arg);
  virtual void checkPass(ModFileStructure &mod_file_struct);
  virtual void writeOutput(ostream &output, const string &basename) const;
};

class SimulSparseStatement : public Statement
{
private:
  const OptionsList options_list;
72
  const int mode;
73
public:
74
  SimulSparseStatement(const OptionsList &options_list_arg, int mode_arg);
75
76
77
78
  virtual void checkPass(ModFileStructure &mod_file_struct);
  virtual void writeOutput(ostream &output, const string &basename) const;
};

ferhat's avatar
ferhat committed
79
class ModelInfoStatement : public Statement
80
81
82
83
{
private:
  const OptionsList options_list;
public:
ferhat's avatar
ferhat committed
84
  ModelInfoStatement(const OptionsList &options_list_arg);
85
86
87
88
  virtual void checkPass(ModFileStructure &mod_file_struct);
  virtual void writeOutput(ostream &output, const string &basename) const;
};

89
90
91
class StochSimulStatement : public Statement
{
private:
sebastien's avatar
sebastien committed
92
  const SymbolList symbol_list;
93
94
  const OptionsList options_list;
public:
sebastien's avatar
sebastien committed
95
  StochSimulStatement(const SymbolList &symbol_list_arg,
96
97
98
99
100
                      const OptionsList &options_list_arg);
  virtual void checkPass(ModFileStructure &mod_file_struct);
  virtual void writeOutput(ostream &output, const string &basename) const;
};

101
102
103
104
105
106
107
class ForecastStatement : public Statement
{
private:
  const SymbolList symbol_list;
  const OptionsList options_list;
public:
  ForecastStatement(const SymbolList &symbol_list_arg,
108
                    const OptionsList &options_list_arg);
109
110
111
112
  virtual void checkPass(ModFileStructure &mod_file_struct);
  virtual void writeOutput(ostream &output, const string &basename) const;
};

113
114
115
class RamseyPolicyStatement : public Statement
{
private:
sebastien's avatar
sebastien committed
116
  const SymbolList symbol_list;
117
118
  const OptionsList options_list;
public:
sebastien's avatar
sebastien committed
119
  RamseyPolicyStatement(const SymbolList &symbol_list_arg,
120
121
122
123
124
125
126
127
                        const OptionsList &options_list_arg);
  virtual void checkPass(ModFileStructure &mod_file_struct);
  virtual void writeOutput(ostream &output, const string &basename) const;
};

class RplotStatement : public Statement
{
private:
sebastien's avatar
sebastien committed
128
  const SymbolList symbol_list;
129
130
  const OptionsList options_list;
public:
sebastien's avatar
sebastien committed
131
  RplotStatement(const SymbolList &symbol_list_arg,
132
133
134
135
136
137
138
                 const OptionsList &options_list_arg);
  virtual void writeOutput(ostream &output, const string &basename) const;
};

class UnitRootVarsStatement : public Statement
{
private:
sebastien's avatar
sebastien committed
139
  const SymbolList symbol_list;
140
public:
sebastien's avatar
sebastien committed
141
  UnitRootVarsStatement(const SymbolList &symbol_list_arg);
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
  virtual void writeOutput(ostream &output, const string &basename) const;
};

class PeriodsStatement : public Statement
{
private:
  const int periods;
public:
  PeriodsStatement(int periods_arg);
  virtual void writeOutput(ostream &output, const string &basename) const;
};

class CutoffStatement : public Statement
{
private:
  const double cutoff;
public:
  CutoffStatement(double cutoff_arg);
  virtual void writeOutput(ostream &output, const string &basename) const;
};

class MarkowitzStatement : public Statement
{
private:
  const double markowitz;
public:
  MarkowitzStatement(double markowitz_arg);
  virtual void writeOutput(ostream &output, const string &basename) const;
};

class DsampleStatement : public Statement
{
private:
  const int val1, val2;
public:
  DsampleStatement(int val1_arg);
  DsampleStatement(int val1_arg, int val2_arg);
  virtual void writeOutput(ostream &output, const string &basename) const;
};

class EstimationStatement : public Statement
{
private:
sebastien's avatar
sebastien committed
185
  const SymbolList symbol_list;
186
187
  const OptionsList options_list;
public:
sebastien's avatar
sebastien committed
188
  EstimationStatement(const SymbolList &symbol_list_arg,
189
190
191
192
193
194
195
196
                      const OptionsList &options_list_arg);
  virtual void checkPass(ModFileStructure &mod_file_struct);
  virtual void writeOutput(ostream &output, const string &basename) const;
};

class PriorAnalysisStatement : public Statement
{
private:
sebastien's avatar
sebastien committed
197
  const SymbolList symbol_list;
198
199
  const OptionsList options_list;
public:
sebastien's avatar
sebastien committed
200
  PriorAnalysisStatement(const SymbolList &symbol_list_arg,
201
202
203
204
205
206
207
                         const OptionsList &options_list_arg);
  virtual void writeOutput(ostream &output, const string &basename) const;
};

class PosteriorAnalysisStatement : public Statement
{
private:
sebastien's avatar
sebastien committed
208
  const SymbolList symbol_list;
209
210
  const OptionsList options_list;
public:
sebastien's avatar
sebastien committed
211
  PosteriorAnalysisStatement(const SymbolList &symbol_list_arg,
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
                             const OptionsList &options_list_arg);
  virtual void writeOutput(ostream &output, const string &basename) const;
};

class DynareSensitivityStatement : public Statement
{
private:
  const OptionsList options_list;
public:
  DynareSensitivityStatement(const OptionsList &options_list_arg);
  virtual void writeOutput(ostream &output, const string &basename) const;
};

class VarobsStatement : public Statement
{
private:
sebastien's avatar
sebastien committed
228
  const SymbolList symbol_list;
229
public:
sebastien's avatar
sebastien committed
230
  VarobsStatement(const SymbolList &symbol_list_arg);
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
  virtual void writeOutput(ostream &output, const string &basename) const;
};

class ObservationTrendsStatement : public Statement
{
public:
  typedef map<string, NodeID> trend_elements_type;
private:
  const trend_elements_type trend_elements;
  const SymbolTable &symbol_table;
public:
  ObservationTrendsStatement(const trend_elements_type &trend_elements_arg,
                             const SymbolTable &symbol_table_arg);
  virtual void writeOutput(ostream &output, const string &basename) const;
};

class OsrParamsStatement : public Statement
{
private:
sebastien's avatar
sebastien committed
250
  const SymbolList symbol_list;
251
public:
sebastien's avatar
sebastien committed
252
  OsrParamsStatement(const SymbolList &symbol_list_arg);
253
254
255
256
257
258
  virtual void writeOutput(ostream &output, const string &basename) const;
};

class OsrStatement : public Statement
{
private:
sebastien's avatar
sebastien committed
259
  const SymbolList symbol_list;
260
261
  const OptionsList options_list;
public:
sebastien's avatar
sebastien committed
262
  OsrStatement(const SymbolList &symbol_list_arg,
263
264
265
266
267
268
269
270
               const OptionsList &options_list_arg);
  virtual void checkPass(ModFileStructure &mod_file_struct);
  virtual void writeOutput(ostream &output, const string &basename) const;
};

class DynaTypeStatement : public Statement
{
private:
sebastien's avatar
sebastien committed
271
  const SymbolList symbol_list;
272
273
  const string filename;
public:
sebastien's avatar
sebastien committed
274
  DynaTypeStatement(const SymbolList &symbol_list_arg,
sebastien's avatar
trunk:    
sebastien committed
275
                    const string &filename_arg);
276
277
278
279
280
281
  virtual void writeOutput(ostream &output, const string &basename) const;
};

class DynaSaveStatement : public Statement
{
private:
sebastien's avatar
sebastien committed
282
  const SymbolList symbol_list;
283
284
  const string filename;
public:
sebastien's avatar
sebastien committed
285
  DynaSaveStatement(const SymbolList &symbol_list_arg,
sebastien's avatar
trunk:    
sebastien committed
286
                    const string &filename_arg);
287
288
289
290
291
292
  virtual void writeOutput(ostream &output, const string &basename) const;
};

class ModelComparisonStatement : public Statement
{
public:
sebastien's avatar
trunk:    
sebastien committed
293
  typedef vector<pair<string, string> > filename_list_type;
294
295
296
297
298
299
300
301
302
private:
  filename_list_type filename_list;
  OptionsList options_list;
public:
  ModelComparisonStatement(const filename_list_type &filename_list_arg,
                           const OptionsList &options_list_arg);
  virtual void writeOutput(ostream &output, const string &basename) const;
};

303
304
//! Temporary structure used when parsing estimation_params* statements
class EstimationParams
305
{
306
public:
307
  int type;
308
309
310
311
  string name, name2, prior;
  NodeID init_val, low_bound, up_bound, mean, std, p3, p4, jscale;

  void init(const DataTree &datatree)
312
313
314
315
316
  {
    type = 0;
    name = "";
    name2 = "";
    prior = "NaN";
317
318
319
320
321
322
323
324
    init_val = datatree.NaN;
    low_bound = datatree.MinusInfinity;
    up_bound = datatree.Infinity;
    mean = datatree.NaN;
    std = datatree.NaN;
    p3 = datatree.NaN;
    p4 = datatree.NaN;
    jscale = datatree.NaN;
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
  }
};

class EstimatedParamsStatement : public Statement
{
private:
  const vector<EstimationParams> estim_params_list;
  const SymbolTable &symbol_table;
public:
  EstimatedParamsStatement(const vector<EstimationParams> &estim_params_list_arg,
                           const SymbolTable &symbol_table_arg);
  virtual void writeOutput(ostream &output, const string &basename) const;
};

class EstimatedParamsInitStatement : public Statement
{
private:
  const vector<EstimationParams> estim_params_list;
  const SymbolTable &symbol_table;
public:
  EstimatedParamsInitStatement(const vector<EstimationParams> &estim_params_list_arg,
                               const SymbolTable &symbol_table_arg);
  virtual void writeOutput(ostream &output, const string &basename) const;
};

class EstimatedParamsBoundsStatement : public Statement
{
private:
  const vector<EstimationParams> estim_params_list;
  const SymbolTable &symbol_table;
public:
  EstimatedParamsBoundsStatement(const vector<EstimationParams> &estim_params_list_arg,
                                 const SymbolTable &symbol_table_arg);
  virtual void writeOutput(ostream &output, const string &basename) const;
};

class OptimWeightsStatement : public Statement
{
public:
  typedef map<string, NodeID> var_weights_type;
  typedef map<pair<string, string>, NodeID> covar_weights_type;
private:
  const var_weights_type var_weights;
  const covar_weights_type covar_weights;
  const SymbolTable &symbol_table;
public:
  OptimWeightsStatement(const var_weights_type &var_weights_arg,
                        const covar_weights_type &covar_weights_arg,
                        const SymbolTable &symbol_table_arg);
  virtual void writeOutput(ostream &output, const string &basename) const;
};

class CalibStatement : public Statement
{
private:
  const int covar;
public:
  CalibStatement(int covar_arg);
  virtual void writeOutput(ostream &output, const string &basename) const;
};

class CalibVarStatement : public Statement
{
public:
  //! Maps a variable to a pair (weight, expression)
  typedef map<string, pair<string, NodeID> > calib_var_type;
  //! Maps a pair of variables to a pair (weight, expression)
  typedef map<pair<string, string>, pair<string, NodeID> > calib_covar_type;
  //! Maps a pair (variable, autocorr) to a pair (weight, expression)
  typedef map<pair<string, int>, pair<string, NodeID> > calib_ac_type;
private:
  const calib_var_type calib_var;
  const calib_covar_type calib_covar;
  const calib_ac_type calib_ac;
  const SymbolTable &symbol_table;
public:
  CalibVarStatement(const calib_var_type &calib_var_arg,
                    const calib_covar_type &calib_covar_arg,
                    const calib_ac_type &calib_ac_arg,
                    const SymbolTable &symbol_table_arg);
  virtual void writeOutput(ostream &output, const string &basename) const;
};

/*! \todo Make model_tree a member instead of a pointer */
class PlannerObjectiveStatement : public Statement
{
private:
  ModelTree *model_tree;
public:
  //! Constructor
  /*! \param model_tree_arg the model tree used to store the objective function.
    It is owned by the PlannerObjectiveStatement, and will be deleted by its destructor */
  PlannerObjectiveStatement(ModelTree *model_tree_arg);
  virtual ~PlannerObjectiveStatement();
  /*! \todo check there are only endogenous variables at the current period in the objective
    (no exogenous, no lead/lag) */
  virtual void checkPass(ModFileStructure &mod_file_struct);
422
  /*! \todo allow for the possibility of disabling temporary terms */
423
424
425
426
427
428
429
430
431
432
433
  virtual void computingPass();
  virtual void writeOutput(ostream &output, const string &basename) const;
};

class BVARDensityStatement : public Statement
{
private:
  const int maxnlags;
  const OptionsList options_list;
public:
  BVARDensityStatement(int maxnlags_arg, const OptionsList &options_list_arg);
434
  virtual void checkPass(ModFileStructure &mod_file_struct);
435
436
437
438
439
440
441
442
443
444
  virtual void writeOutput(ostream &output, const string &basename) const;
};

class BVARForecastStatement : public Statement
{
private:
  const int nlags;
  const OptionsList options_list;
public:
  BVARForecastStatement(int nlags_arg, const OptionsList &options_list_arg);
445
  virtual void checkPass(ModFileStructure &mod_file_struct);
446
447
448
449
  virtual void writeOutput(ostream &output, const string &basename) const;
};

#endif