ComputingTasks.hh 14.8 KB
Newer Older
sebastien's avatar
sebastien committed
1
/*
2
 * Copyright (C) 2003-2009 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
94
  virtual void checkPass(ModFileStructure &mod_file_struct);
  virtual void writeOutput(ostream &output, const string &basename) const;
};

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

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

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

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

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
143
  virtual void writeOutput(ostream &output, const string &basename) const;
sebastien's avatar
sebastien committed
144
145
146
147
148
};

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

class PriorAnalysisStatement : public Statement
{
private:
sebastien's avatar
sebastien committed
161
  const SymbolList symbol_list;
sebastien's avatar
sebastien committed
162
163
  const OptionsList options_list;
public:
sebastien's avatar
sebastien committed
164
  PriorAnalysisStatement(const SymbolList &symbol_list_arg,
sebastien's avatar
sebastien committed
165
                         const OptionsList &options_list_arg);
sebastien's avatar
sebastien committed
166
  virtual void writeOutput(ostream &output, const string &basename) const;
sebastien's avatar
sebastien committed
167
168
169
170
171
};

class PosteriorAnalysisStatement : public Statement
{
private:
sebastien's avatar
sebastien committed
172
  const SymbolList symbol_list;
sebastien's avatar
sebastien committed
173
174
  const OptionsList options_list;
public:
sebastien's avatar
sebastien committed
175
  PosteriorAnalysisStatement(const SymbolList &symbol_list_arg,
sebastien's avatar
sebastien committed
176
                             const OptionsList &options_list_arg);
sebastien's avatar
sebastien committed
177
  virtual void writeOutput(ostream &output, const string &basename) const;
sebastien's avatar
sebastien committed
178
179
};

180
181
182
183
184
185
class DynareSensitivityStatement : public Statement
{
private:
  const OptionsList options_list;
public:
  DynareSensitivityStatement(const OptionsList &options_list_arg);
sebastien's avatar
sebastien committed
186
  virtual void checkPass(ModFileStructure &mod_file_struct);
187
188
189
  virtual void writeOutput(ostream &output, const string &basename) const;
};

sebastien's avatar
sebastien committed
190
191
192
class VarobsStatement : public Statement
{
private:
sebastien's avatar
sebastien committed
193
  const SymbolList symbol_list;
sebastien's avatar
sebastien committed
194
public:
sebastien's avatar
sebastien committed
195
  VarobsStatement(const SymbolList &symbol_list_arg);
sebastien's avatar
sebastien committed
196
  virtual void writeOutput(ostream &output, const string &basename) const;
sebastien's avatar
sebastien committed
197
198
199
200
201
};

class ObservationTrendsStatement : public Statement
{
public:
sebastien's avatar
sebastien committed
202
  typedef map<string, NodeID> trend_elements_type;
sebastien's avatar
sebastien committed
203
204
205
206
207
208
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);
sebastien's avatar
sebastien committed
209
  virtual void writeOutput(ostream &output, const string &basename) const;
sebastien's avatar
sebastien committed
210
211
212
213
214
};

class OsrParamsStatement : public Statement
{
private:
sebastien's avatar
sebastien committed
215
  const SymbolList symbol_list;
sebastien's avatar
sebastien committed
216
public:
sebastien's avatar
sebastien committed
217
  OsrParamsStatement(const SymbolList &symbol_list_arg);
sebastien's avatar
sebastien committed
218
  virtual void writeOutput(ostream &output, const string &basename) const;
sebastien's avatar
sebastien committed
219
220
221
222
223
};

class OsrStatement : public Statement
{
private:
sebastien's avatar
sebastien committed
224
  const SymbolList symbol_list;
sebastien's avatar
sebastien committed
225
226
  const OptionsList options_list;
public:
sebastien's avatar
sebastien committed
227
  OsrStatement(const SymbolList &symbol_list_arg,
sebastien's avatar
sebastien committed
228
               const OptionsList &options_list_arg);
sebastien's avatar
sebastien committed
229
  virtual void checkPass(ModFileStructure &mod_file_struct);
sebastien's avatar
sebastien committed
230
  virtual void writeOutput(ostream &output, const string &basename) const;
sebastien's avatar
sebastien committed
231
232
233
234
235
};

class DynaTypeStatement : public Statement
{
private:
sebastien's avatar
sebastien committed
236
  const SymbolList symbol_list;
sebastien's avatar
sebastien committed
237
238
  const string filename;
public:
sebastien's avatar
sebastien committed
239
  DynaTypeStatement(const SymbolList &symbol_list_arg,
sebastien's avatar
trunk:    
sebastien committed
240
                    const string &filename_arg);
sebastien's avatar
sebastien committed
241
  virtual void writeOutput(ostream &output, const string &basename) const;
sebastien's avatar
sebastien committed
242
243
244
245
246
};

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

class ModelComparisonStatement : public Statement
{
public:
sebastien's avatar
trunk:    
sebastien committed
258
  typedef vector<pair<string, string> > filename_list_type;
sebastien's avatar
sebastien committed
259
260
261
262
263
264
private:
  filename_list_type filename_list;
  OptionsList options_list;
public:
  ModelComparisonStatement(const filename_list_type &filename_list_arg,
                           const OptionsList &options_list_arg);
sebastien's avatar
sebastien committed
265
  virtual void writeOutput(ostream &output, const string &basename) const;
sebastien's avatar
sebastien committed
266
267
};

268
269
//! Temporary structure used when parsing estimation_params* statements
class EstimationParams
270
{
271
public:
272
  int type;
273
274
275
276
  string name, name2, prior;
  NodeID init_val, low_bound, up_bound, mean, std, p3, p4, jscale;

  void init(const DataTree &datatree)
277
278
279
280
281
  {
    type = 0;
    name = "";
    name2 = "";
    prior = "NaN";
282
283
284
285
286
287
288
289
    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;
290
291
292
  }
};

sebastien's avatar
sebastien committed
293
class EstimatedParamsStatement : public Statement
294
{
sebastien's avatar
sebastien committed
295
296
private:
  const vector<EstimationParams> estim_params_list;
297
  const SymbolTable &symbol_table;
sebastien's avatar
sebastien committed
298
299
300
public:
  EstimatedParamsStatement(const vector<EstimationParams> &estim_params_list_arg,
                           const SymbolTable &symbol_table_arg);
sebastien's avatar
sebastien committed
301
  virtual void writeOutput(ostream &output, const string &basename) const;
sebastien's avatar
sebastien committed
302
};
303

sebastien's avatar
sebastien committed
304
305
306
307
308
309
310
311
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
312
  virtual void writeOutput(ostream &output, const string &basename) const;
sebastien's avatar
sebastien committed
313
};
314

sebastien's avatar
sebastien committed
315
316
317
318
319
320
321
322
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
323
  virtual void writeOutput(ostream &output, const string &basename) const;
sebastien's avatar
sebastien committed
324
};
325

sebastien's avatar
sebastien committed
326
327
328
class OptimWeightsStatement : public Statement
{
public:
sebastien's avatar
sebastien committed
329
330
  typedef map<string, NodeID> var_weights_type;
  typedef map<pair<string, string>, NodeID> covar_weights_type;
sebastien's avatar
sebastien committed
331
332
333
334
335
336
337
338
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);
sebastien's avatar
sebastien committed
339
  virtual void writeOutput(ostream &output, const string &basename) const;
sebastien's avatar
sebastien committed
340
};
341

sebastien's avatar
sebastien committed
342
343
344
345
346
347
class CalibStatement : public Statement
{
private:
  const int covar;
public:
  CalibStatement(int covar_arg);
sebastien's avatar
sebastien committed
348
  virtual void writeOutput(ostream &output, const string &basename) const;
sebastien's avatar
sebastien committed
349
};
350

sebastien's avatar
sebastien committed
351
352
353
354
class CalibVarStatement : public Statement
{
public:
  //! Maps a variable to a pair (weight, expression)
sebastien's avatar
sebastien committed
355
  typedef map<string, pair<string, NodeID> > calib_var_type;
sebastien's avatar
sebastien committed
356
  //! Maps a pair of variables to a pair (weight, expression)
sebastien's avatar
sebastien committed
357
  typedef map<pair<string, string>, pair<string, NodeID> > calib_covar_type;
sebastien's avatar
sebastien committed
358
  //! Maps a pair (variable, autocorr) to a pair (weight, expression)
sebastien's avatar
sebastien committed
359
  typedef map<pair<string, int>, pair<string, NodeID> > calib_ac_type;
sebastien's avatar
sebastien committed
360
361
362
363
364
365
366
367
368
369
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);
sebastien's avatar
sebastien committed
370
371
372
373
374
375
376
  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
377
  StaticModel *model_tree;
sebastien's avatar
sebastien committed
378
379
380
381
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
382
  PlannerObjectiveStatement(StaticModel *model_tree_arg);
sebastien's avatar
sebastien committed
383
384
385
386
  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);
387
  /*! \todo allow for the possibility of disabling temporary terms */
