preprocessor: issue warning when param used with lead/lag. closes #976

time-shift
Houtan Bastani 2015-07-30 14:40:03 +02:00
parent a4db6f9be8
commit c88c17728e
7 changed files with 36 additions and 4 deletions

View File

@ -495,6 +495,7 @@ M_.exo_histval = [];
M_.exo_det_histval = [];
M_.Correlation_matrix = [];
M_.Correlation_matrix_ME = [];
M_.parameter_used_with_lead_lag = false;
% homotopy for steady state
options_.homotopy_mode = 0;

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2003-2014 Dynare Team
* Copyright (C) 2003-2015 Dynare Team
*
* This file is part of Dynare.
*
@ -72,6 +72,16 @@ DataTree::AddVariableInternal(int symb_id, int lag)
return new VariableNode(*this, symb_id, lag);
}
bool
DataTree::ParamUsedWithLeadLagInternal() const
{
for (variable_node_map_t::const_iterator it = variable_node_map.begin();
it != variable_node_map.end(); it++)
if (symbol_table.getType(it->first.first) == eParameter && it->first.second != 0)
return true;
return false;
}
VariableNode *
DataTree::AddVariable(int symb_id, int lag)
{

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2003-2014 Dynare Team
* Copyright (C) 2003-2015 Dynare Team
*
* This file is part of Dynare.
*
@ -88,6 +88,8 @@ protected:
//! Internal implementation of AddVariable(), without the check on the lag
VariableNode *AddVariableInternal(int symb_id, int lag);
//! Internal implementation of ParamUsedWithLeadLag()
bool ParamUsedWithLeadLagInternal() const;
private:
typedef list<expr_t> node_list_t;
//! The list of nodes

View File

@ -3499,6 +3499,12 @@ DynamicModel::toStatic(StaticModel &static_model) const
static_model.addAuxEquation((*it)->toStatic(static_model));
}
bool
DynamicModel::ParamUsedWithLeadLag() const
{
return ParamUsedWithLeadLagInternal();
}
set<int>
DynamicModel::findUnusedEndogenous()
{

View File

@ -469,6 +469,9 @@ public:
};
bool isModelLocalVariableUsed() const;
//! Returns true if a parameter was used in the model block with a lead or lag
bool ParamUsedWithLeadLag() const;
//! Writes model initialization and lead/lag incidence matrix to C output
void writeCOutput(ostream &output, const string &basename, bool block, bool byte_code, bool use_dll, int order, bool estimation_present) const;
//! Writes model initialization and lead/lag incidence matrix to Cpp output

View File

@ -41,7 +41,7 @@ ModFile::ModFile(WarningConsolidation &warnings_arg)
linear(false), block(false), byte_code(false), use_dll(false), no_static(false),
differentiate_forward_vars(false),
nonstationary_variables(false), orig_eqn_nbr(0), ramsey_eqn_nbr(0),
warnings(warnings_arg)
param_used_with_lead_lag(false), warnings(warnings_arg)
{
}
@ -120,6 +120,10 @@ ModFile::checkPass()
if (!mod_file_struct.order_option)
mod_file_struct.order_option = 2;
param_used_with_lead_lag = dynamic_model.ParamUsedWithLeadLag();
if (param_used_with_lead_lag)
warnings << "WARNING: A parameter was used with a lead or a lag in the model block" << endl;
bool stochastic_statement_present = mod_file_struct.stoch_simul_present
|| mod_file_struct.estimation_present
|| mod_file_struct.osr_present
@ -599,7 +603,10 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool clear_glo
if (nointeractive)
mOutputFile << "options_.nointeractive = 1;" << endl;
if (param_used_with_lead_lag)
mOutputFile << "M_.parameter_used_with_lead_lag = true;" << endl;
cout << "Processing outputs ..." << endl;
symbol_table.writeOutput(mOutputFile);

View File

@ -107,6 +107,9 @@ public:
//! Stores the number of equations added to the Ramsey model
int ramsey_eqn_nbr;
//! Parameter used with lead/lag
bool param_used_with_lead_lag;
//! Stores the list of extra files to be transefered during a parallel run
/*! (i.e. option parallel_local_files of model block) */
vector<string> parallel_local_files;