ComputingTasks.hh 15.2 KB
Newer Older
sebastien's avatar
sebastien committed
1
/*
Sébastien Villemot's avatar
Sébastien Villemot committed
2
 * Copyright (C) 2003-2010 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/>.
 */

20
21
#ifndef _COMPUTINGTASKS_HH
#define _COMPUTINGTASKS_HH
sebastien's avatar
sebastien committed
22
23
24

#include <ostream>

sebastien's avatar
sebastien committed
25
#include "SymbolList.hh"
26
#include "SymbolTable.hh"
sebastien's avatar
sebastien committed
27
#include "Statement.hh"
sebastien's avatar
sebastien committed
28
#include "StaticModel.hh"
29
#include "DynamicModel.hh"
sebastien's avatar
sebastien committed
30
31
32
33
34
35

class SteadyStatement : public Statement
{
private:
  const OptionsList options_list;
public:
36
  SteadyStatement(const OptionsList &options_list_arg);
37
  virtual void checkPass(ModFileStructure &mod_file_struct);
sebastien's avatar
sebastien committed
38
  virtual void writeOutput(ostream &output, const string &basename) const;
sebastien's avatar
sebastien committed
39
40
41
42
43
44
45
46
};

class CheckStatement : public Statement
{
private:
  const OptionsList options_list;
public:
  CheckStatement(const OptionsList &options_list_arg);
47
  virtual void checkPass(ModFileStructure &mod_file_struct);
sebastien's avatar
sebastien committed
48
  virtual void writeOutput(ostream &output, const string &basename) const;
sebastien's avatar
sebastien committed
49
50
51
52
53
54
55
};

class SimulStatement : public Statement
{
private:
  const OptionsList options_list;
public:
56
  SimulStatement(const OptionsList &options_list_arg);
sebastien's avatar
sebastien committed
57
58
59
60
  virtual void checkPass(ModFileStructure &mod_file_struct);
  virtual void writeOutput(ostream &output, const string &basename) const;
};

ferhat's avatar
ferhat committed
61
class ModelInfoStatement : public Statement
62
63
64
65
{
private:
  const OptionsList options_list;
public:
ferhat's avatar
ferhat committed
66
  ModelInfoStatement(const OptionsList &options_list_arg);
67
68
69
70
  virtual void checkPass(ModFileStructure &mod_file_struct);
  virtual void writeOutput(ostream &output, const string &basename) const;
};

sebastien's avatar
sebastien committed
71
72
73
class StochSimulStatement : public Statement
{
private:
sebastien's avatar
sebastien committed
74
  const SymbolList symbol_list;
sebastien's avatar
sebastien committed
75
76
  const OptionsList options_list;
public:
sebastien's avatar
sebastien committed
77
  StochSimulStatement(const SymbolList &symbol_list_arg,
78
                      const OptionsList &options_list_arg);
sebastien's avatar
sebastien committed
79
  virtual void checkPass(ModFileStructure &mod_file_struct);
sebastien's avatar
sebastien committed
80
  virtual void writeOutput(ostream &output, const string &basename) const;
sebastien's avatar
sebastien committed
81
82
};

83
84
85
86
87
88
89
class ForecastStatement : public Statement
{
private:
  const SymbolList symbol_list;
  const OptionsList options_list;
public:
  ForecastStatement(const SymbolList &symbol_list_arg,
90
                    const OptionsList &options_list_arg);
91
92
93
  virtual void writeOutput(ostream &output, const string &basename) const;
};

michel's avatar
michel committed
94
95
96
class RamseyPolicyStatement : public Statement
{
private:
sebastien's avatar
sebastien committed
97
  const SymbolList symbol_list;
michel's avatar
michel committed
98
99
  const OptionsList options_list;
public:
sebastien's avatar
sebastien committed
100
  RamseyPolicyStatement(const SymbolList &symbol_list_arg,
sebastien's avatar
sebastien committed
101
                        const OptionsList &options_list_arg);
michel's avatar
michel committed
102
103
104
105
  virtual void checkPass(ModFileStructure &mod_file_struct);
  virtual void writeOutput(ostream &output, const string &basename) const;
};

