ComputingTasks.hh 45.3 KB
Newer Older
1
/*
2
 * Copyright (C) 2003-2019 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
#include "SymbolTable.hh"
#include "Statement.hh"
sebastien's avatar
sebastien committed
28
#include "StaticModel.hh"
29
#include "DynamicModel.hh"
Houtan Bastani's avatar
Houtan Bastani committed
30
#include "ModelEquationBlock.hh"
31 32 33 34 35 36

class SteadyStatement : public Statement
{
private:
  const OptionsList options_list;
public:
37
  explicit SteadyStatement(OptionsList options_list_arg);
38 39 40
  void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
  void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
  void writeJsonOutput(ostream &output) const override;
41 42 43 44 45 46 47
};

class CheckStatement : public Statement
{
private:
  const OptionsList options_list;
public:
48
  explicit CheckStatement(OptionsList options_list_arg);
49 50 51
  void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
  void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
  void writeJsonOutput(ostream &output) const override;
52 53 54 55 56 57 58
};

class SimulStatement : public Statement
{
private:
  const OptionsList options_list;
public:
59
  explicit SimulStatement(OptionsList options_list_arg);
60 61 62
  void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
  void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
  void writeJsonOutput(ostream &output) const override;
63 64
};

65 66 67 68 69
class PerfectForesightSetupStatement : public Statement
{
private:
  const OptionsList options_list;
public:
70
  explicit PerfectForesightSetupStatement(OptionsList options_list_arg);
71 72
  void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
  void writeJsonOutput(ostream &output) const override;
73 74 75 76 77 78 79
};

class PerfectForesightSolverStatement : public Statement
{
private:
  const OptionsList options_list;
public:
80
  explicit PerfectForesightSolverStatement(OptionsList options_list_arg);
81 82 83
  void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
  void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
  void writeJsonOutput(ostream &output) const override;
84 85
};

86 87 88
class PriorPosteriorFunctionStatement : public Statement
{
private:
89
  const bool prior_func;
90 91
  const OptionsList options_list;
public:
92
  PriorPosteriorFunctionStatement(const bool prior_func_arg, OptionsList options_list_arg);
93 94 95
  void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
  void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
  void writeJsonOutput(ostream &output) const override;
96 97
};

98 99 100 101 102 103 104 105

class DetCondForecast : public Statement
{
private:
  const OptionsList options_list;
  const SymbolList symbol_list;
  const bool linear_decomposition;
public:
106
  DetCondForecast(SymbolList symbol_list_arg,
107
                  OptionsList options_list_arg,
108 109
                  const bool linear_decompositiontion_arg);
  //virtual void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings);
110
  void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
111 112
};

ferhat's avatar
ferhat committed
113
class ModelInfoStatement : public Statement
114 115 116 117
{
private:
  const OptionsList options_list;
public:
118
  explicit ModelInfoStatement(OptionsList options_list_arg);
119 120 121
  void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
  void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
  void writeJsonOutput(ostream &output) const override;
122 123
};

124 125 126
class StochSimulStatement : public Statement
{
private:
sebastien's avatar
sebastien committed
127
  const SymbolList symbol_list;
128 129
  const OptionsList options_list;
public:
130 131
  StochSimulStatement(SymbolList symbol_list_arg,
                      OptionsList options_list_arg);
132 133 134
  void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
  void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
  void writeJsonOutput(ostream &output) const override;
135 136
};

Houtan Bastani's avatar
Houtan Bastani committed
137 138
class PacModelStatement : public Statement
{
139 140
public:
  const string name, aux_model_name, discount;
141
  expr_t growth, original_growth;
142 143 144
private:
  const double steady_state_growth_rate_number;
  const int steady_state_growth_rate_symb_id;
Houtan Bastani's avatar
Houtan Bastani committed
145 146
  const SymbolTable &symbol_table;
public:
147 148
  int growth_symb_id;
  int growth_lag;
149
  PacModelStatement(string name_arg,
150
                    string aux_model_name_arg,
151
                    string discount_arg,
152
                    expr_t growth_arg,
153 154
                    double steady_state_growth_rate_number_arg,
                    int steady_state_growth_rate_symb_id_arg,
Houtan Bastani's avatar
Houtan Bastani committed
155
                    const SymbolTable &symbol_table_arg);
156
  void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
157
  void overwriteGrowth(expr_t new_growth);
158 159
  void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
  void writeJsonOutput(ostream &output) const override;
Houtan Bastani's avatar
Houtan Bastani committed
160 161
};

162 163 164
class VarRestrictionsStatement : public Statement
{
private:
165
  using var_restriction_eq_crosseq_t = pair<pair<int, pair<int, int>>, expr_t>;
166 167
  const string var_model_name;
  const map<string, vector<string>> var_map;
168
  const map<int, map<int, SymbolList>> exclusion_restrictions;
169
  using equation_restrictions_t = map<int, pair<pair<var_restriction_eq_crosseq_t, var_restriction_eq_crosseq_t>, double>>;
170
  const equation_restrictions_t equation_restrictions;
171
  using crossequation_restrictions_t = vector<pair<pair<var_restriction_eq_crosseq_t, var_restriction_eq_crosseq_t>, double>>;
172 173
  const crossequation_restrictions_t crossequation_restrictions;
  const map<pair<int, int>, double> covariance_number_restriction;
174
  const map<pair<int, int>, pair<int, int>> covariance_pair_restriction;
175
  const SymbolTable &symbol_table;
176
  int findIdxInVector(const vector<string> &vecvars, const string &var) const;
177
public:
178 179
  VarRestrictionsStatement(string var_model_name_arg,
                           map<string, vector<string>> var_map_arg,
180
                           map<int, map<int, SymbolList>> exclusion_restrictions_arg,
181 182 183
                           equation_restrictions_t equation_restrictions_arg,
                           crossequation_restrictions_t crossequation_restrictions_arg,
                           map<pair<int, int>, double> covariance_number_restriction_arg,
184
                           map<pair<int, int>, pair<int, int>> covariance_pair_restriction_arg,
185
                           const SymbolTable &symbol_table_arg);
186
  void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
187 188
};

189 190 191
class VarEstimationStatement : public Statement
{
private:
192
  const OptionsList options_list;
193
public:
194
  explicit VarEstimationStatement(OptionsList options_list_arg);
195 196
  void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
  void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
197 198
};

199 200 201 202 203 204
class ForecastStatement : public Statement
{
private:
  const SymbolList symbol_list;
  const OptionsList options_list;
public:
205 206
  ForecastStatement(SymbolList symbol_list_arg,
                    OptionsList options_list_arg);
207 208
  void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
  void writeJsonOutput(ostream &output) const override;
209 210 211 212 213 214 215
};

class RamseyModelStatement : public Statement
{
private:
  const OptionsList options_list;
public:
216
  explicit RamseyModelStatement(OptionsList options_list_arg);
217 218 219
  void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
  void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
  void writeJsonOutput(ostream &output) const override;
220 221
};

222 223 224
class RamseyConstraintsStatement : public Statement
{
public:
225 226
  struct Constraint
  {
227 228 229
    int endo;
    BinaryOpcode code;
    expr_t expression;
230
  };
231
  using constraints_t = vector<Constraint>;
232
private:
233
  const SymbolTable &symbol_table;
234 235
  const constraints_t constraints;
public:
236
  RamseyConstraintsStatement(const SymbolTable &symbol_table_arg, constraints_t constraints_arg);
237 238 239
  void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
  void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
  void writeJsonOutput(ostream &output) const override;
240 241
};

242 243 244
class RamseyPolicyStatement : public Statement
{
private:
245 246
  const SymbolTable &symbol_table;
  const vector<string> ramsey_policy_list;
247 248
  const OptionsList options_list;
public:
249
  RamseyPolicyStatement(const SymbolTable &symbol_table_arg,
250 251
                        vector<string> ramsey_policy_list_arg,
                        OptionsList options_list_arg);
252
  void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
253
  void checkRamseyPolicyList();
254 255
  void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
  void writeJsonOutput(ostream &output) const override;
256 257
};

258 259 260 261 262 263
class DiscretionaryPolicyStatement : public Statement
{
private:
  const SymbolList symbol_list;
  const OptionsList options_list;
public:
264 265
  DiscretionaryPolicyStatement(SymbolList symbol_list_arg,
                               OptionsList options_list_arg);
266 267 268
  void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
  void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
  void writeJsonOutput(ostream &output) const override;
269 270
};

271 272 273
class RplotStatement : public Statement
{
private:
sebastien's avatar
sebastien committed
274
  const SymbolList symbol_list;
275
public:
276
  explicit RplotStatement(SymbolList symbol_list_arg);
277 278
  void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
  void writeJsonOutput(ostream &output) const override;
279 280 281 282 283
};

class UnitRootVarsStatement : public Statement
{
public:
284 285
  void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
  void writeJsonOutput(ostream &output) const override;
286 287 288 289 290 291 292
};

class PeriodsStatement : public Statement
{
private:
  const int periods;
public:
293
  explicit PeriodsStatement(int periods_arg);
294 295
  void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
  void writeJsonOutput(ostream &output) const override;
296 297 298 299 300 301 302
};

class DsampleStatement : public Statement
{
private:
  const int val1, val2;
public:
303
  explicit DsampleStatement(int val1_arg);
304
  DsampleStatement(int val1_arg, int val2_arg);
305 306
  void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
  void writeJsonOutput(ostream &output) const override;
307 308 309 310 311
};

class EstimationStatement : public Statement
{
private:
sebastien's avatar
sebastien committed
312
  const SymbolList symbol_list;
313 314
  const OptionsList options_list;
public:
315 316
  EstimationStatement(SymbolList symbol_list_arg,
                      OptionsList options_list_arg);
317 318 319
  void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
  void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
  void writeJsonOutput(ostream &output) const override;
320 321 322 323 324 325 326
};

class DynareSensitivityStatement : public Statement
{
private:
  const OptionsList options_list;
public:
327
  explicit DynareSensitivityStatement(OptionsList options_list_arg);
328 329 330
  void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
  void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
  void writeJsonOutput(ostream &output) const override;
331 332 333 334 335
};

class ObservationTrendsStatement : public Statement
{
public:
336
  using trend_elements_t = map<string, expr_t>;
337
private:
338
  const trend_elements_t trend_elements;
339 340
  const SymbolTable &symbol_table;
public:
341
  ObservationTrendsStatement(trend_elements_t trend_elements_arg,
342
                             const SymbolTable &symbol_table_arg);
343 344
  void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
  void writeJsonOutput(ostream &output) const override;
345 346 347 348 349
};

class OsrParamsStatement : public Statement
{
private:
sebastien's avatar
sebastien committed
350
  const SymbolList symbol_list;
351
  const SymbolTable &symbol_table;
352
public:
353
  OsrParamsStatement(SymbolList symbol_list_arg, const SymbolTable &symbol_table_arg);
354 355 356
  void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
  void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
  void writeJsonOutput(ostream &output) const override;
357 358 359 360 361
};

class OsrStatement : public Statement
{
private:
sebastien's avatar
sebastien committed
362
  const SymbolList symbol_list;
363 364
  const OptionsList options_list;
public:
365 366
  OsrStatement(SymbolList symbol_list_arg,
               OptionsList options_list_arg);
367 368 369
  void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
  void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
  void writeJsonOutput(ostream &output) const override;
370 371
};

372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392
//! Temporary structure used when parsing estimation_params* statements
class OsrParams
{
public:
  string name;
  expr_t low_bound, up_bound;

  void
  init(const DataTree &datatree)
  {
    name = "";
    low_bound = datatree.MinusInfinity;
    up_bound = datatree.Infinity;
  }
};

class OsrParamsBoundsStatement : public Statement
{
private:
  const vector<OsrParams> osr_params_list;
public:
393
  explicit OsrParamsBoundsStatement(vector<OsrParams> osr_params_list_arg);
394 395 396
  void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
  void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
  void writeJsonOutput(ostream &output) const override;
397 398
};

399 400 401
class DynaTypeStatement : public Statement
{
private:
sebastien's avatar
sebastien committed
402
  const SymbolList symbol_list;
403 404
  const string filename;
public:
405 406
  DynaTypeStatement(SymbolList symbol_list_arg,
                    string filename_arg);
407 408
  void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
  void writeJsonOutput(ostream &output) const override;
409 410 411 412 413
};

class DynaSaveStatement : public Statement
{
private:
sebastien's avatar
sebastien committed
414
  const SymbolList symbol_list;
415 416
  const string filename;
public:
417 418
  DynaSaveStatement(SymbolList symbol_list_arg,
                    string filename_arg);
419 420
  void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
  void writeJsonOutput(ostream &output) const override;
421 422 423 424 425
};

class ModelComparisonStatement : public Statement
{
public:
426
  using filename_list_t = vector<pair<string, string>>;
427
private:
428
  filename_list_t filename_list;
429 430
  OptionsList options_list;
public:
431 432
  ModelComparisonStatement(filename_list_t filename_list_arg,
                           OptionsList options_list_arg);
433 434
  void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
  void writeJsonOutput(ostream &output) const override;
435 436
};

437 438
//! Temporary structure used when parsing estimation_params* statements
class EstimationParams
439
{
440
public:
441
  int type;
442 443
  string name, name2;
  PriorDistributions prior;
444
  expr_t init_val, low_bound, up_bound, mean, std, p3, p4, jscale;
445

446 447
  void
  init(const DataTree &datatree)
448 449 450 451
  {
    type = 0;
    name = "";
    name2 = "";
452
    prior = PriorDistributions::noShape;
453 454 455 456 457 458 459 460
    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;
461 462 463 464 465 466 467 468 469
  }
};

class EstimatedParamsStatement : public Statement
{
private:
  const vector<EstimationParams> estim_params_list;
  const SymbolTable &symbol_table;
public:
470
  EstimatedParamsStatement(vector<EstimationParams> estim_params_list_arg,
471
                           const SymbolTable &symbol_table_arg);
472 473 474
  void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
  void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
  void writeJsonOutput(ostream &output) const override;
475 476 477 478 479 480 481
};

class EstimatedParamsInitStatement : public Statement
{
private:
  const vector<EstimationParams> estim_params_list;
  const SymbolTable &symbol_table;
482
  const bool use_calibration;
483
public:
484
  EstimatedParamsInitStatement(vector<EstimationParams> estim_params_list_arg,
485 486
                               const SymbolTable &symbol_table_arg,
                               const bool use_calibration_arg);
487 488 489
  void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
  void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
  void writeJsonOutput(ostream &output) const override;
490 491 492 493 494 495 496 497
};

class EstimatedParamsBoundsStatement : public Statement
{
private:
  const vector<EstimationParams> estim_params_list;
  const SymbolTable &symbol_table;
public:
498
  EstimatedParamsBoundsStatement(vector<EstimationParams> estim_params_list_arg,
499
                                 const SymbolTable &symbol_table_arg);
500 501
  void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
  void writeJsonOutput(ostream &output) const override;
502 503 504 505 506
};

class OptimWeightsStatement : public Statement
{
public:
507 508
  using var_weights_t = map<string, expr_t>;
  using covar_weights_t = map<pair<string, string>, expr_t>;
509
private:
510 511
  const var_weights_t var_weights;
  const covar_weights_t covar_weights;
512 513
  const SymbolTable &symbol_table;
public:
514 515
  OptimWeightsStatement(var_weights_t var_weights_arg,
                        covar_weights_t covar_weights_arg,
516
                        const SymbolTable &symbol_table_arg);
517 518 519
  void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
  void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
  void writeJsonOutput(ostream &output) const override;
520 521 522 523 524
};

class PlannerObjectiveStatement : public Statement
{
private:
525 526
  StaticModel model_tree;
  bool computing_pass_called{false};
527
public:
528
  PlannerObjectiveStatement(const StaticModel &model_tree_arg);
529 530
  /*! \todo check there are only endogenous variables at the current period in the objective
    (no exogenous, no lead/lag) */
