From 0808ba42b70c68d26bfcb8242589597383dc3053 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 --- ComputingTasks.cc | 1 + DynareBison.yy | 3 ++- DynareFlex.ll | 1 + ModFile.cc | 18 +++++++++++++----- ModFile.hh | 3 +++ ParsingDriver.cc | 7 +++++++ ParsingDriver.hh | 2 ++ Statement.cc | 1 + Statement.hh | 2 ++ 9 files changed, 32 insertions(+), 6 deletions(-) diff --git a/ComputingTasks.cc b/ComputingTasks.cc index ac377eca..20118f1e 100644 --- a/ComputingTasks.cc +++ b/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/DynareBison.yy b/DynareBison.yy index 48076c94..e5254ae9 100644 --- a/DynareBison.yy +++ b/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/DynareFlex.ll b/DynareFlex.ll index ea329b9f..113a73e7 100644 --- a/DynareFlex.ll +++ b/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/ModFile.cc b/ModFile.cc index 0ee3b6ff..048365a2 100644 --- a/ModFile.cc +++ b/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/ModFile.hh b/ModFile.hh index def8595d..5af71538 100644 --- a/ModFile.hh +++ b/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/ParsingDriver.cc b/ParsingDriver.cc index 3c6bba6c..dfdd62f2 100644 --- a/ParsingDriver.cc +++ b/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/ParsingDriver.hh b/ParsingDriver.hh index f4ed5fb8..59210220 100644 --- a/ParsingDriver.hh +++ b/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/Statement.cc b/Statement.cc index 08295127..db9cd915 100644 --- a/Statement.cc +++ b/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/Statement.hh b/Statement.hh index b745a16d..170322ae 100644 --- a/Statement.hh +++ b/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