2008-01-11 14:42:14 +01:00
|
|
|
/*
|
2015-02-16 08:31:30 +01:00
|
|
|
* Copyright (C) 2006-2015 Dynare Team
|
2008-01-11 14:42:14 +01:00
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2006-11-28 12:56:02 +01:00
|
|
|
#ifndef _MOD_FILE_HH
|
|
|
|
#define _MOD_FILE_HH
|
|
|
|
|
2006-12-12 12:54:30 +01:00
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
#include <ostream>
|
2009-01-20 23:04:37 +01:00
|
|
|
#include <ctime>
|
2015-05-10 18:16:11 +02:00
|
|
|
#include <iostream>
|
|
|
|
#include <sstream>
|
2009-01-20 23:04:37 +01:00
|
|
|
|
2006-11-28 12:56:02 +01:00
|
|
|
#include "SymbolTable.hh"
|
|
|
|
#include "NumericalConstants.hh"
|
2008-12-19 11:24:31 +01:00
|
|
|
#include "NumericalInitialization.hh"
|
2009-04-14 16:39:53 +02:00
|
|
|
#include "StaticModel.hh"
|
|
|
|
#include "DynamicModel.hh"
|
2010-04-23 18:39:07 +02:00
|
|
|
#include "SteadyStateModel.hh"
|
2006-12-12 12:54:30 +01:00
|
|
|
#include "Statement.hh"
|
2010-02-22 17:33:38 +01:00
|
|
|
#include "ExternalFunctionsTable.hh"
|
2010-10-25 18:20:58 +02:00
|
|
|
#include "ConfigFile.hh"
|
2012-01-23 16:52:27 +01:00
|
|
|
#include "WarningConsolidation.hh"
|
2014-04-20 11:12:12 +02:00
|
|
|
#include "ExtendedPreprocessorTypes.hh"
|
2006-11-28 12:56:02 +01:00
|
|
|
|
2015-05-10 18:16:11 +02:00
|
|
|
// for checksum computation
|
|
|
|
#ifndef PRIVATE_BUFFER_SIZE
|
|
|
|
#define PRIVATE_BUFFER_SIZE 1024
|
|
|
|
#endif
|
|
|
|
|
2006-11-28 12:56:02 +01:00
|
|
|
//! The abstract representation of a "mod" file
|
|
|
|
class ModFile
|
|
|
|
{
|
|
|
|
public:
|
2013-02-26 16:50:05 +01:00
|
|
|
ModFile(WarningConsolidation &warnings_arg);
|
2006-12-12 12:54:30 +01:00
|
|
|
~ModFile();
|
2006-11-28 12:56:02 +01:00
|
|
|
//! Symbol table
|
|
|
|
SymbolTable symbol_table;
|
2010-02-22 17:33:38 +01:00
|
|
|
//! External Functions table
|
|
|
|
ExternalFunctionsTable external_functions_table;
|
2006-12-12 12:54:30 +01:00
|
|
|
//! Numerical constants table
|
2006-11-28 12:56:02 +01:00
|
|
|
NumericalConstants num_constants;
|
2007-03-09 18:27:46 +01:00
|
|
|
//! Expressions outside model block
|
|
|
|
DataTree expressions_tree;
|
2015-02-16 08:31:30 +01:00
|
|
|
//! Original model, as declared in the "model" block, that won't be modified by the preprocessor
|
|
|
|
DynamicModel original_model;
|
2010-04-23 18:39:07 +02:00
|
|
|
//! Dynamic model, as declared in the "model" block
|
2009-04-14 16:39:53 +02:00
|
|
|
DynamicModel dynamic_model;
|
2010-10-15 19:05:16 +02:00
|
|
|
//! A copy of Dynamic model, for testing trends declared by user
|
|
|
|
DynamicModel trend_dynamic_model;
|
2011-03-21 18:40:57 +01:00
|
|
|
//! A model in which to create the FOC for the ramsey problem
|
|
|
|
DynamicModel ramsey_FOC_equations_dynamic_model;
|
2010-04-23 18:39:07 +02:00
|
|
|
//! Static model, as derived from the "model" block when leads and lags have been removed
|
|
|
|
StaticModel static_model;
|
2010-04-27 17:04:52 +02:00
|
|
|
//! Static model, as declared in the "steady_state_model" block if present
|
|
|
|
SteadyStateModel steady_state_model;
|
2006-11-28 12:56:02 +01:00
|
|
|
//! Option linear
|
2006-12-15 12:44:58 +01:00
|
|
|
bool linear;
|
2009-08-29 17:04:11 +02:00
|
|
|
|
|
|
|
//! Is the model block decomposed?
|
|
|
|
bool block;
|
|
|
|
|
2009-12-09 12:50:58 +01:00
|
|
|
//! Is the model stored in bytecode format (byte_code=true) or in a M-file (byte_code=false)
|
2009-08-29 17:04:11 +02:00
|
|
|
bool byte_code;
|
|
|
|
|
2009-12-09 12:50:58 +01:00
|
|
|
//! Is the model stored in a MEX file ? (option "use_dll" of "model")
|
2009-09-02 15:36:56 +02:00
|
|
|
bool use_dll;
|
2009-08-29 17:04:11 +02:00
|
|
|
|
2010-01-08 12:06:25 +01:00
|
|
|
//! Is the static model have to computed (no_static=false) or not (no_static=true). Option of 'model'
|
|
|
|
bool no_static;
|
|
|
|
|
2013-04-25 18:09:31 +02:00
|
|
|
//! Is the 'differentiate_forward_vars' option used?
|
|
|
|
bool differentiate_forward_vars;
|
|
|
|
|
2013-05-17 16:51:34 +02:00
|
|
|
/*! If the 'differentiate_forward_vars' option is used, contains the set of
|
|
|
|
endogenous with respect to which to do the transformation;
|
|
|
|
if empty, means that the transformation must be applied to all endos
|
|
|
|
with a lead */
|
|
|
|
vector<string> differentiate_forward_vars_subset;
|
|
|
|
|
2010-10-15 19:05:16 +02:00
|
|
|
//! Are nonstationary variables present ?
|
|
|
|
bool nonstationary_variables;
|
|
|
|
|
2007-03-09 18:27:46 +01:00
|
|
|
//! Global evaluation context
|
|
|
|
/*! Filled using initval blocks and parameters initializations */
|
2010-09-16 19:00:48 +02:00
|
|
|
eval_context_t global_eval_context;
|
2006-12-15 12:44:58 +01:00
|
|
|
|
2011-03-21 18:40:57 +01:00
|
|
|
//! Stores the original number of equations in the model_block
|
2014-10-13 17:16:41 +02:00
|
|
|
int orig_eqn_nbr;
|
2011-03-21 18:40:57 +01:00
|
|
|
|
2014-10-13 17:25:08 +02:00
|
|
|
//! Stores the number of equations added to the Ramsey model
|
|
|
|
int ramsey_eqn_nbr;
|
|
|
|
|
2015-07-30 14:40:03 +02:00
|
|
|
//! Parameter used with lead/lag
|
|
|
|
bool param_used_with_lead_lag;
|
|
|
|
|
2013-05-31 14:47:28 +02:00
|
|
|
//! Stores the list of extra files to be transefered during a parallel run
|
|
|
|
/*! (i.e. option parallel_local_files of model block) */
|
|
|
|
vector<string> parallel_local_files;
|
|
|
|
|
2006-12-12 12:54:30 +01:00
|
|
|
private:
|
|
|
|
//! List of statements
|
|
|
|
vector<Statement *> statements;
|
2006-12-15 12:44:58 +01:00
|
|
|
//! Structure of the mod file
|
|
|
|
ModFileStructure mod_file_struct;
|
2013-02-26 16:50:05 +01:00
|
|
|
//! Warnings Encountered
|
|
|
|
WarningConsolidation &warnings;
|
2006-12-12 12:54:30 +01:00
|
|
|
|
|
|
|
public:
|
|
|
|
//! Add a statement
|
|
|
|
void addStatement(Statement *st);
|
2010-06-24 15:07:15 +02:00
|
|
|
//! Add a statement at the front of the statements vector
|
|
|
|
void addStatementAtFront(Statement *st);
|
2008-12-19 11:24:31 +01:00
|
|
|
//! Evaluate all the statements
|
2009-11-06 19:31:03 +01:00
|
|
|
/*! \param warn_uninit Should a warning be displayed for uninitialized endogenous/exogenous/parameters ? */
|
|
|
|
void evalAllExpressions(bool warn_uninit);
|
2006-12-15 12:44:58 +01:00
|
|
|
//! Do some checking and fills mod_file_struct
|
2008-09-29 12:16:13 +02:00
|
|
|
/*! \todo add check for number of equations and endogenous if ramsey_policy is present */
|
2006-12-15 12:44:58 +01:00
|
|
|
void checkPass();
|
2009-09-30 17:10:31 +02:00
|
|
|
//! Perform some transformations on the model (creation of auxiliary vars and equations)
|
2013-09-13 20:37:31 +02:00
|
|
|
void transformPass(bool nostrict);
|
2006-12-15 18:31:31 +01:00
|
|
|
//! Execute computations
|
2008-10-29 16:10:51 +01:00
|
|
|
/*! \param no_tmp_terms if true, no temporary terms will be computed in the static and dynamic files */
|
2014-02-25 15:53:14 +01:00
|
|
|
void computingPass(bool no_tmp_terms, FileOutputType output);
|
2009-04-14 16:39:53 +02:00
|
|
|
//! Writes Matlab/Octave output files
|
2006-12-12 12:54:30 +01:00
|
|
|
/*!
|
|
|
|
\param basename The base name used for writing output files. Should be the name of the mod file without its extension
|
|
|
|
\param clear_all Should a "clear all" instruction be written to output ?
|
2010-10-28 11:19:11 +02:00
|
|
|
\param console Are we in console mode ?
|
2013-07-10 11:03:48 +02:00
|
|
|
\param nograph Should we build the figures?
|
2013-07-10 12:02:12 +02:00
|
|
|
\param nointeractive Should Dynare request user input?
|
2010-10-28 11:19:11 +02:00
|
|
|
\param cygwin Should the MEX command of use_dll be adapted for Cygwin?
|
2009-12-11 15:46:21 +01:00
|
|
|
\param msvc Should the MEX command of use_dll be adapted for MSVC?
|
2006-12-12 12:54:30 +01:00
|
|
|
*/
|
2015-05-10 20:29:03 +02:00
|
|
|
void writeOutputFiles(const string &basename, bool clear_all, bool clear_global, bool no_log, bool no_warn,
|
2015-05-28 11:42:12 +02:00
|
|
|
bool console, bool nograph, bool nointeractive, const ConfigFile &config_file,
|
|
|
|
bool check_model_changes, bool minimal_workspace
|
2009-12-11 15:46:21 +01:00
|
|
|
#if defined(_WIN32) || defined(__CYGWIN32__)
|
2009-12-16 18:13:23 +01:00
|
|
|
, bool cygwin, bool msvc
|
2009-12-11 15:46:21 +01:00
|
|
|
#endif
|
2009-12-16 18:13:23 +01:00
|
|
|
) const;
|
2014-04-21 19:57:40 +02:00
|
|
|
void writeExternalFiles(const string &basename, FileOutputType output, LanguageOutputType language) const;
|
|
|
|
void writeExternalFilesC(const string &basename, FileOutputType output) const;
|
|
|
|
void writeExternalFilesCC(const string &basename, FileOutputType output) const;
|
2013-08-06 21:20:36 +02:00
|
|
|
//! Writes C output files only => No further Matlab processing
|
|
|
|
void writeCOutputFiles(const string &basename) const;
|
2014-04-21 19:57:40 +02:00
|
|
|
void writeModelC(const string &basename) const;
|
2014-04-10 16:35:31 +02:00
|
|
|
//! Writes Cpp output files only => No further Matlab processing
|
|
|
|
void writeCCOutputFiles(const string &basename) const;
|
2014-04-21 19:57:40 +02:00
|
|
|
void writeModelCC(const string &basename) const;
|
2015-05-10 18:16:11 +02:00
|
|
|
|
|
|
|
void computeChecksum();
|
2006-11-28 12:56:02 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // ! MOD_FILE_HH
|