Commit 762f31ba authored by MichelJuillard's avatar MichelJuillard
Browse files

preprocessor, auxiliary variables: fixes ordering issue introduced in

347ab4d0 and corrects the earlier
ordering problem.
parent ebcc9d8f
......@@ -4018,8 +4018,14 @@ DynamicModel::substituteLeadLagInternal(aux_var_t type, bool deterministic_model
for (int i = 0; i < (int) neweqs.size(); i++)
addEquation(neweqs[i]);
// Add the new set of equations at the *beginning* of aux_equations
copy(neweqs.rbegin(), neweqs.rend(), front_inserter(aux_equations));
// Order of auxiliary variable definition equations:
// - expectation (entered before this function is called)
// - lead variables from lower lead to higher lead (need to be listed in reverse order)
// - lag variables from lower lag to higher lag
if ((type == avEndoLead) || (type == avExoLead))
copy(neweqs.rbegin(), neweqs.rend(), back_inserter(aux_equations));
else
copy(neweqs.begin(), neweqs.end(), back_inserter(aux_equations));
if (neweqs.size() > 0)
{
......
......@@ -1702,7 +1702,7 @@ StaticModel::writeLatexFile(const string &basename) const
void
StaticModel::writeAuxVarInitval(ostream &output, ExprNodeOutputType output_type) const
{
for (int i = (int) aux_equations.size()-1; i >= 0; i--)
for (int i = 0; i < (int) aux_equations.size(); i++)
{
dynamic_cast<ExprNode *>(aux_equations[i])->writeOutput(output, output_type);
output << ";" << endl;
......@@ -1730,7 +1730,7 @@ void StaticModel::writeAuxVarRecursiveDefinitions(const string &basename) const
<< "% from model file (.mod)" << endl
<< endl;
for (int i = (int) aux_equations.size()-1; i >= 0; i--)
for (int i = 0; i < (int) aux_equations.size(); i++)
{
dynamic_cast<ExprNode *>(aux_equations[i])->writeOutput(output, oMatlabStaticModel);
output << ";" << endl;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment