preprocessor: add all_values_required option to histval. closes #261
parent
3d16707dd9
commit
ea4ec224e1
|
@ -2446,6 +2446,7 @@ jump from t=200 to t=201.
|
|||
@end deffn
|
||||
|
||||
@deffn Block histval ;
|
||||
@deffnx Block histval (@var{OPTIONS}@dots{});
|
||||
@anchor{histval}
|
||||
@descriptionhead
|
||||
|
||||
|
@ -2504,6 +2505,17 @@ of the Lagrange multipliers associated with the planner's problem cannot be set
|
|||
|
||||
@end itemize
|
||||
|
||||
@optionshead
|
||||
|
||||
@table @code
|
||||
|
||||
@item all_values_required
|
||||
@anchor{all_values_required}
|
||||
Issues an error and stops processing the @file{.mod} file if there is at least
|
||||
one endogenous or exogenous variable that has not been set in the @code{histval}
|
||||
block.
|
||||
@end table
|
||||
|
||||
|
||||
@examplehead
|
||||
|
||||
|
|
|
@ -636,7 +636,11 @@ initval_list : initval_list initval_elem
|
|||
|
||||
initval_elem : symbol EQUAL expression ';' { driver.init_val($1, $3); };
|
||||
|
||||
histval : HISTVAL ';' histval_list END ';' { driver.end_histval(); };
|
||||
histval : HISTVAL ';' histval_list END ';'
|
||||
{ driver.end_histval(false); };
|
||||
| HISTVAL '(' ALL_VALUES_REQUIRED ')' ';' histval_list END ';'
|
||||
{ driver.end_histval(true); }
|
||||
;
|
||||
|
||||
histval_list : histval_list histval_elem
|
||||
| histval_elem
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2003-2015 Dynare Team
|
||||
* Copyright (C) 2003-2016 Dynare Team
|
||||
*
|
||||
* This file is part of Dynare.
|
||||
*
|
||||
|
@ -268,9 +268,11 @@ EndValStatement::writeOutput(ostream &output, const string &basename, bool minim
|
|||
}
|
||||
|
||||
HistValStatement::HistValStatement(const hist_values_t &hist_values_arg,
|
||||
const SymbolTable &symbol_table_arg) :
|
||||
const SymbolTable &symbol_table_arg,
|
||||
const bool &all_values_required_arg) :
|
||||
hist_values(hist_values_arg),
|
||||
symbol_table(symbol_table_arg)
|
||||
symbol_table(symbol_table_arg),
|
||||
all_values_required(all_values_required_arg)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -278,6 +280,44 @@ void
|
|||
HistValStatement::checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings)
|
||||
{
|
||||
mod_file_struct.histval_present = true;
|
||||
|
||||
if (all_values_required)
|
||||
{
|
||||
set<int> unused_endo = symbol_table.getEndogenous();
|
||||
set<int> unused_exo = symbol_table.getExogenous();
|
||||
|
||||
set<int>::iterator sit;
|
||||
for (hist_values_t::const_iterator it = hist_values.begin();
|
||||
it != hist_values.end(); it++)
|
||||
{
|
||||
sit = unused_endo.find(it->first.first);
|
||||
if (sit != unused_endo.end())
|
||||
unused_endo.erase(sit);
|
||||
|
||||
sit = unused_exo.find(it->first.first);
|
||||
if (sit != unused_exo.end())
|
||||
unused_exo.erase(sit);
|
||||
}
|
||||
|
||||
if (unused_endo.size() > 0)
|
||||
{
|
||||
cerr << "ERROR: You have not set the following endogenous variables in histval:";
|
||||
for (set<int>::const_iterator it = unused_endo.begin(); it != unused_endo.end(); it++)
|
||||
cerr << " " << symbol_table.getName(*it);
|
||||
cerr << endl;
|
||||
}
|
||||
|
||||
if (unused_exo.size() > 0)
|
||||
{
|
||||
cerr << "ERROR: You have not set the following exogenous variables in endval:";
|
||||
for (set<int>::const_iterator it = unused_exo.begin(); it != unused_exo.end(); it++)
|
||||
cerr << " " << symbol_table.getName(*it);
|
||||
cerr << endl;
|
||||
}
|
||||
|
||||
if (unused_endo.size() > 0 || unused_exo.size() > 0)
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2003-2015 Dynare Team
|
||||
* Copyright (C) 2003-2016 Dynare Team
|
||||
*
|
||||
* This file is part of Dynare.
|
||||
*
|
||||
|
@ -106,9 +106,11 @@ public:
|
|||
private:
|
||||
const hist_values_t hist_values;
|
||||
const SymbolTable &symbol_table;
|
||||
const bool all_values_required;
|
||||
public:
|
||||
HistValStatement(const hist_values_t &hist_values_arg,
|
||||
const SymbolTable &symbol_table_arg);
|
||||
const SymbolTable &symbol_table_arg,
|
||||
const bool &all_values_required_arg);
|
||||
//! Workaround for trac ticket #157
|
||||
virtual void checkPass(ModFileStructure &mod_file_struct, WarningConsolidation &warnings);
|
||||
virtual void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const;
|
||||
|
|
|
@ -614,9 +614,9 @@ ParsingDriver::end_endval(bool all_values_required)
|
|||
}
|
||||
|
||||
void
|
||||
ParsingDriver::end_histval()
|
||||
ParsingDriver::end_histval(bool all_values_required)
|
||||
{
|
||||
mod_file->addStatement(new HistValStatement(hist_values, mod_file->symbol_table));
|
||||
mod_file->addStatement(new HistValStatement(hist_values, mod_file->symbol_table, all_values_required));
|
||||
hist_values.clear();
|
||||
}
|
||||
|
||||
|
|
|
@ -335,7 +335,7 @@ public:
|
|||
//! Writes end of an endval block
|
||||
void end_endval(bool all_values_required);
|
||||
//! Writes end of an histval block
|
||||
void end_histval();
|
||||
void end_histval(bool all_values_required);
|
||||
//! Writes end of an homotopy_setup block
|
||||
void end_homotopy();
|
||||
//! Begin a model block
|
||||
|
|
Loading…
Reference in New Issue