extend nopreprocessoroutput option to substitution output
parent
16a97a96fd
commit
41af0841c3
|
@ -5626,31 +5626,31 @@ DynamicModel::writeLatexOriginalFile(const string &basename, const bool write_eq
|
|||
}
|
||||
|
||||
void
|
||||
DynamicModel::substituteEndoLeadGreaterThanTwo(bool deterministic_model)
|
||||
DynamicModel::substituteEndoLeadGreaterThanTwo(bool deterministic_model, bool nopreprocessoroutput)
|
||||
{
|
||||
substituteLeadLagInternal(AuxVarType::endoLead, deterministic_model, vector<string>());
|
||||
substituteLeadLagInternal(AuxVarType::endoLead, deterministic_model, vector<string>(), nopreprocessoroutput);
|
||||
}
|
||||
|
||||
void
|
||||
DynamicModel::substituteEndoLagGreaterThanTwo(bool deterministic_model)
|
||||
DynamicModel::substituteEndoLagGreaterThanTwo(bool deterministic_model, bool nopreprocessoroutput)
|
||||
{
|
||||
substituteLeadLagInternal(AuxVarType::endoLag, deterministic_model, vector<string>());
|
||||
substituteLeadLagInternal(AuxVarType::endoLag, deterministic_model, vector<string>(), nopreprocessoroutput);
|
||||
}
|
||||
|
||||
void
|
||||
DynamicModel::substituteExoLead(bool deterministic_model)
|
||||
DynamicModel::substituteExoLead(bool deterministic_model, bool nopreprocessoroutput)
|
||||
{
|
||||
substituteLeadLagInternal(AuxVarType::exoLead, deterministic_model, vector<string>());
|
||||
substituteLeadLagInternal(AuxVarType::exoLead, deterministic_model, vector<string>(), nopreprocessoroutput);
|
||||
}
|
||||
|
||||
void
|
||||
DynamicModel::substituteExoLag(bool deterministic_model)
|
||||
DynamicModel::substituteExoLag(bool deterministic_model, bool nopreprocessoroutput)
|
||||
{
|
||||
substituteLeadLagInternal(AuxVarType::exoLag, deterministic_model, vector<string>());
|
||||
substituteLeadLagInternal(AuxVarType::exoLag, deterministic_model, vector<string>(), nopreprocessoroutput);
|
||||
}
|
||||
|
||||
void
|
||||
DynamicModel::substituteLeadLagInternal(AuxVarType type, bool deterministic_model, const vector<string> &subset)
|
||||
DynamicModel::substituteLeadLagInternal(AuxVarType type, bool deterministic_model, const vector<string> &subset, bool nopreprocessoroutput)
|
||||
{
|
||||
ExprNode::subst_table_t subst_table;
|
||||
vector<BinaryOpNode *> neweqs;
|
||||
|
@ -5728,7 +5728,7 @@ DynamicModel::substituteLeadLagInternal(AuxVarType type, bool deterministic_mode
|
|||
// - lag variables from lower lag to higher lag
|
||||
copy(neweqs.begin(), neweqs.end(), back_inserter(aux_equations));
|
||||
|
||||
if (neweqs.size() > 0)
|
||||
if (!nopreprocessoroutput && neweqs.size() > 0)
|
||||
{
|
||||
cout << "Substitution of ";
|
||||
switch (type)
|
||||
|
@ -5793,24 +5793,24 @@ DynamicModel::findPacExpectationEquationNumbers(vector<int> &eqnumbers) const
|
|||
}
|
||||
|
||||
void
|
||||
DynamicModel::substituteUnaryOps(StaticModel &static_model)
|
||||
DynamicModel::substituteUnaryOps(StaticModel &static_model, bool nopreprocessoroutput)
|
||||
{
|
||||
vector<int> eqnumbers(equations.size());
|
||||
iota(eqnumbers.begin(), eqnumbers.end(), 0);
|
||||
substituteUnaryOps(static_model, eqnumbers);
|
||||
substituteUnaryOps(static_model, eqnumbers, nopreprocessoroutput);
|
||||
}
|
||||
|
||||
void
|
||||
DynamicModel::substituteUnaryOps(StaticModel &static_model, set<string> &var_model_eqtags)
|
||||
DynamicModel::substituteUnaryOps(StaticModel &static_model, set<string> &var_model_eqtags, bool nopreprocessoroutput)
|
||||
{
|
||||
vector<int> eqnumbers;
|
||||
getEquationNumbersFromTags(eqnumbers, var_model_eqtags);
|
||||
findPacExpectationEquationNumbers(eqnumbers);
|
||||
substituteUnaryOps(static_model, eqnumbers);
|
||||
substituteUnaryOps(static_model, eqnumbers, nopreprocessoroutput);
|
||||
}
|
||||
|
||||
void
|
||||
DynamicModel::substituteUnaryOps(StaticModel &static_model, vector<int> &eqnumbers)
|
||||
DynamicModel::substituteUnaryOps(StaticModel &static_model, vector<int> &eqnumbers, bool nopreprocessoroutput)
|
||||
{
|
||||
diff_table_t nodes;
|
||||
|
||||
|
@ -5848,12 +5848,12 @@ DynamicModel::substituteUnaryOps(StaticModel &static_model, vector<int> &eqnumbe
|
|||
|
||||
copy(neweqs.begin(), neweqs.end(), back_inserter(aux_equations));
|
||||
|
||||
if (subst_table.size() > 0)
|
||||
if (!nopreprocessoroutput && subst_table.size() > 0)
|
||||
cout << "Substitution of Unary Ops: added " << neweqs.size() << " auxiliary variables and equations." << endl;
|
||||
}
|
||||
|
||||
void
|
||||
DynamicModel::substituteDiff(StaticModel &static_model, ExprNode::subst_table_t &diff_subst_table)
|
||||
DynamicModel::substituteDiff(StaticModel &static_model, ExprNode::subst_table_t &diff_subst_table, bool nopreprocessoroutput)
|
||||
{
|
||||
set<int> used_local_vars;
|
||||
for (const auto & equation : equations)
|
||||
|
@ -5911,12 +5911,12 @@ DynamicModel::substituteDiff(StaticModel &static_model, ExprNode::subst_table_t
|
|||
|
||||
copy(neweqs.begin(), neweqs.end(), back_inserter(aux_equations));
|
||||
|
||||
if (diff_subst_table.size() > 0)
|
||||
if (!nopreprocessoroutput && diff_subst_table.size() > 0)
|
||||
cout << "Substitution of Diff operator: added " << neweqs.size() << " auxiliary variables and equations." << endl;
|
||||
}
|
||||
|
||||
void
|
||||
DynamicModel::substituteExpectation(bool partial_information_model)
|
||||
DynamicModel::substituteExpectation(bool partial_information_model, bool nopreprocessoroutput)
|
||||
{
|
||||
ExprNode::subst_table_t subst_table;
|
||||
vector<BinaryOpNode *> neweqs;
|
||||
|
@ -5940,7 +5940,7 @@ DynamicModel::substituteExpectation(bool partial_information_model)
|
|||
// Add the new set of equations at the *beginning* of aux_equations
|
||||
copy(neweqs.rbegin(), neweqs.rend(), front_inserter(aux_equations));
|
||||
|
||||
if (subst_table.size() > 0)
|
||||
if (!nopreprocessoroutput && subst_table.size() > 0)
|
||||
{
|
||||
if (partial_information_model)
|
||||
cout << "Substitution of Expectation operator: added " << subst_table.size() << " auxiliary variables and " << neweqs.size() << " auxiliary equations." << endl;
|
||||
|
@ -5996,9 +5996,9 @@ DynamicModel::removeTrendVariableFromEquations()
|
|||
}
|
||||
|
||||
void
|
||||
DynamicModel::differentiateForwardVars(const vector<string> &subset)
|
||||
DynamicModel::differentiateForwardVars(const vector<string> &subset, bool nopreprocessoroutput)
|
||||
{
|
||||
substituteLeadLagInternal(AuxVarType::diffForward, true, subset);
|
||||
substituteLeadLagInternal(AuxVarType::diffForward, true, subset, nopreprocessoroutput);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -180,7 +180,7 @@ private:
|
|||
\param[in] deterministic_model whether we are in a deterministic model (only for exogenous leads/lags)
|
||||
\param[in] subset variables to which to apply the transformation (only for diff of forward vars)
|
||||
*/
|
||||
void substituteLeadLagInternal(AuxVarType type, bool deterministic_model, const vector<string> &subset);
|
||||
void substituteLeadLagInternal(AuxVarType type, bool deterministic_model, const vector<string> &subset, bool nopreprocessoroutput);
|
||||
|
||||
//! Indicate if the temporary terms are computed for the overall model (true) or not (false). Default value true
|
||||
bool global_temporary_terms{true};
|
||||
|
@ -412,20 +412,20 @@ public:
|
|||
|
||||
//! Transforms the model by removing all leads greater or equal than 2 on endos
|
||||
/*! Note that this can create new lags on endos and exos */
|
||||
void substituteEndoLeadGreaterThanTwo(bool deterministic_model);
|
||||
void substituteEndoLeadGreaterThanTwo(bool deterministic_model, bool nopreprocessoroutput);
|
||||
|
||||
//! Transforms the model by removing all lags greater or equal than 2 on endos
|
||||
void substituteEndoLagGreaterThanTwo(bool deterministic_model);
|
||||
void substituteEndoLagGreaterThanTwo(bool deterministic_model, bool nopreprocessoroutput);
|
||||
|
||||
//! Transforms the model by removing all leads on exos
|
||||
/*! Note that this can create new lags on endos and exos */
|
||||
void substituteExoLead(bool deterministic_model);
|
||||
void substituteExoLead(bool deterministic_model, bool nopreprocessoroutput);
|
||||
|
||||
//! Transforms the model by removing all lags on exos
|
||||
void substituteExoLag(bool deterministic_model);
|
||||
void substituteExoLag(bool deterministic_model, bool nopreprocessoroutput);
|
||||
|
||||
//! Transforms the model by removing all UnaryOpcode::expectation
|
||||
void substituteExpectation(bool partial_information_model);
|
||||
void substituteExpectation(bool partial_information_model, bool nopreprocessoroutput);
|
||||
|
||||
//! Transforms the model by decreasing the lead/lag of predetermined variables in model equations by one
|
||||
void transformPredeterminedVariables();
|
||||
|
@ -437,16 +437,16 @@ public:
|
|||
void substituteAdl();
|
||||
|
||||
//! Creates aux vars for all unary operators
|
||||
void substituteUnaryOps(StaticModel &static_model);
|
||||
void substituteUnaryOps(StaticModel &static_model, bool nopreprocessoroutput);
|
||||
|
||||
//! Creates aux vars for certain unary operators: originally implemented for support of VARs
|
||||
void substituteUnaryOps(StaticModel &static_model, set<string> &eq_tags);
|
||||
void substituteUnaryOps(StaticModel &static_model, set<string> &eq_tags, bool nopreprocessoroutput);
|
||||
|
||||
//! Creates aux vars for certain unary operators: originally implemented for support of VARs
|
||||
void substituteUnaryOps(StaticModel &static_model, vector<int> &eqnumbers);
|
||||
void substituteUnaryOps(StaticModel &static_model, vector<int> &eqnumbers, bool nopreprocessoroutput);
|
||||
|
||||
//! Substitutes diff operator
|
||||
void substituteDiff(StaticModel &static_model, ExprNode::subst_table_t &diff_subst_table);
|
||||
void substituteDiff(StaticModel &static_model, ExprNode::subst_table_t &diff_subst_table, bool nopreprocessoroutput);
|
||||
|
||||
//! Substitute VarExpectation operators
|
||||
void substituteVarExpectation(const map<string, expr_t> &subst_table);
|
||||
|
@ -464,7 +464,7 @@ public:
|
|||
//! Transforms the model by creating aux vars for the diff of forward vars
|
||||
/*! If subset is empty, does the transformation for all fwrd vars; otherwise
|
||||
restrict it to the vars in subset */
|
||||
void differentiateForwardVars(const vector<string> &subset);
|
||||
void differentiateForwardVars(const vector<string> &subset, bool nopreprocessoroutput);
|
||||
|
||||
//! Fills eval context with values of model local variables and auxiliary variables
|
||||
void fillEvalContext(eval_context_t &eval_context) const;
|
||||
|
|
|
@ -392,14 +392,14 @@ ModFile::transformPass(bool nostrict, bool stochastic, bool compute_xrefs, const
|
|||
eqtags.insert(it1);
|
||||
|
||||
if (transform_unary_ops)
|
||||
dynamic_model.substituteUnaryOps(diff_static_model);
|
||||
dynamic_model.substituteUnaryOps(diff_static_model, nopreprocessoroutput);
|
||||
else
|
||||
// substitute only those unary ops that appear in auxiliary model equations
|
||||
dynamic_model.substituteUnaryOps(diff_static_model, eqtags);
|
||||
dynamic_model.substituteUnaryOps(diff_static_model, eqtags, nopreprocessoroutput);
|
||||
|
||||
// Create auxiliary variable and equations for Diff operators that appear in VAR equations
|
||||
ExprNode::subst_table_t diff_subst_table;
|
||||
dynamic_model.substituteDiff(diff_static_model, diff_subst_table);
|
||||
dynamic_model.substituteDiff(diff_static_model, diff_subst_table, nopreprocessoroutput);
|
||||
|
||||
// Fill Trend Component Model Table
|
||||
dynamic_model.fillTrendComponentModelTable();
|
||||
|
@ -455,7 +455,7 @@ ModFile::transformPass(bool nostrict, bool stochastic, bool compute_xrefs, const
|
|||
dynamic_model.transformPredeterminedVariables();
|
||||
|
||||
// Create auxiliary vars for Expectation operator
|
||||
dynamic_model.substituteExpectation(mod_file_struct.partial_information);
|
||||
dynamic_model.substituteExpectation(mod_file_struct.partial_information, nopreprocessoroutput);
|
||||
|
||||
if (nonstationary_variables)
|
||||
{
|
||||
|
@ -578,22 +578,22 @@ ModFile::transformPass(bool nostrict, bool stochastic, bool compute_xrefs, const
|
|||
|| stochastic )
|
||||
{
|
||||
// In stochastic models, create auxiliary vars for leads and lags greater than 2, on both endos and exos
|
||||
dynamic_model.substituteEndoLeadGreaterThanTwo(false);
|
||||
dynamic_model.substituteExoLead(false);
|
||||
dynamic_model.substituteEndoLagGreaterThanTwo(false);
|
||||
dynamic_model.substituteExoLag(false);
|
||||
dynamic_model.substituteEndoLeadGreaterThanTwo(false, nopreprocessoroutput);
|
||||
dynamic_model.substituteExoLead(false, nopreprocessoroutput);
|
||||
dynamic_model.substituteEndoLagGreaterThanTwo(false, nopreprocessoroutput);
|
||||
dynamic_model.substituteExoLag(false, nopreprocessoroutput);
|
||||
}
|
||||
else
|
||||
{
|
||||
// In deterministic models, create auxiliary vars for leads and lags endogenous greater than 2, only on endos (useless on exos)
|
||||
dynamic_model.substituteEndoLeadGreaterThanTwo(true);
|
||||
dynamic_model.substituteEndoLagGreaterThanTwo(true);
|
||||
dynamic_model.substituteEndoLeadGreaterThanTwo(true, nopreprocessoroutput);
|
||||
dynamic_model.substituteEndoLagGreaterThanTwo(true, nopreprocessoroutput);
|
||||
}
|
||||
|
||||
dynamic_model.updateVarAndTrendModel();
|
||||
|
||||
if (differentiate_forward_vars)
|
||||
dynamic_model.differentiateForwardVars(differentiate_forward_vars_subset);
|
||||
dynamic_model.differentiateForwardVars(differentiate_forward_vars_subset, nopreprocessoroutput);
|
||||
|
||||
if (mod_file_struct.dsge_var_estimated || !mod_file_struct.dsge_var_calibrated.empty())
|
||||
try
|
||||
|
|
Loading…
Reference in New Issue