sebastien's avatar
sebastien committed
106
107
108
class RplotStatement : public Statement
{
private:
sebastien's avatar
sebastien committed
109
  const SymbolList symbol_list;
sebastien's avatar
sebastien committed
110
111
  const OptionsList options_list;
public:
sebastien's avatar
sebastien committed
112
  RplotStatement(const SymbolList &symbol_list_arg,
sebastien's avatar
sebastien committed
113
                 const OptionsList &options_list_arg);
sebastien's avatar
sebastien committed
114
  virtual void writeOutput(ostream &output, const string &basename) const;
sebastien's avatar
sebastien committed
115
116
117
118
119
};

class UnitRootVarsStatement : public Statement
{
private:
sebastien's avatar
sebastien committed
120
  const SymbolList symbol_list;
sebastien's avatar
sebastien committed
121
public:
sebastien's avatar
sebastien committed
122
  UnitRootVarsStatement(const SymbolList &symbol_list_arg);
sebastien's avatar
sebastien committed
123
  virtual void writeOutput(ostream &output, const string &basename) const;
sebastien's avatar
sebastien committed
124
125
126
127
128
129
130
131
};

class PeriodsStatement : public Statement
{
private:
  const int periods;
public:
  PeriodsStatement(int periods_arg);
sebastien's avatar
sebastien committed
132
  virtual void writeOutput(ostream &output, const string &basename) const;
sebastien's avatar
sebastien committed
133
134
135
136
137
138
139
140
141
};

class DsampleStatement : public Statement
{
private:
  const int val1, val2;
public:
  DsampleStatement(int val1_arg);
  DsampleStatement(int val1_arg, int val2_arg);
sebastien's avatar
sebastien committed
142
  virtual void writeOutput(ostream &output, const string &basename) const;
sebastien's avatar
sebastien committed
143
144
145
146
147
};

class EstimationStatement : public Statement
{
private:
sebastien's avatar
sebastien committed
148
  const SymbolList symbol_list;
sebastien's avatar
sebastien committed
149
  const OptionsList options_list;
150
  const SymbolTable &symbol_table;
sebastien's avatar
sebastien committed
151
public:
sebastien's avatar
sebastien committed
152
  EstimationStatement(const SymbolList &symbol_list_arg,
153
154
                      const OptionsList &options_list_arg,
                      const SymbolTable &symbol_table);
sebastien's avatar
sebastien committed
155
  virtual void checkPass(ModFileStructure &mod_file_struct);
sebastien's avatar
sebastien committed
156
  virtual void writeOutput(ostream &output, const string &basename) const;
sebastien's avatar
sebastien committed
157
158
};

159
160
161
162
163
164
class DynareSensitivityStatement : public Statement
{
private:
  const OptionsList options_list;
public:
  DynareSensitivityStatement(const OptionsList &options_list_arg);
sebastien's avatar
sebastien committed
165
  virtual void checkPass(ModFileStructure &mod_file_struct);
166
167
168
  virtual void writeOutput(ostream &output, const string &basename) const;
};

sebastien's avatar
sebastien committed
169
170
171
class ObservationTrendsStatement : public Statement
{
public:
172
  typedef map<string, NodeID> trend_elements_t;
sebastien's avatar
sebastien committed
173
private:
174
  const trend_elements_t trend_elements;
sebastien's avatar
sebastien committed
175
176
  const SymbolTable &symbol_table;
public:
177
  ObservationTrendsStatement(const trend_elements_t &trend_elements_arg,
sebastien's avatar
sebastien committed
178
                             const SymbolTable &symbol_table_arg);
sebastien's avatar
sebastien committed
179
  virtual void writeOutput(ostream &output, const string &basename) const;
sebastien's avatar
sebastien committed
180
181
182
183
184
};