531
  void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
532
  /*! \todo allow for the possibility of disabling temporary terms */
533 534 535
  void computingPass() override;
  void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
  void writeJsonOutput(ostream &output) const override;
536
  //! Return a reference the Planner Objective model tree
537
  const StaticModel &getPlannerObjective() const;
538 539 540 541 542 543 544 545
};

class BVARDensityStatement : public Statement
{
private:
  const int maxnlags;
  const OptionsList options_list;
public:
546
  BVARDensityStatement(int maxnlags_arg, OptionsList options_list_arg);
547 548 549
  void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
  void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
  void writeJsonOutput(ostream &output) const override;
550 551 552 553 554 555 556 557
};

class BVARForecastStatement : public Statement
{
private:
  const int nlags;
  const OptionsList options_list;
public:
558
  BVARForecastStatement(int nlags_arg, OptionsList options_list_arg);
559 560 561
  void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
  void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
  void writeJsonOutput(ostream &output) const override;
562 563
};

564 565 566 567 568
class SBVARStatement : public Statement
{
private:
  const OptionsList options_list;
public:
569
  explicit SBVARStatement(OptionsList options_list_arg);
570 571 572
  void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
  void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
  void writeJsonOutput(ostream &output) const override;
573 574
};

Houtan Bastani's avatar
Houtan Bastani committed
575
class MSSBVAREstimationStatement : public Statement
576 577 578 579
{
private:
  const OptionsList options_list;
public:
580
  explicit MSSBVAREstimationStatement(OptionsList options_list_arg);
581 582 583
  void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
  void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
  void writeJsonOutput(ostream &output) const override;
Houtan Bastani's avatar
Houtan Bastani committed
584 585 586 587 588 589 590
};

