From 522de968d07688702d07462a473b09c3dd0e8b96 Mon Sep 17 00:00:00 2001 From: sebastien Date: Fri, 2 Oct 2009 17:02:35 +0000 Subject: [PATCH] preprocessor: reverted useless changes from last commit git-svn-id: https://www.dynare.org/svn/dynare/trunk@3016 ac1d8469-bf42-47a9-8791-bf33cf982152 --- preprocessor/DynamicModel.cc | 4 ---- preprocessor/ExprNode.cc | 22 +++++----------------- preprocessor/ExprNode.hh | 2 +- preprocessor/ModelTree.cc | 4 +--- preprocessor/StaticModel.cc | 6 ++---- 5 files changed, 9 insertions(+), 29 deletions(-) diff --git a/preprocessor/DynamicModel.cc b/preprocessor/DynamicModel.cc index 4727a1e58..1451f7a9e 100644 --- a/preprocessor/DynamicModel.cc +++ b/preprocessor/DynamicModel.cc @@ -2424,16 +2424,12 @@ DynamicModel::toStaticDll(StaticDllModel &static_model) const // Convert model local variables (need to be done first) for (map::const_iterator it = local_variables_table.begin(); it != local_variables_table.end(); it++) - { static_model.AddLocalVariable(symbol_table.getName(it->first), it->second->toStatic(static_model)); - } // Convert equations for (vector::const_iterator it = equations.begin(); it != equations.end(); it++) - { static_model.addEquation((*it)->toStatic(static_model)); - } } void diff --git a/preprocessor/ExprNode.cc b/preprocessor/ExprNode.cc index 7226eac60..87f4bc390 100644 --- a/preprocessor/ExprNode.cc +++ b/preprocessor/ExprNode.cc @@ -52,10 +52,12 @@ ExprNode::getDerivative(int deriv_id) { if (!preparedForDerivation) prepareForDerivation(); + // Return zero if derivative is necessarily null (using symbolic a priori) set::const_iterator it = non_null_derivatives.find(deriv_id); if (it == non_null_derivatives.end()) return datatree.Zero; + // If derivative is stored in cache, use the cached value, otherwise compute it (and cache it) map::const_iterator it2 = derivatives.find(deriv_id); if (it2 != derivatives.end()) @@ -306,7 +308,7 @@ VariableNode::prepareForDerivation() { if (preparedForDerivation) return; - int der_id; + preparedForDerivation = true; // Fill in non_null_derivatives @@ -317,25 +319,12 @@ VariableNode::prepareForDerivation() case eExogenousDet: case eParameter: // For a variable or a parameter, the only non-null derivative is with respect to itself - //non_null_derivatives.insert(datatree.getDerivID(symb_id, lag)); - der_id = datatree.getDerivID(symb_id, lag); - non_null_derivatives = set(&der_id, &der_id+1); + non_null_derivatives.insert(datatree.getDerivID(symb_id, lag)); break; case eModelLocalVariable: datatree.local_variables_table[symb_id]->prepareForDerivation(); // Non null derivatives are those of the value of the local parameter non_null_derivatives = datatree.local_variables_table[symb_id]->non_null_derivatives; - /*for(set::const_iterator it=datatree.local_variables_table[symb_id]->non_null_derivatives.begin(); it != datatree.local_variables_table[symb_id]->non_null_derivatives.end(); it++) - non_null_derivatives.insert(*it);*/ - //cout << "symb_id=" << symb_id << " " << datatree.symbol_table.getName(symb_id) << " " << datatree.symbol_table.maxID(); - //non_null_derivatives = datatree.local_variables_table[symb_id]->non_null_derivatives; - /*cout << " non_null_derivatives.size()= " << non_null_derivatives.size() << endl; - if(non_null_derivatives.size()>0) - for(set::const_iterator it=non_null_derivatives.begin(); it != non_null_derivatives.end(); it++) - { - cout << "symb_id=" << symb_id << " *it = " << *it << "\n" ; - //cout << datatree.symbol_table.getName(staticdllmodel.getSymbIDByDerivID(*it)) << "(" << staticdllmodel.getLagByDerivID(*it) << ")\n"; - }*/ break; case eModFileLocalVariable: // Such a variable is never derived @@ -360,7 +349,6 @@ VariableNode::computeDerivative(int deriv_id) else return datatree.Zero; case eModelLocalVariable: - //datatree.local_variables_table[symb_id]->writeOutput(cout); return datatree.local_variables_table[symb_id]->getDerivative(deriv_id); case eModFileLocalVariable: cerr << "ModFileLocalVariable is not derivable" << endl; @@ -640,7 +628,7 @@ VariableNode::compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_ break; case eModelLocalVariable: case eModFileLocalVariable: - //cout << "eModelLocalVariable=" << tsid << "lhs_rhs=" << lhs_rhs << "\n"; + //cout << "eModelLocalVariable=" << symb_id << "\n"; datatree.local_variables_table[symb_id]->compile(CompileCode, lhs_rhs, temporary_terms, map_idx, dynamic, steady_dynamic); break; case eUnknownFunction: diff --git a/preprocessor/ExprNode.hh b/preprocessor/ExprNode.hh index 903e5a875..08bafae8c 100644 --- a/preprocessor/ExprNode.hh +++ b/preprocessor/ExprNode.hh @@ -241,7 +241,7 @@ public: typedef map subst_table_t; //! Creates auxiliary lead variables corresponding to this expression - /*! + /*! If maximum endogenous lead >= 3, this method will also create intermediary auxiliary var, and will add the equations of the form aux1 = aux2(+1) to the substitution table. \pre This expression is assumed to have maximum endogenous lead >= 2 \param[in,out] subst_table The table to which new auxiliary variables and their correspondance will be added diff --git a/preprocessor/ModelTree.cc b/preprocessor/ModelTree.cc index eecfc3d74..ac19cc4ca 100644 --- a/preprocessor/ModelTree.cc +++ b/preprocessor/ModelTree.cc @@ -53,15 +53,13 @@ ModelTree::writeDerivative(ostream &output, int eq, int symb_id, int lag, void ModelTree::computeJacobian(const set &vars) { - int i = 0; for(set::const_iterator it = vars.begin(); - it != vars.end(); it++, i++) + it != vars.end(); it++) for (int eq = 0; eq < (int) equations.size(); eq++) { NodeID d1 = equations[eq]->getDerivative(*it); if (d1 == Zero) continue; - //printf("eq=%4d var=%4d i=%4d\n",eq,*it,i); first_derivatives[make_pair(eq, *it)] = d1; ++NNZDerivatives[0]; } diff --git a/preprocessor/StaticModel.cc b/preprocessor/StaticModel.cc index 15981f621..d848b7390 100644 --- a/preprocessor/StaticModel.cc +++ b/preprocessor/StaticModel.cc @@ -250,8 +250,6 @@ StaticModel::computeNormalization() #if 1 bool check = checked_edmonds_maximum_cardinality_matching(g, &mate_map[0]); - for (int i = 0; i < n; i++) - printf("match equation %4d with variable %4d \n", mate_map[i] - n, i); #else // Alternative way to compute normalization, by giving an initial matching using natural normalizations fill(mate_map.begin(), mate_map.end(), graph_traits::null_vertex()); @@ -406,11 +404,11 @@ StaticModel::computeSortedBlockDecomposition() for(int i = 0; i < n; i++) blocks[unordered2ordered[endo2block[i]]].insert(i); -//#ifdef DEBUG +#ifdef DEBUG cout << "Found " << m << " blocks" << endl; for(int i = 0; i < m; i++) cout << " Block " << i << " of size " << blocks[i].size() << endl; -//#endif +#endif } void