class OsrParamsStatement : public Statement
{
private:
sebastien's avatar
sebastien committed
185
  const SymbolList symbol_list;
sebastien's avatar
sebastien committed
186
public:
sebastien's avatar
sebastien committed
187
  OsrParamsStatement(const SymbolList &symbol_list_arg);
sebastien's avatar
sebastien committed
188
  virtual void writeOutput(ostream &output, const string &basename) const;
sebastien's avatar
sebastien committed
189
190
191
192
193
};

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

class DynaTypeStatement : public Statement
{
private:
sebastien's avatar
sebastien committed
206
  const SymbolList symbol_list;
sebastien's avatar
sebastien committed
207
208
  const string filename;
public:
sebastien's avatar
sebastien committed
209
  DynaTypeStatement(const SymbolList &symbol_list_arg,
sebastien's avatar
trunk:    
sebastien committed
210
                    const string &filename_arg);
sebastien's avatar
sebastien committed
211
  virtual void writeOutput(ostream &output, const string &basename) const;
sebastien's avatar
sebastien committed
212
213
214
215
216
};

class DynaSaveStatement : public Statement
{
private:
sebastien's avatar
sebastien committed
217
  const SymbolList symbol_list;
sebastien's avatar
sebastien committed
218
219
  const string filename;
public:
sebastien's avatar
sebastien committed
220
  DynaSaveStatement(const SymbolList &symbol_list_arg,
sebastien's avatar
trunk:    
sebastien committed
221
                    const string &filename_arg);
sebastien's avatar
sebastien committed
222
  virtual void writeOutput(ostream &output, const string &basename) const;
sebastien's avatar
sebastien committed
223
224
225
226
227
};

class ModelComparisonStatement : public Statement
{
public:
228
  typedef vector<pair<string, string> > filename_list_t;
sebastien's avatar
sebastien committed
229
private:
230
  filename_list_t filename_list;
sebastien's avatar
sebastien committed
231
232
  OptionsList options_list;
public:
233
  ModelComparisonStatement(const filename_list_t &filename_list_arg,
sebastien's avatar
sebastien committed
234
                           const OptionsList &options_list_arg);
sebastien's avatar
sebastien committed
235
  virtual void writeOutput(ostream &output, const string &basename) const;
sebastien's avatar
sebastien committed
236
237
};

238
239
//! Temporary structure used when parsing estimation_params* statements
class EstimationParams
240
{
241
public:
242
  int type;
243
244
245
  string name, name2, prior;
  NodeID init_val, low_bound, up_bound, mean, std, p3, p4, jscale;

246
247
  void
  init(const DataTree &datatree)
248
249
250
251
252
  {
    type = 0;
    name = "";
    name2 = "";
    prior = "NaN";
253
254
255
256
257
258
259
260
    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;
261
262
263
  }
};

sebastien's avatar
sebastien committed
264
class EstimatedParamsStatement : public Statement
265
{
sebastien's avatar
sebastien committed
266
267
private:
  const vector<EstimationParams> estim_params_list;
268
  const SymbolTable &symbol_table;
sebastien's avatar
sebastien committed
269
270
271
public:
  EstimatedParamsStatement(const vector<EstimationParams> &estim_params_list_arg,
                           const SymbolTable &symbol_table_arg);
272
  virtual void checkPass(ModFileStructure &mod_file_struct);
sebastien's avatar
sebastien committed
273
  virtual void writeOutput(ostream &output, const string &basename) const;
sebastien's avatar
sebastien committed
274
};
275

sebastien's avatar
sebastien committed
276
277
278
279
280
281
282
283
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);
sebastien's avatar
sebastien committed
284
  virtual void writeOutput(ostream &output, const string &basename) const;
sebastien's avatar
sebastien committed
285
};
286

sebastien's avatar
sebastien committed
287
288
289
290
291
292
293
294
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);
sebastien's avatar
sebastien committed
295
  virtual void writeOutput(ostream &output, const string &basename) const;
sebastien's avatar
sebastien committed
296
};
297

