From 2a2da609c268062f3b0c27702145cfd7449c6782 Mon Sep 17 00:00:00 2001 From: Houtan Bastani Date: Tue, 3 Jan 2012 16:51:52 +0100 Subject: [PATCH] ms-sbvar: enforce consecutive chain numbers for markov_switching --- preprocessor/ComputingTasks.cc | 12 +++++++++++- preprocessor/Statement.cc | 5 +++-- preprocessor/Statement.hh | 4 +++- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/preprocessor/ComputingTasks.cc b/preprocessor/ComputingTasks.cc index 55de98bcb..2051b5fb7 100644 --- a/preprocessor/ComputingTasks.cc +++ b/preprocessor/ComputingTasks.cc @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2011 Dynare Team + * Copyright (C) 2003-2012 Dynare Team * * This file is part of Dynare. * @@ -1427,6 +1427,16 @@ MarkovSwitchingStatement::MarkovSwitchingStatement(const OptionsList &options_li void MarkovSwitchingStatement::checkPass(ModFileStructure &mod_file_struct) { + OptionsList::num_options_t::const_iterator itChain = options_list.num_options.find("ms.chain"); + assert(itChain != options_list.num_options.end()); + int chainNumber = atoi(itChain->second.c_str()); + if (++mod_file_struct.last_markov_switching_chain != chainNumber) + { + cerr << "ERROR: The markov_switching chain option takes consecutive integers " + << "beginning at 1." << endl; + exit(EXIT_FAILURE); + } + OptionsList::num_options_t::const_iterator it_num = options_list.num_options.find("ms.restrictions"); if (it_num != options_list.num_options.end()) { diff --git a/preprocessor/Statement.cc b/preprocessor/Statement.cc index 0d2d8cf06..67ca01a1b 100644 --- a/preprocessor/Statement.cc +++ b/preprocessor/Statement.cc @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006-2011 Dynare Team + * Copyright (C) 2006-2012 Dynare Team * * This file is part of Dynare. * @@ -50,7 +50,8 @@ ModFileStructure::ModFileStructure() : corr_prior_statement_present(false), options_statement_present(false), std_options_statement_present(false), - corr_options_statement_present(false) + corr_options_statement_present(false), + last_markov_switching_chain(0) { } diff --git a/preprocessor/Statement.hh b/preprocessor/Statement.hh index 9aeecf95e..ccfcbaeb1 100644 --- a/preprocessor/Statement.hh +++ b/preprocessor/Statement.hh @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006-2011 Dynare Team + * Copyright (C) 2006-2012 Dynare Team * * This file is part of Dynare. * @@ -100,6 +100,8 @@ public: bool std_options_statement_present; //! Whether there is a corr options statement present bool corr_options_statement_present; + //! Last chain number for Markov Switching statement + int last_markov_switching_chain; }; class Statement