Commit b7652646 authored by houtanb's avatar houtanb
Browse files

fixes global oo_ declaration for steady state operator as discussed on 14 Sep

git-svn-id: https://www.dynare.org/svn/dynare/trunk@3020 ac1d8469-bf42-47a9-8791-bf33cf982152
parent 343e0b3c
...@@ -39,6 +39,8 @@ DataTree::DataTree(SymbolTable &symbol_table_arg, NumericalConstants &num_consta ...@@ -39,6 +39,8 @@ DataTree::DataTree(SymbolTable &symbol_table_arg, NumericalConstants &num_consta
MinusInfinity = AddUMinus(Infinity); MinusInfinity = AddUMinus(Infinity);
Pi = AddNumConstant("3.141592653589793"); Pi = AddNumConstant("3.141592653589793");
steady_state_found = false;
} }
DataTree::~DataTree() DataTree::~DataTree()
...@@ -416,6 +418,7 @@ DataTree::AddNormcdf(NodeID iArg1, NodeID iArg2, NodeID iArg3) ...@@ -416,6 +418,7 @@ DataTree::AddNormcdf(NodeID iArg1, NodeID iArg2, NodeID iArg3)
NodeID NodeID
DataTree::AddSteadyState(NodeID iArg1) DataTree::AddSteadyState(NodeID iArg1)
{ {
steady_state_found = true;
return AddUnaryOp(oSteadyState, iArg1); return AddUnaryOp(oSteadyState, iArg1);
} }
......
...@@ -64,6 +64,9 @@ protected: ...@@ -64,6 +64,9 @@ protected:
//! Stores local variables value (maps symbol ID to corresponding node) //! Stores local variables value (maps symbol ID to corresponding node)
map<int, NodeID> local_variables_table; map<int, NodeID> local_variables_table;
//! true when oSteadyState is encountered in a dynamic model
bool steady_state_found;
//! Internal implementation of AddVariable(), without the check on the lag //! Internal implementation of AddVariable(), without the check on the lag
VariableNode *AddVariableInternal(int symb_id, int lag); VariableNode *AddVariableInternal(int symb_id, int lag);
...@@ -175,6 +178,8 @@ public: ...@@ -175,6 +178,8 @@ public:
//! Checks if a given symbol is used somewhere in the data tree //! Checks if a given symbol is used somewhere in the data tree
bool isSymbolUsed(int symb_id) const; bool isSymbolUsed(int symb_id) const;
//! Thrown when trying to access an unknown variable by deriv_id //! Thrown when trying to access an unknown variable by deriv_id
bool containsSteadyStateOperator() const { return steady_state_found; };
//! Thrown when trying to access an unknown variable by deriv_id
class UnknownDerivIDException class UnknownDerivIDException
{ {
}; };
...@@ -183,7 +188,7 @@ public: ...@@ -183,7 +188,7 @@ public:
virtual int getDerivID(int symb_id, int lag) const throw (UnknownDerivIDException); virtual int getDerivID(int symb_id, int lag) const throw (UnknownDerivIDException);
//! Returns the column of the dynamic Jacobian associated to a derivation ID //! Returns the column of the dynamic Jacobian associated to a derivation ID
virtual int getDynJacobianCol(int deriv_id) const throw (UnknownDerivIDException); virtual int getDynJacobianCol(int deriv_id) const throw (UnknownDerivIDException);
//! Returns bool indicating whether DataTree represents a Dynamic Model (returns true in DynamicModel.hh) //! Returns bool indicating whether DataTree represents a Dynamic Model (returns true in DynamicModel.hh)
virtual bool isDynamic() const { return false; }; virtual bool isDynamic() const { return false; };
}; };
......
...@@ -1129,6 +1129,9 @@ DynamicModel::writeDynamicMFile(const string &dynamic_basename) const ...@@ -1129,6 +1129,9 @@ DynamicModel::writeDynamicMFile(const string &dynamic_basename) const
<< "% Warning : this file is generated automatically by Dynare" << endl << "% Warning : this file is generated automatically by Dynare" << endl
<< "% from model file (.mod)" << endl << endl; << "% from model file (.mod)" << endl << endl;
if (containsSteadyStateOperator())
mDynamicModelFile << "global oo_;" << endl << endl;
writeDynamicModel(mDynamicModelFile, false); writeDynamicModel(mDynamicModelFile, false);
mDynamicModelFile.close(); mDynamicModelFile.close();
......
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