sebastien's avatar
sebastien committed
298
299
300
class OptimWeightsStatement : public Statement
{
public:
301
302
  typedef map<string, NodeID> var_weights_t;
  typedef map<pair<string, string>, NodeID> covar_weights_t;
sebastien's avatar
sebastien committed
303
private:
304
305
  const var_weights_t var_weights;
  const covar_weights_t covar_weights;
sebastien's avatar
sebastien committed
306
307
  const SymbolTable &symbol_table;
public:
308
309
  OptimWeightsStatement(const var_weights_t &var_weights_arg,
                        const covar_weights_t &covar_weights_arg,
sebastien's avatar
sebastien committed
310
                        const SymbolTable &symbol_table_arg);
sebastien's avatar
sebastien committed
311
  virtual void writeOutput(ostream &output, const string &basename) const;
sebastien's avatar
sebastien committed
312
};
313

sebastien's avatar
sebastien committed
314
315
316
317
318
319
class CalibStatement : public Statement
{
private:
  const int covar;
public:
  CalibStatement(int covar_arg);
sebastien's avatar
sebastien committed
320
  virtual void writeOutput(ostream &output, const string &basename) const;
sebastien's avatar
sebastien committed
321
};
322

sebastien's avatar
sebastien committed
323
324
325
326
class CalibVarStatement : public Statement
{
public:
  //! Maps a variable to a pair (weight, expression)
327
  typedef map<string, pair<string, NodeID> > calib_var_t;
sebastien's avatar
sebastien committed
328
  //! Maps a pair of variables to a pair (weight, expression)
329
  typedef map<pair<string, string>, pair<string, NodeID> > calib_covar_t;
sebastien's avatar
sebastien committed
330
  //! Maps a pair (variable, autocorr) to a pair (weight, expression)
331
  typedef map<pair<string, int>, pair<string, NodeID> > calib_ac_t;
sebastien's avatar
sebastien committed
332
private:
333
334
335
  const calib_var_t calib_var;
  const calib_covar_t calib_covar;
  const calib_ac_t calib_ac;
sebastien's avatar
sebastien committed
336
337
  const SymbolTable &symbol_table;
public:
338
339
340
  CalibVarStatement(const calib_var_t &calib_var_arg,
                    const calib_covar_t &calib_covar_arg,
                    const calib_ac_t &calib_ac_arg,
sebastien's avatar
sebastien committed
341
                    const SymbolTable &symbol_table_arg);
sebastien's avatar
sebastien committed
342
343
344
345
346
347
348
  virtual void writeOutput(ostream &output, const string &basename) const;
};

/*! \todo Make model_tree a member instead of a pointer */
class PlannerObjectiveStatement : public Statement
{
private:
sebastien's avatar
sebastien committed
349
  StaticModel *model_tree;
sebastien's avatar
sebastien committed
350
351
352
353
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 */
sebastien's avatar
sebastien committed
354
  PlannerObjectiveStatement(StaticModel *model_tree_arg);
sebastien's avatar
sebastien committed
355
356
357
358
  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);
359
  /*! \todo allow for the possibility of disabling temporary terms */
sebastien's avatar
sebastien committed
360
361
  virtual void computingPass();
  virtual void writeOutput(ostream &output, const string &basename) const;
362
};
sebastien's avatar
sebastien committed
363

364
365
366
367
368
369
370
class BVARDensityStatement : public Statement
{
private:
  const int maxnlags;
  const OptionsList options_list;
public:
  BVARDensityStatement(int maxnlags_arg, const OptionsList &options_list_arg);
371
  virtual void checkPass(ModFileStructure &mod_file_struct);
372
373
  virtual void writeOutput(ostream &output, const string &basename) const;
};
ferhat's avatar
ferhat committed
374

375
376
377
378
379
380
381
class BVARForecastStatement : public Statement
{
private:
  const int nlags;
  const OptionsList options_list;
public:
  BVARForecastStatement(int nlags_arg, const OptionsList &options_list_arg);
382
  virtual void checkPass(ModFileStructure &mod_file_struct);
383
384
  virtual void writeOutput(ostream &output, const string &basename) const;
};
ferhat's avatar
ferhat committed
385