class MSSBVARSimulationStatement : public Statement
{
private:
  const OptionsList options_list;
public:
591
  explicit MSSBVARSimulationStatement(OptionsList options_list_arg);
592 593 594
  void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
  void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
  void writeJsonOutput(ostream &output) const override;
Houtan Bastani's avatar
Houtan Bastani committed
595 596 597 598 599 600 601
};

class MSSBVARComputeMDDStatement : public Statement
{
private:
  const OptionsList options_list;
public:
602
  explicit MSSBVARComputeMDDStatement(OptionsList options_list_arg);
603 604 605
  void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
  void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
  void writeJsonOutput(ostream &output) const override;
Houtan Bastani's avatar
Houtan Bastani committed
606 607 608 609 610 611 612
};

class MSSBVARComputeProbabilitiesStatement : public Statement
{
private:
  const OptionsList options_list;
public:
613
  explicit MSSBVARComputeProbabilitiesStatement(OptionsList options_list_arg);
614 615 616
  void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
  void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
  void writeJsonOutput(ostream &output) const override;
Houtan Bastani's avatar
Houtan Bastani committed
617 618 619 620 621
};

class MSSBVARIrfStatement : public Statement
{
private:
622
  const SymbolList symbol_list;
Houtan Bastani's avatar
Houtan Bastani committed
623 624
  const OptionsList options_list;
public:
625 626
  MSSBVARIrfStatement(SymbolList symbol_list_arg,
                      OptionsList options_list_arg);
627 628 629
  void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
  void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
  void writeJsonOutput(ostream &output) const override;
Houtan Bastani's avatar
Houtan Bastani committed
630 631 632 633 634 635 636
};