sebastien's avatar
sebastien committed
388
389
  virtual void computingPass();
  virtual void writeOutput(ostream &output, const string &basename) const;
390
};
sebastien's avatar
sebastien committed
391

392
393
394
395
396
397
398
class BVARDensityStatement : public Statement
{
private:
  const int maxnlags;
  const OptionsList options_list;
public:
  BVARDensityStatement(int maxnlags_arg, const OptionsList &options_list_arg);
399
  virtual void checkPass(ModFileStructure &mod_file_struct);
400
401
  virtual void writeOutput(ostream &output, const string &basename) const;
};
ferhat's avatar
ferhat committed
402

403
404
405
406
407
408
409
class BVARForecastStatement : public Statement
{
private:
  const int nlags;
  const OptionsList options_list;
public:
  BVARForecastStatement(int nlags_arg, const OptionsList &options_list_arg);
410
  virtual void checkPass(ModFileStructure &mod_file_struct);
411
412
  virtual void writeOutput(ostream &output, const string &basename) const;
};
ferhat's avatar
ferhat committed
413

414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
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
434
435
class IdentificationStatement : public Statement
{
sebastien's avatar
sebastien committed
436
437
private:
  const OptionsList options_list;
sebastien's avatar
sebastien committed
438
public:
sebastien's avatar
sebastien committed
439
  IdentificationStatement(const OptionsList &options_list_arg);
sebastien's avatar
sebastien committed
440
441
442
443
  virtual void checkPass(ModFileStructure &mod_file_struct);
  virtual void writeOutput(ostream &output, const string &basename) const;
};

444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
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;
};

462
463
464
465
466
467
468
469
470
471
472
class ShockDecompositionStatement : public Statement
{
private:
  const SymbolList symbol_list;
  const OptionsList options_list;
public:
  ShockDecompositionStatement(const SymbolList &symbol_list_arg,
                         const OptionsList &options_list_arg);
  virtual void writeOutput(ostream &output, const string &basename) const;
};

473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
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:
  //! A value of -1 indicates that the length of the constrained path should be used
  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;
};

493
#endif