From 46e144ad80cd70275c06de97a192898e2eb4fe58 Mon Sep 17 00:00:00 2001 From: ferhat Date: Fri, 8 Jan 2010 11:06:25 +0000 Subject: [PATCH] Add new model option no_static : avoid to compute the static model. Useful for models without steady-state. git-svn-id: https://www.dynare.org/svn/dynare/trunk@3319 ac1d8469-bf42-47a9-8791-bf33cf982152 --- preprocessor/ComputingTasks.cc | 1 + preprocessor/DynareBison.yy | 3 ++- preprocessor/DynareFlex.ll | 1 + preprocessor/ModFile.cc | 18 +++++++++++++----- preprocessor/ModFile.hh | 3 +++ preprocessor/ParsingDriver.cc | 7 +++++++ preprocessor/ParsingDriver.hh | 2 ++ preprocessor/Statement.cc | 1 + preprocessor/Statement.hh | 2 ++ 9 files changed, 32 insertions(+), 6 deletions(-) diff --git a/preprocessor/ComputingTasks.cc b/preprocessor/ComputingTasks.cc index ac377eca6..20118f1eb 100644 --- a/preprocessor/ComputingTasks.cc +++ b/preprocessor/ComputingTasks.cc @@ -35,6 +35,7 @@ SteadyStatement::SteadyStatement(const OptionsList &options_list_arg) : void SteadyStatement::checkPass(ModFileStructure &mod_file_struct) { + mod_file_struct.steady_present = true; } void diff --git a/preprocessor/DynareBison.yy b/preprocessor/DynareBison.yy index 48076c948..e5254ae90 100644 --- a/preprocessor/DynareBison.yy +++ b/preprocessor/DynareBison.yy @@ -111,7 +111,7 @@ class ParsingDriver; %token MODE_CHECK MODE_COMPUTE MODE_FILE MODEL MODEL_COMPARISON MODEL_INFO MSHOCKS %token MODIFIEDHARMONICMEAN MOMENTS_VARENDO DIFFUSE_FILTER %token NAME -%token NAN_CONSTANT NOBS NOCONSTANT NOCORR NODIAGNOSTIC NOFUNCTIONS +%token NAN_CONSTANT NO_STATIC NOBS NOCONSTANT NOCORR NODIAGNOSTIC NOFUNCTIONS %token NOGRAPH NOMOMENTS NOPRINT NORMAL_PDF %token OBSERVATION_TRENDS OPTIM OPTIM_WEIGHTS ORDER OSR OSR_PARAMS %token PARAMETERS PARAMETER_SET PARTIAL_INFORMATION PERIODS PLANNER_OBJECTIVE PLOT_CONDITIONAL_FORECAST PLOT_PRIORS PREFILTER PRESAMPLE @@ -463,6 +463,7 @@ model_options : BLOCK { driver.block(); } | o_mfs | BYTECODE { driver.byte_code(); } | USE_DLL { driver.use_dll(); } + | NO_STATIC { driver.no_static();} | o_linear ; diff --git a/preprocessor/DynareFlex.ll b/preprocessor/DynareFlex.ll index ea329b9f5..113a73e7f 100644 --- a/preprocessor/DynareFlex.ll +++ b/preprocessor/DynareFlex.ll @@ -416,6 +416,7 @@ int sigma_e = 0; use_dll {return token::USE_DLL;} block {return token::BLOCK;} bytecode {return token::BYTECODE;} +no_static {return token::NO_STATIC;} linear {return token::LINEAR;} diff --git a/preprocessor/ModFile.cc b/preprocessor/ModFile.cc index 0ee3b6ff1..048365a2e 100644 --- a/preprocessor/ModFile.cc +++ b/preprocessor/ModFile.cc @@ -27,7 +27,7 @@ ModFile::ModFile() : expressions_tree(symbol_table, num_constants), static_model(symbol_table, num_constants), dynamic_model(symbol_table, num_constants), linear(false), block(false), byte_code(false), - use_dll(false) + use_dll(false), no_static(false) { } @@ -134,6 +134,12 @@ ModFile::checkPass() cerr << "ERROR: In 'model' block, can't use option 'bytecode' without option 'block'" << endl; exit(EXIT_FAILURE); } + if (stochastic_statement_present || mod_file_struct.check_present || mod_file_struct.steady_present && no_static) + { + cerr << "no_static option is incompatible with stochastic simulation, estimation, optimal policy, steady or check command" << endl; + exit(EXIT_FAILURE); + } + } void @@ -187,7 +193,8 @@ ModFile::computingPass(bool no_tmp_terms) { // Compute static model and its derivatives dynamic_model.toStatic(static_model); - static_model.computingPass(global_eval_context, no_tmp_terms, false, block); + if(!no_static) + static_model.computingPass(global_eval_context, no_tmp_terms, false, block); // Set things to compute for dynamic model if (dynamic_model_needed) { @@ -336,7 +343,7 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all dynamic_model.writeOutput(mOutputFile, basename, block, byte_code, use_dll); else dynamic_model.writeOutput(mOutputFile, basename, false, false, false); - if (!byte_code) + if (!byte_code && !no_static) static_model.writeOutput(mOutputFile, block); } @@ -356,7 +363,7 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all // Special treatment for load params and steady state statement: insert initial values for the auxiliary variables LoadParamsAndSteadyStateStatement *lpass = dynamic_cast(*it); - if (lpass) + if (lpass && !no_static) static_model.writeAuxVarInitval(mOutputFile); } @@ -373,7 +380,8 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all // Create static and dynamic files if (dynamic_model.equation_number() > 0) { - static_model.writeStaticFile(basename, block, byte_code); + if (!no_static) + static_model.writeStaticFile(basename, block, byte_code); if (dynamic_model_needed) { diff --git a/preprocessor/ModFile.hh b/preprocessor/ModFile.hh index def8595dd..5af71538e 100644 --- a/preprocessor/ModFile.hh +++ b/preprocessor/ModFile.hh @@ -60,6 +60,9 @@ public: //! Is the model stored in a MEX file ? (option "use_dll" of "model") bool use_dll; + //! Is the static model have to computed (no_static=false) or not (no_static=true). Option of 'model' + bool no_static; + //! Global evaluation context /*! Filled using initval blocks and parameters initializations */ eval_context_type global_eval_context; diff --git a/preprocessor/ParsingDriver.cc b/preprocessor/ParsingDriver.cc index 3c6bba6c1..dfdd62f26 100644 --- a/preprocessor/ParsingDriver.cc +++ b/preprocessor/ParsingDriver.cc @@ -365,6 +365,13 @@ ParsingDriver::block() mod_file->block = true; } + +void +ParsingDriver::no_static() +{ + mod_file->no_static = true; +} + void ParsingDriver::byte_code() { diff --git a/preprocessor/ParsingDriver.hh b/preprocessor/ParsingDriver.hh index f4ed5fb80..592102203 100644 --- a/preprocessor/ParsingDriver.hh +++ b/preprocessor/ParsingDriver.hh @@ -188,6 +188,8 @@ public: void block(); //! the model is stored in a binary file void byte_code(); + //! the static model is not computed + void no_static(); //! cutoff option of model block void cutoff(string *value); //! mfs option of model block diff --git a/preprocessor/Statement.cc b/preprocessor/Statement.cc index 08295127f..db9cd915a 100644 --- a/preprocessor/Statement.cc +++ b/preprocessor/Statement.cc @@ -21,6 +21,7 @@ ModFileStructure::ModFileStructure() : check_present(false), + steady_present(false), simul_present(false), stoch_simul_present(false), estimation_present(false), diff --git a/preprocessor/Statement.hh b/preprocessor/Statement.hh index b745a16d5..170322ae8 100644 --- a/preprocessor/Statement.hh +++ b/preprocessor/Statement.hh @@ -34,6 +34,8 @@ public: ModFileStructure(); //! Wheter check is present bool check_present; + //! Wheter steady is present + bool steady_present; //! Whether a simul statement is present bool simul_present; //! Whether a stoch_simul statement is present