class MSSBVARForecastStatement : public Statement
{
private:
  const OptionsList options_list;
public:
637
  explicit MSSBVARForecastStatement(OptionsList options_list_arg);
638 639 640
  void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
  void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
  void writeJsonOutput(ostream &output) const override;
Houtan Bastani's avatar
Houtan Bastani committed
641 642 643 644 645 646 647
};

class MSSBVARVarianceDecompositionStatement : public Statement
{
private:
  const OptionsList options_list;
public:
648
  explicit MSSBVARVarianceDecompositionStatement(OptionsList options_list_arg);
649 650 651
  void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
  void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
  void writeJsonOutput(ostream &output) const override;
652 653
};

sebastien's avatar
sebastien committed
654 655
class IdentificationStatement : public Statement
{
sebastien's avatar
sebastien committed
656
private:
657
  OptionsList options_list;
sebastien's avatar
sebastien committed
658
public:
659
  explicit IdentificationStatement(OptionsList options_list_arg);
660 661 662
  void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
  void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
  void writeJsonOutput(ostream &output) const override;
sebastien's avatar
sebastien committed
663 664
};

665 666 667 668
class WriteLatexDynamicModelStatement : public Statement
{
private:
  const DynamicModel &dynamic_model;
669
  const bool write_equation_tags;
670
public:
671
  WriteLatexDynamicModelStatement(const DynamicModel &dynamic_model_arg, bool write_equation_tags_arg);
672 673
  void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
  void writeJsonOutput(ostream &output) const override;
674 675 676 677 678 679
};

