Commit 856f6f50 authored by Houtan Bastani's avatar Houtan Bastani
Browse files

Revert "create aux vars for certain unary ops contained in diff operator"

This reverts commit f600a65c.
parent 922d0551
......@@ -5225,44 +5225,6 @@ DynamicModel::substituteDiff(StaticModel &static_model, ExprNode::subst_table_t
cout << "Substitution of Diff operator: added " << neweqs.size() << " auxiliary variables and equations." << endl;
}
void
DynamicModel::substituteDiffUnaryOps(StaticModel &static_model)
{
// Find diff Nodes
set<UnaryOpNode *> nodes;
for (map<int, expr_t>::iterator it = local_variables_table.begin();
it != local_variables_table.end(); it++)
it->second->findDiffUnaryOpNodes(static_model, nodes);
for (int i = 0; i < (int) equations.size(); i++)
equations[i]->findDiffUnaryOpNodes(static_model, nodes);
// Substitute in model local variables
ExprNode::subst_table_t subst_table;
vector<BinaryOpNode *> neweqs;
for (map<int, expr_t>::iterator it = local_variables_table.begin();
it != local_variables_table.end(); it++)
it->second = it->second->substituteDiffUnaryOpNodes(static_model, nodes, subst_table, neweqs);
// Substitute in equations
for (int i = 0; i < (int) equations.size(); i++)
{
BinaryOpNode *substeq = dynamic_cast<BinaryOpNode *>(equations[i]->
substituteDiffUnaryOpNodes(static_model, nodes, subst_table, neweqs));
assert(substeq != NULL);
equations[i] = substeq;
}
// Add new equations
for (int i = 0; i < (int) neweqs.size(); i++)
addEquation(neweqs[i], -1);
copy(neweqs.begin(), neweqs.end(), back_inserter(diff_aux_equations));
if (subst_table.size() > 0)
cout << "Substitution of Unary Ops in Diff operator: added " << neweqs.size() << " auxiliary variables and equations." << endl;
}
void
DynamicModel::combineDiffAuxEquations()
{
......
......@@ -411,7 +411,6 @@ public:
//! Substitutes diff operator
void substituteDiff(StaticModel &static_model, ExprNode::subst_table_t &diff_subst_table);
void substituteDiffUnaryOps(StaticModel &static_model);
//! Table to undiff LHS variables for pac vector z
void getUndiffLHSForPac(vector<int> &lhs, vector<expr_t> &lhs_expr_t, vector<bool> &diff, vector<int> &orig_diff_var,
......
......@@ -538,23 +538,12 @@ NumConstNode::findDiffNodes(DataTree &static_datatree, diff_table_t &diff_table)
{
}
void
NumConstNode::findDiffUnaryOpNodes(DataTree &static_datatree, set<UnaryOpNode *> &unary_op_nodes_in_diff) const
{
}
expr_t
NumConstNode::substituteDiff(DataTree &static_datatree, diff_table_t &diff_table, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const
{
return const_cast<NumConstNode *>(this);
}
expr_t
NumConstNode::substituteDiffUnaryOpNodes(DataTree &static_datatree, set<UnaryOpNode *> &nodes, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const
{
return const_cast<NumConstNode *>(this);
}
expr_t
NumConstNode::substitutePacExpectation(map<const PacExpectationNode *, const BinaryOpNode *> &subst_table)
{
......@@ -1424,11 +1413,6 @@ VariableNode::findDiffNodes(DataTree &static_datatree, diff_table_t &diff_table)
{
}
void
VariableNode::findDiffUnaryOpNodes(DataTree &static_datatree, set<UnaryOpNode *> &unary_op_nodes_in_diff) const
{
}
expr_t
VariableNode::substituteDiff(DataTree &static_datatree, diff_table_t &diff_table, subst_table_t &subst_table,
vector<BinaryOpNode *> &neweqs) const
......@@ -1436,12 +1420,6 @@ VariableNode::substituteDiff(DataTree &static_datatree, diff_table_t &diff_table
return const_cast<VariableNode *>(this);
}
expr_t
VariableNode::substituteDiffUnaryOpNodes(DataTree &static_datatree, set<UnaryOpNode *> &nodes, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const
{
return const_cast<VariableNode *>(this);
}
expr_t
VariableNode::substitutePacExpectation(map<const PacExpectationNode *, const BinaryOpNode *> &subst_table)
{
......@@ -3035,75 +3013,6 @@ UnaryOpNode::isDiffPresent() const
return arg->isDiffPresent();
}
void
UnaryOpNode::findDiffUnaryOpNodes(DataTree &static_datatree, set<UnaryOpNode *> &unary_op_nodes_in_diff) const
{
if (op_code != oDiff)
{
arg->findDiffUnaryOpNodes(static_datatree, unary_op_nodes_in_diff);
return;
}
VariableNode *vn = dynamic_cast<VariableNode *>(arg);
if (vn != NULL)
return;
UnaryOpNode *sarg = dynamic_cast<UnaryOpNode *>(arg->toStatic(static_datatree));
if (sarg == NULL || (!sarg->createAuxVarForUnaryOpNodeInDiffOp() && sarg->get_op_code() != oDiff))
{
cerr << "Error: diff operator can only contain certain unary operations" << endl;
exit(EXIT_FAILURE);
}
if (unary_op_nodes_in_diff.find(sarg) != unary_op_nodes_in_diff.end())
return;
if (sarg->get_op_code() == oDiff)
{
arg->findDiffUnaryOpNodes(static_datatree, unary_op_nodes_in_diff);
return;
}
vn = dynamic_cast<VariableNode *>(sarg->get_arg());
if (vn == NULL)
{
cerr << "Error: A unary op inside of a diff can only take a variable as an argument" << endl;
exit(EXIT_FAILURE);
}
unary_op_nodes_in_diff.insert(sarg);
}
bool
UnaryOpNode::createAuxVarForUnaryOpNodeInDiffOp() const
{
switch (op_code)
{
case oExp:
case oLog:
case oLog10:
case oCos:
case oSin:
case oTan:
case oAcos:
case oAsin:
case oAtan:
case oCosh:
case oSinh:
case oTanh:
case oAcosh:
case oAsinh:
case oAtanh:
case oSqrt:
case oAbs:
case oSign:
case oErf:
return true;
default:
return false;
}
}
void
UnaryOpNode::findDiffNodes(DataTree &static_datatree, diff_table_t &diff_table) const
{
......@@ -3288,43 +3197,6 @@ UnaryOpNode::substituteDiff(DataTree &static_datatree, diff_table_t &diff_table,
return const_cast<VariableNode *>(subst_table[this]);
}
expr_t
UnaryOpNode::substituteDiffUnaryOpNodes(DataTree &static_datatree, set<UnaryOpNode *> &nodes, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const
{
UnaryOpNode *sarg, *argtouse;
if (op_code == oDiff)
{
sarg = dynamic_cast<UnaryOpNode *>(arg->toStatic(static_datatree));
argtouse = dynamic_cast<UnaryOpNode *>(arg);
}
else
{
sarg = dynamic_cast<UnaryOpNode *>(this->toStatic(static_datatree));
argtouse = const_cast<UnaryOpNode *>(this);
}
if (sarg == NULL || nodes.find(sarg) == nodes.end())
{
expr_t argsubst = arg->substituteDiffUnaryOpNodes(static_datatree, nodes, subst_table, neweqs);
return buildSimilarUnaryOpNode(argsubst, datatree);
}
subst_table_t::const_iterator sit = subst_table.find(argtouse);
if (sit != subst_table.end())
return const_cast<VariableNode *>(sit->second);
VariableNode *vn = dynamic_cast<VariableNode *>(dynamic_cast<UnaryOpNode *>(argtouse)->get_arg());
int lag = vn->get_lag();
int symb_id = datatree.symbol_table.addUnaryOpInsideDiffAuxiliaryVar(argtouse->idx, argtouse,
vn->get_symb_id(), lag);
VariableNode *aux_var = datatree.AddVariable(symb_id, 0);
neweqs.push_back(dynamic_cast<BinaryOpNode *>(datatree.AddEqual(aux_var, argtouse)));
subst_table[argtouse] = dynamic_cast<VariableNode *>(aux_var);
if (op_code == oDiff)
return buildSimilarUnaryOpNode(aux_var, datatree);
return const_cast<VariableNode *>(aux_var);
}
expr_t
UnaryOpNode::substitutePacExpectation(map<const PacExpectationNode *, const BinaryOpNode *> &subst_table)
{
......@@ -4993,13 +4865,6 @@ BinaryOpNode::substituteAdl() const
return buildSimilarBinaryOpNode(arg1subst, arg2subst, datatree);
}
void
BinaryOpNode::findDiffUnaryOpNodes(DataTree &static_datatree, set<UnaryOpNode *> &unary_op_nodes_in_diff) const
{
arg1->findDiffUnaryOpNodes(static_datatree, unary_op_nodes_in_diff);
arg2->findDiffUnaryOpNodes(static_datatree, unary_op_nodes_in_diff);
}
void
BinaryOpNode::findDiffNodes(DataTree &static_datatree, diff_table_t &diff_table) const
{
......@@ -5016,14 +4881,6 @@ BinaryOpNode::substituteDiff(DataTree &static_datatree, diff_table_t &diff_table
return buildSimilarBinaryOpNode(arg1subst, arg2subst, datatree);
}
expr_t
BinaryOpNode::substituteDiffUnaryOpNodes(DataTree &static_datatree, set<UnaryOpNode *> &nodes, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const
{
expr_t arg1subst = arg1->substituteDiffUnaryOpNodes(static_datatree, nodes, subst_table, neweqs);
expr_t arg2subst = arg2->substituteDiffUnaryOpNodes(static_datatree, nodes, subst_table, neweqs);
return buildSimilarBinaryOpNode(arg1subst, arg2subst, datatree);
}
bool
BinaryOpNode::isDiffPresent() const
{
......@@ -5909,14 +5766,6 @@ TrinaryOpNode::findDiffNodes(DataTree &static_datatree, diff_table_t &diff_table
arg3->findDiffNodes(static_datatree, diff_table);
}
void
TrinaryOpNode::findDiffUnaryOpNodes(DataTree &static_datatree, set<UnaryOpNode *> &unary_op_nodes_in_diff) const
{
arg1->findDiffUnaryOpNodes(static_datatree, unary_op_nodes_in_diff);
arg2->findDiffUnaryOpNodes(static_datatree, unary_op_nodes_in_diff);
arg3->findDiffUnaryOpNodes(static_datatree, unary_op_nodes_in_diff);
}
expr_t
TrinaryOpNode::substituteDiff(DataTree &static_datatree, diff_table_t &diff_table, subst_table_t &subst_table,
vector<BinaryOpNode *> &neweqs) const
......@@ -5927,15 +5776,6 @@ TrinaryOpNode::substituteDiff(DataTree &static_datatree, diff_table_t &diff_tabl
return buildSimilarTrinaryOpNode(arg1subst, arg2subst, arg3subst, datatree);
}
expr_t
TrinaryOpNode::substituteDiffUnaryOpNodes(DataTree &static_datatree, set<UnaryOpNode *> &nodes, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const
{
expr_t arg1subst = arg1->substituteDiffUnaryOpNodes(static_datatree, nodes, subst_table, neweqs);
expr_t arg2subst = arg2->substituteDiffUnaryOpNodes(static_datatree, nodes, subst_table, neweqs);
expr_t arg3subst = arg3->substituteDiffUnaryOpNodes(static_datatree, nodes, subst_table, neweqs);
return buildSimilarTrinaryOpNode(arg1subst, arg2subst, arg3subst, datatree);
}
bool
TrinaryOpNode::isDiffPresent() const
{
......@@ -6349,13 +6189,6 @@ AbstractExternalFunctionNode::findDiffNodes(DataTree &static_datatree, diff_tabl
(*it)->findDiffNodes(static_datatree, diff_table);
}
void
AbstractExternalFunctionNode::findDiffUnaryOpNodes(DataTree &static_datatree, set<UnaryOpNode *> &unary_op_nodes_in_diff) const
{
for (vector<expr_t>::const_iterator it = arguments.begin(); it != arguments.end(); it++)
(*it)->findDiffUnaryOpNodes(static_datatree, unary_op_nodes_in_diff);
}
expr_t
AbstractExternalFunctionNode::substituteDiff(DataTree &static_datatree, diff_table_t &diff_table, subst_table_t &subst_table,
vector<BinaryOpNode *> &neweqs) const
......@@ -6366,15 +6199,6 @@ AbstractExternalFunctionNode::substituteDiff(DataTree &static_datatree, diff_tab
return buildSimilarExternalFunctionNode(arguments_subst, datatree);
}
expr_t
AbstractExternalFunctionNode::substituteDiffUnaryOpNodes(DataTree &static_datatree, set<UnaryOpNode *> &nodes, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const
{
vector<expr_t> arguments_subst;
for (vector<expr_t>::const_iterator it = arguments.begin(); it != arguments.end(); it++)
arguments_subst.push_back((*it)->substituteDiffUnaryOpNodes(static_datatree, nodes, subst_table, neweqs));
return buildSimilarExternalFunctionNode(arguments_subst, datatree);
}
bool
AbstractExternalFunctionNode::isDiffPresent() const
{
......@@ -7928,11 +7752,6 @@ VarExpectationNode::findDiffNodes(DataTree &static_datatree, diff_table_t &diff_
{
}
void
VarExpectationNode::findDiffUnaryOpNodes(DataTree &static_datatree, set<UnaryOpNode *> &unary_op_nodes_in_diff) const
{
}
expr_t
VarExpectationNode::substituteDiff(DataTree &static_datatree, diff_table_t &diff_table, subst_table_t &subst_table,
vector<BinaryOpNode *> &neweqs) const
......@@ -7940,12 +7759,6 @@ VarExpectationNode::substituteDiff(DataTree &static_datatree, diff_table_t &diff
return const_cast<VarExpectationNode *>(this);
}
expr_t
VarExpectationNode::substituteDiffUnaryOpNodes(DataTree &static_datatree, set<UnaryOpNode *> &nodes, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const
{
return const_cast<VarExpectationNode *>(this);
}
expr_t
VarExpectationNode::substitutePacExpectation(map<const PacExpectationNode *, const BinaryOpNode *> &subst_table)
{
......@@ -8373,11 +8186,6 @@ PacExpectationNode::findDiffNodes(DataTree &static_datatree, diff_table_t &diff_
{
}
void
PacExpectationNode::findDiffUnaryOpNodes(DataTree &static_datatree, set<UnaryOpNode *> &unary_op_nodes_in_diff) const
{
}
expr_t
PacExpectationNode::substituteDiff(DataTree &static_datatree, diff_table_t &diff_table, subst_table_t &subst_table,
vector<BinaryOpNode *> &neweqs) const
......@@ -8385,12 +8193,6 @@ PacExpectationNode::substituteDiff(DataTree &static_datatree, diff_table_t &diff
return const_cast<PacExpectationNode *>(this);
}
expr_t
PacExpectationNode::substituteDiffUnaryOpNodes(DataTree &static_datatree, set<UnaryOpNode *> &nodes, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const
{
return const_cast<PacExpectationNode *>(this);
}
expr_t
PacExpectationNode::differentiateForwardVars(const vector<string> &subset, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const
{
......
......@@ -492,9 +492,7 @@ class ExprNode
//! Substitute diff operator
virtual void findDiffNodes(DataTree &static_datatree, diff_table_t &diff_table) const = 0;
virtual void findDiffUnaryOpNodes(DataTree &static_datatree, set<UnaryOpNode *> &unary_op_nodes_in_diff) const = 0;
virtual expr_t substituteDiff(DataTree &static_datatree, diff_table_t &diff_table, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const = 0;
virtual expr_t substituteDiffUnaryOpNodes(DataTree &static_datatree, set<UnaryOpNode *> &nodes, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const = 0;
//! Substitute pac_expectation operator
virtual expr_t substitutePacExpectation(map<const PacExpectationNode *, const BinaryOpNode *> &subst_table) = 0;
......@@ -586,9 +584,7 @@ public:
virtual expr_t substituteExpectation(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs, bool partial_information_model) const;
virtual expr_t substituteAdl() const;
virtual void findDiffNodes(DataTree &static_datatree, diff_table_t &diff_table) const;
virtual void findDiffUnaryOpNodes(DataTree &static_datatree, set<UnaryOpNode *> &unary_op_nodes_in_diff) const;
virtual expr_t substituteDiff(DataTree &static_datatree, diff_table_t &diff_table, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
virtual expr_t substituteDiffUnaryOpNodes(DataTree &static_datatree, set<UnaryOpNode *> &nodes, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
virtual expr_t substitutePacExpectation(map<const PacExpectationNode *, const BinaryOpNode *> &subst_table);
virtual expr_t decreaseLeadsLagsPredeterminedVariables() const;
virtual expr_t differentiateForwardVars(const vector<string> &subset, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
......@@ -676,9 +672,7 @@ public:
virtual expr_t substituteExpectation(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs, bool partial_information_model) const;
virtual expr_t substituteAdl() const;
virtual void findDiffNodes(DataTree &static_datatree, diff_table_t &diff_table) const;
virtual void findDiffUnaryOpNodes(DataTree &static_datatree, set<UnaryOpNode *> &unary_op_nodes_in_diff) const;
virtual expr_t substituteDiff(DataTree &static_datatree, diff_table_t &diff_table, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
virtual expr_t substituteDiffUnaryOpNodes(DataTree &static_datatree, set<UnaryOpNode *> &nodes, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
virtual expr_t substitutePacExpectation(map<const PacExpectationNode *, const BinaryOpNode *> &subst_table);
virtual expr_t decreaseLeadsLagsPredeterminedVariables() const;
virtual expr_t differentiateForwardVars(const vector<string> &subset, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
......@@ -788,11 +782,8 @@ public:
virtual expr_t substituteExpectation(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs, bool partial_information_model) const;
virtual expr_t substituteAdl() const;
virtual void findDiffNodes(DataTree &static_datatree, diff_table_t &diff_table) const;
bool createAuxVarForUnaryOpNodeInDiffOp() const;
virtual void findDiffUnaryOpNodes(DataTree &static_datatree, set<UnaryOpNode *> &unary_op_nodes_in_diff) const;
void getDiffArgUnaryOperatorIfAny(string &op_handle) const;
virtual expr_t substituteDiff(DataTree &static_datatree, diff_table_t &diff_table, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
virtual expr_t substituteDiffUnaryOpNodes(DataTree &static_datatree, set<UnaryOpNode *> &nodes, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
virtual expr_t substitutePacExpectation(map<const PacExpectationNode *, const BinaryOpNode *> &subst_table);
virtual expr_t decreaseLeadsLagsPredeterminedVariables() const;
virtual expr_t differentiateForwardVars(const vector<string> &subset, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
......@@ -919,9 +910,7 @@ public:
virtual expr_t substituteExpectation(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs, bool partial_information_model) const;
virtual expr_t substituteAdl() const;
virtual void findDiffNodes(DataTree &static_datatree, diff_table_t &diff_table) const;
virtual void findDiffUnaryOpNodes(DataTree &static_datatree, set<UnaryOpNode *> &unary_op_nodes_in_diff) const;
virtual expr_t substituteDiff(DataTree &static_datatree, diff_table_t &diff_table, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
virtual expr_t substituteDiffUnaryOpNodes(DataTree &static_datatree, set<UnaryOpNode *> &nodes, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
virtual expr_t substitutePacExpectation(map<const PacExpectationNode *, const BinaryOpNode *> &subst_table);
virtual expr_t decreaseLeadsLagsPredeterminedVariables() const;
virtual expr_t differentiateForwardVars(const vector<string> &subset, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
......@@ -1024,9 +1013,7 @@ public:
virtual expr_t substituteExpectation(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs, bool partial_information_model) const;
virtual expr_t substituteAdl() const;
virtual void findDiffNodes(DataTree &static_datatree, diff_table_t &diff_table) const;
virtual void findDiffUnaryOpNodes(DataTree &static_datatree, set<UnaryOpNode *> &unary_op_nodes_in_diff) const;
virtual expr_t substituteDiff(DataTree &static_datatree, diff_table_t &diff_table, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
virtual expr_t substituteDiffUnaryOpNodes(DataTree &static_datatree, set<UnaryOpNode *> &nodes, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
virtual expr_t substitutePacExpectation(map<const PacExpectationNode *, const BinaryOpNode *> &subst_table);
virtual expr_t decreaseLeadsLagsPredeterminedVariables() const;
virtual expr_t differentiateForwardVars(const vector<string> &subset, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
......@@ -1129,9 +1116,7 @@ public:
virtual expr_t substituteExpectation(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs, bool partial_information_model) const;
virtual expr_t substituteAdl() const;
virtual void findDiffNodes(DataTree &static_datatree, diff_table_t &diff_table) const;
virtual void findDiffUnaryOpNodes(DataTree &static_datatree, set<UnaryOpNode *> &unary_op_nodes_in_diff) const;
virtual expr_t substituteDiff(DataTree &static_datatree, diff_table_t &diff_table, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
virtual expr_t substituteDiffUnaryOpNodes(DataTree &static_datatree, set<UnaryOpNode *> &nodes, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
virtual expr_t substitutePacExpectation(map<const PacExpectationNode *, const BinaryOpNode *> &subst_table);
virtual expr_t buildSimilarExternalFunctionNode(vector<expr_t> &alt_args, DataTree &alt_datatree) const = 0;
virtual expr_t decreaseLeadsLagsPredeterminedVariables() const;
......@@ -1324,9 +1309,7 @@ public:
virtual expr_t substituteExpectation(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs, bool partial_information_model) const;
virtual expr_t substituteAdl() const;
virtual void findDiffNodes(DataTree &static_datatree, diff_table_t &diff_table) const;
virtual void findDiffUnaryOpNodes(DataTree &static_datatree, set<UnaryOpNode *> &unary_op_nodes_in_diff) const;
virtual expr_t substituteDiff(DataTree &static_datatree, diff_table_t &diff_table, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
virtual expr_t substituteDiffUnaryOpNodes(DataTree &static_datatree, set<UnaryOpNode *> &nodes, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
virtual expr_t substitutePacExpectation(map<const PacExpectationNode *, const BinaryOpNode *> &subst_table);
virtual pair<int, expr_t> normalizeEquation(int symb_id_endo, vector<pair<int, pair<expr_t, expr_t> > > &List_of_Op_RHS) const;
virtual void compile(ostream &CompileCode, unsigned int &instruction_number,
......@@ -1409,9 +1392,7 @@ public:
virtual expr_t substituteExpectation(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs, bool partial_information_model) const;
virtual expr_t substituteAdl() const;
virtual void findDiffNodes(DataTree &static_datatree, diff_table_t &diff_table) const;
virtual void findDiffUnaryOpNodes(DataTree &static_datatree, set<UnaryOpNode *> &unary_op_nodes_in_diff) const;
virtual expr_t substituteDiff(DataTree &static_datatree, diff_table_t &diff_table, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
virtual expr_t substituteDiffUnaryOpNodes(DataTree &static_datatree, set<UnaryOpNode *> &nodes, subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
virtual expr_t substitutePacExpectation(map<const PacExpectationNode *, const BinaryOpNode *> &subst_table);
virtual pair<int, expr_t> normalizeEquation(int symb_id_endo, vector<pair<int, pair<expr_t, expr_t> > > &List_of_Op_RHS) const;
virtual void compile(ostream &CompileCode, unsigned int &instruction_number,
......
......@@ -368,7 +368,6 @@ ModFile::transformPass(bool nostrict, bool stochastic, bool compute_xrefs, const
// Create auxiliary variable and equations for Diff operator
ExprNode::subst_table_t diff_subst_table;
dynamic_model.substituteDiffUnaryOps(diff_static_model);
dynamic_model.substituteDiff(diff_static_model, diff_subst_table);
// Var Model
......
......@@ -391,7 +391,6 @@ SymbolTable::writeOutput(ostream &output) const throw (NotYetFrozenException)
break;
case avDiff:
case avDiffLag:
case avUnaryOpInsideDiff:
if (aux_vars[i].get_orig_symb_id() >= 0)
output << "M_.aux_vars(" << i+1 << ").orig_index = " << getTypeSpecificID(aux_vars[i].get_orig_symb_id())+1 << ";" << endl
<< "M_.aux_vars(" << i+1 << ").orig_lead_lag = " << aux_vars[i].get_orig_lead_lag() << ";" << endl;
......@@ -512,7 +511,6 @@ SymbolTable::writeCOutput(ostream &output) const throw (NotYetFrozenException)
break;
case avDiff:
case avDiffLag:
case avUnaryOpInsideDiff:
if (aux_vars[i].get_orig_symb_id() >= 0)
output << "av[" << i << "].orig_index = " << getTypeSpecificID(aux_vars[i].get_orig_symb_id()) << ";" << endl
<< "av[" << i << "].orig_lead_lag = " << aux_vars[i].get_orig_lead_lag() << ";" << endl;
......@@ -612,7 +610,6 @@ SymbolTable::writeCCOutput(ostream &output) const throw (NotYetFrozenException)
break;
case avDiff:
case avDiffLag:
case avUnaryOpInsideDiff:
if (aux_vars[i].get_orig_symb_id() >= 0)
output << "av" << i << ".orig_index = " << getTypeSpecificID(aux_vars[i].get_orig_symb_id()) << ";" << endl
<< "av" << i << ".orig_lead_lag = " << aux_vars[i].get_orig_lead_lag() << ";" << endl;
......@@ -808,28 +805,6 @@ SymbolTable::addDiffAuxiliaryVar(int index, expr_t expr_arg) throw (FrozenExcept
return addDiffAuxiliaryVar(index, expr_arg, -1, 0);
}
int
SymbolTable::addUnaryOpInsideDiffAuxiliaryVar(int index, expr_t expr_arg, int orig_symb_id, int orig_lag) throw (FrozenException)
{
ostringstream varname;
int symb_id;
varname << "AUX_UOP_IN_DIFF_" << index;
try
{
symb_id = addSymbol(varname.str(), eEndogenous);
}
catch (AlreadyDeclaredException &e)
{
cerr << "ERROR: you should rename your variable called " << varname.str() << ", this name is internally used by Dynare" << endl;
exit(EXIT_FAILURE);
}
aux_vars.push_back(AuxVarInfo(symb_id, avUnaryOpInsideDiff, orig_symb_id, orig_lag, 0, 0, expr_arg));
return symb_id;
}
int
SymbolTable::addVarModelEndoLagAuxiliaryVar(int orig_symb_id, int orig_lead_lag, expr_t expr_arg) throw (AlreadyDeclaredException, FrozenException)
{
......@@ -1163,7 +1138,6 @@ SymbolTable::writeJuliaOutput(ostream &output) const throw (NotYetFrozenExceptio
break;
case avDiff:
case avDiffLag:
case avUnaryOpInsideDiff:
if (aux_vars[i].get_orig_symb_id() >= 0)
output << getTypeSpecificID(aux_vars[i].get_orig_symb_id()) + 1 << ", "
<< aux_vars[i].get_orig_lead_lag() << ", NaN, NaN," << aux_vars[i].get_unary_op_handle();
......
......@@ -36,17 +36,16 @@ typedef class ExprNode *expr_t;
//! Types of auxiliary variables
enum aux_var_t
{
avEndoLead = 0, //!< Substitute for endo leads >= 2
avEndoLag = 1, //!< Substitute for endo lags >= 2
avExoLead = 2, //!< Substitute for exo leads >= 1
avExoLag = 3, //!< Substitute for exo lags >= 1
avExpectation = 4, //!< Substitute for Expectation Operator
avDiffForward = 5, //!< Substitute for the differentiate of a forward variable
avMultiplier = 6, //!< Multipliers for FOC of Ramsey Problem
avVarModel = 7, //!< Variable for var_model with order > abs(min_lag()) present in model
avDiff = 8, //!< Variable for Diff operator
avDiffLag = 9, //!< Variable for timing between Diff operators
avUnaryOpInsideDiff = 10 //!< Variable for allowing the undiff operator to work when diff was taken of unary op, eg diff(log(x))
avEndoLead = 0, //!< Substitute for endo leads >= 2
avEndoLag = 1, //!< Substitute for endo lags >= 2
avExoLead = 2, //!< Substitute for exo leads >= 1
avExoLag = 3, //!< Substitute for exo lags >= 1
avExpectation = 4, //!< Substitute for Expectation Operator
avDiffForward = 5, //!< Substitute for the differentiate of a forward variable
avMultiplier = 6, //!< Multipliers for FOC of Ramsey Problem
avVarModel = 7, //!< Variable for var_model with order > abs(min_lag()) present in model
avDiff = 8, //!< Variable for Diff operator
avDiffLag = 9 //!< Variable for timing between Diff operators
};
//! Information on some auxiliary variables
......@@ -301,8 +300,6 @@ public:
int addDiffAuxiliaryVar(int index, expr_t expr_arg, int orig_symb_id, int orig_lag, string &unary_op_handle) throw (FrozenException);
//! Takes care of timing between diff statements
int addDiffLagAuxiliaryVar(int index, expr_t expr_arg, int orig_symb_id, int orig_lag) throw (FrozenException);
//! An Auxiliary variable for a unary op that was substituted because it was inside a diff node
int addUnaryOpInsideDiffAuxiliaryVar(int index, expr_t expr_arg, int orig_symb_id, int orig_lag) throw (FrozenException);
//! Returns the number of auxiliary variables
int
AuxVarsSize() const
......
Supports Markdown
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