ms-sbvar: enforce consecutive chain numbers for markov_switching

time-shift
Houtan Bastani 2012-01-03 16:51:52 +01:00
parent 7ec25ee27e
commit 2a2da609c2
3 changed files with 17 additions and 4 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2003-2011 Dynare Team * Copyright (C) 2003-2012 Dynare Team
* *
* This file is part of Dynare. * This file is part of Dynare.
* *
@ -1427,6 +1427,16 @@ MarkovSwitchingStatement::MarkovSwitchingStatement(const OptionsList &options_li
void void
MarkovSwitchingStatement::checkPass(ModFileStructure &mod_file_struct) 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"); OptionsList::num_options_t::const_iterator it_num = options_list.num_options.find("ms.restrictions");
if (it_num != options_list.num_options.end()) if (it_num != options_list.num_options.end())
{ {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2006-2011 Dynare Team * Copyright (C) 2006-2012 Dynare Team
* *
* This file is part of Dynare. * This file is part of Dynare.
* *
@ -50,7 +50,8 @@ ModFileStructure::ModFileStructure() :
corr_prior_statement_present(false), corr_prior_statement_present(false),
options_statement_present(false), options_statement_present(false),
std_options_statement_present(false), std_options_statement_present(false),
corr_options_statement_present(false) corr_options_statement_present(false),
last_markov_switching_chain(0)
{ {
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2006-2011 Dynare Team * Copyright (C) 2006-2012 Dynare Team
* *
* This file is part of Dynare. * This file is part of Dynare.
* *
@ -100,6 +100,8 @@ public:
bool std_options_statement_present; bool std_options_statement_present;
//! Whether there is a corr options statement present //! Whether there is a corr options statement present
bool corr_options_statement_present; bool corr_options_statement_present;
//! Last chain number for Markov Switching statement
int last_markov_switching_chain;
}; };
class Statement class Statement