class WriteLatexStaticModelStatement : public Statement
{
private:
  const StaticModel &static_model;
680
  const bool write_equation_tags;
681
public:
682
  WriteLatexStaticModelStatement(const StaticModel &static_model_arg, bool write_equation_tags_arg);
683 684
  void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
  void writeJsonOutput(ostream &output) const override;
685 686
};

687 688 689 690
class WriteLatexOriginalModelStatement : public Statement
{
private:
  const DynamicModel &original_model;
691
  const bool write_equation_tags;
692
public:
693
  WriteLatexOriginalModelStatement(const DynamicModel &original_model_arg, bool write_equation_tags_arg);
694 695
  void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
  void writeJsonOutput(ostream &output) const override;
696 697
};

698 699 700 701 702
class WriteLatexSteadyStateModelStatement : public Statement
{
private:
  const SteadyStateModel &steady_state_model;
public:
703
  explicit WriteLatexSteadyStateModelStatement(const SteadyStateModel &steady_state_model_arg);
704 705 706
  void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
  void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
  void writeJsonOutput(ostream &output) const override;
707 708
};

709 710 711 712 713 714
class ShockDecompositionStatement : public Statement
{
private:
  const SymbolList symbol_list;
  const OptionsList options_list;
public:
715 716
  ShockDecompositionStatement(SymbolList symbol_list_arg,
                              OptionsList options_list_arg);
717 718
  void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
  void writeJsonOutput(ostream &output) const override;
719 720
};