386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
class SBVARStatement : public Statement
{
private:
  const OptionsList options_list;
public:
  SBVARStatement(const OptionsList &options_list_arg);
  virtual void checkPass(ModFileStructure &mod_file_struct);
  virtual void writeOutput(ostream &output, const string &basename) const;
};

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

sebastien's avatar
sebastien committed
406
407
class IdentificationStatement : public Statement
{
sebastien's avatar
sebastien committed
408
409
private:
  const OptionsList options_list;
sebastien's avatar
sebastien committed
410
public:
sebastien's avatar
sebastien committed
411
  IdentificationStatement(const OptionsList &options_list_arg);
sebastien's avatar
sebastien committed
412
413
414
415
  virtual void checkPass(ModFileStructure &mod_file_struct);
  virtual void writeOutput(ostream &output, const string &basename) const;
};

416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
class WriteLatexDynamicModelStatement : public Statement
{
private:
  const DynamicModel &dynamic_model;
public:
  WriteLatexDynamicModelStatement(const DynamicModel &dynamic_model_arg);
  virtual void writeOutput(ostream &output, const string &basename) const;
};

class WriteLatexStaticModelStatement : public Statement
{
private:
  const StaticModel &static_model;
public:
  WriteLatexStaticModelStatement(const StaticModel &static_model_arg);
  virtual void writeOutput(ostream &output, const string &basename) const;
};

434
435
436
437
438
439
440
class ShockDecompositionStatement : public Statement
{
private:
  const SymbolList symbol_list;
  const OptionsList options_list;
public:
  ShockDecompositionStatement(const SymbolList &symbol_list_arg,
441
                              const OptionsList &options_list_arg);
442
443
444
  virtual void writeOutput(ostream &output, const string &basename) const;
};

445
446
447
448
449
450
451
452
453
454
455
456
class ConditionalForecastStatement : public Statement
{
private:
  const OptionsList options_list;
public:
  ConditionalForecastStatement(const OptionsList &options_list_arg);
  virtual void writeOutput(ostream &output, const string &basename) const;
};

class PlotConditionalForecastStatement : public Statement
{
private:
457
  //! A value of -1 indicates that the user didn't specify a value
458
459
460
461
462
463
464
  const int periods;
  const SymbolList symbol_list;
public:
  PlotConditionalForecastStatement(int periods_arg, const SymbolList &symbol_list_arg);
  virtual void writeOutput(ostream &output, const string &basename) const;
};

houtanb's avatar
houtanb committed
465
466
467
class SvarIdentificationStatement : public Statement
{
public:
468
  typedef map<pair<int, int>, vector<int> > svar_identification_exclusion_t;
houtanb's avatar
houtanb committed
469
private:
470
  const svar_identification_exclusion_t exclusion;
houtanb's avatar
houtanb committed
471
472
473
474
475
  const bool upper_cholesky_present;
  const bool lower_cholesky_present;
  const SymbolTable &symbol_table;
  int getMaxLag() const;
public:
476
  SvarIdentificationStatement(const svar_identification_exclusion_t &exclusion_arg,
houtanb's avatar
houtanb committed
477
478
479
480
481
482
483
                              const bool &upper_cholesky_present_arg,
                              const bool &lower_cholesky_present_arg,
                              const SymbolTable &symbol_table_arg);
  virtual void checkPass(ModFileStructure &mod_file_struct);
  virtual void writeOutput(ostream &output, const string &basename) const;
};

houtanb's avatar
houtanb committed
484
485
486
487
488
489
490
491
492
class MarkovSwitchingStatement : public Statement
{
private:
  const OptionsList options_list;
public:
  MarkovSwitchingStatement(const OptionsList &options_list_arg);
  virtual void writeOutput(ostream &output, const string &basename) const;
};

houtanb's avatar
houtanb committed
493
494
495
496
497
498
499
500
501
class SvarStatement : public Statement
{
private:
  const OptionsList options_list;
public:
  SvarStatement(const OptionsList &options_list_arg);
  virtual void writeOutput(ostream &output, const string &basename) const;
};

502
#endif