721 722 723 724 725 726
class RealtimeShockDecompositionStatement : public Statement
{
private:
  const SymbolList symbol_list;
  const OptionsList options_list;
public:
727 728
  RealtimeShockDecompositionStatement(SymbolList symbol_list_arg,
                                      OptionsList options_list_arg);
729
  void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
730 731 732 733 734 735 736 737
};

class PlotShockDecompositionStatement : public Statement
{
private:
  const SymbolList symbol_list;
  const OptionsList options_list;
public:
738 739
  PlotShockDecompositionStatement(SymbolList symbol_list_arg,
                                  OptionsList options_list_arg);
740
  void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
741
};
742

743 744 745 746 747 748
class InitialConditionDecompositionStatement : public Statement
{
private:
  const SymbolList symbol_list;
  const OptionsList options_list;
public:
749 750
  InitialConditionDecompositionStatement(SymbolList symbol_list_arg,
                                         OptionsList options_list_arg);
751
  void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
752 753
};

754 755 756 757 758
class ConditionalForecastStatement : public Statement
{
private:
  const OptionsList options_list;
public:
759
  explicit ConditionalForecastStatement(OptionsList options_list_arg);
760
  void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
761 762
  void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
  void writeJsonOutput(ostream &output) const override;
763 764 765 766 767
};

class PlotConditionalForecastStatement : public Statement
{
private:
768
  //! A value of -1 indicates that the user didn't specify a value
769 770 771
  const int periods;
  const SymbolList symbol_list;
public:
772
  PlotConditionalForecastStatement(int periods_arg, SymbolList symbol_list_arg);
773 774
  void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
  void writeJsonOutput(ostream &output) const override;
775 776
};

777 778 779 780 781 782
class CalibSmootherStatement : public Statement
{
private:
  const SymbolList symbol_list;
  const OptionsList options_list;
public:
783 784
  CalibSmootherStatement(SymbolList symbol_list_arg,
                         OptionsList options_list_arg);
785 786 787
  void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
  void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
  void writeJsonOutput(ostream &output) const override;
788 789
};

790 791 792 793 794
class ExtendedPathStatement : public Statement
{
private:
  const OptionsList options_list;
public:
795
  explicit ExtendedPathStatement(OptionsList options_list_arg);
796 797 798
  void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
  void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
  void writeJsonOutput(ostream &output) const override;
799 800
};

houtanb's avatar
houtanb committed
801 802 803
class SvarIdentificationStatement : public Statement
{
public:
804
  //  using svar_identification_exclusion_t = map<pair<int, int>, vector<int>>;
805 806 807 808 809 810 811
  struct svar_identification_restriction
  {
    int equation;
    int restriction_nbr;
    int lag;
    int variable;
    expr_t value;
812
  };
813

814
  using svar_identification_restrictions_t = vector<svar_identification_restriction>;
houtanb's avatar
houtanb committed
815
private:
816
  const svar_identification_restrictions_t restrictions;
houtanb's avatar
houtanb committed
817 818
  const bool upper_cholesky_present;
  const bool lower_cholesky_present;
819
  const bool constants_exclusion_present;
houtanb's avatar
houtanb committed
820 821 822
  const SymbolTable &symbol_table;
  int getMaxLag() const;
public:
823
  SvarIdentificationStatement(svar_identification_restrictions_t restrictions_arg,
824 825 826
                              bool upper_cholesky_present_arg,
                              bool lower_cholesky_present_arg,
                              bool constants_exclusion_present_arg,
houtanb's avatar
houtanb committed
827
                              const SymbolTable &symbol_table_arg);
828 829 830
  void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
  void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
  void writeJsonOutput(ostream &output) const override;
houtanb's avatar
houtanb committed
831 832
};

houtanb's avatar
houtanb committed
833 834 835 836
class MarkovSwitchingStatement : public Statement
{
private:
  const OptionsList options_list;
837
  map <pair<int, int >, double > restriction_map;
houtanb's avatar
houtanb committed
838
public:
839
  explicit MarkovSwitchingStatement(OptionsList options_list_arg);
840 841 842 843
  void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
  void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
  void writeCOutput(ostream &output, const string &basename) override;
  void writeJsonOutput(ostream &output) const override;
houtanb's avatar
houtanb committed
844 845
};

houtanb's avatar
houtanb committed
846 847 848 849 850
class SvarStatement : public Statement
{
private:
  const OptionsList options_list;
public:
851
  explicit SvarStatement(OptionsList options_list_arg);
852 853 854
  void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
  void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
  void writeJsonOutput(ostream &output) const override;
houtanb's avatar
houtanb committed
855 856
};

857 858 859
class SvarGlobalIdentificationCheckStatement : public Statement
{
public:
860 861
  void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
  void writeJsonOutput(ostream &output) const override;
862 863
};

864 865 866 867 868
class SetTimeStatement : public Statement
{
private:
  const OptionsList options_list;
public:
869
  explicit SetTimeStatement(OptionsList options_list_arg);
870 871
  void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
  void writeJsonOutput(ostream &output) const override;
872 873
};

874 875 876 877 878
class EstimationDataStatement : public Statement
{
private:
  const OptionsList options_list;
public:
879
  explicit EstimationDataStatement(OptionsList options_list_arg);
880 881 882
  void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
  void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
  void writeJsonOutput(ostream &output) const override;
883 884
};

885 886 887 888
class SubsamplesStatement : public Statement
{
public:
  //! Storage for declaring subsamples: map<subsample_name, <date1, date2 >
889
  using subsample_declaration_map_t = map<string, pair<string, string>>;
890 891 892 893
private:
  const string name1;
  const string name2;
  const subsample_declaration_map_t subsample_declaration_map;
894
  const SymbolTable &symbol_table;
895
public:
896 897
  SubsamplesStatement(string name1_arg,
                      string name2_arg,
898 899
                      subsample_declaration_map_t subsample_declaration_map_arg,
                      const SymbolTable &symbol_table_arg);
900 901 902
  void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings) override;
  void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
  void writeJsonOutput(ostream &output) const override;