preprocessor: reverted useless changes from last commit

git-svn-id: https://www.dynare.org/svn/dynare/trunk@3016 ac1d8469-bf42-47a9-8791-bf33cf982152
time-shift
sebastien 2009-10-02 17:02:35 +00:00
parent ece194b602
commit 522de968d0
5 changed files with 9 additions and 29 deletions

View File

@ -2424,16 +2424,12 @@ DynamicModel::toStaticDll(StaticDllModel &static_model) const
// Convert model local variables (need to be done first) // Convert model local variables (need to be done first)
for (map<int, NodeID>::const_iterator it = local_variables_table.begin(); for (map<int, NodeID>::const_iterator it = local_variables_table.begin();
it != local_variables_table.end(); it++) it != local_variables_table.end(); it++)
{
static_model.AddLocalVariable(symbol_table.getName(it->first), it->second->toStatic(static_model)); static_model.AddLocalVariable(symbol_table.getName(it->first), it->second->toStatic(static_model));
}
// Convert equations // Convert equations
for (vector<BinaryOpNode *>::const_iterator it = equations.begin(); for (vector<BinaryOpNode *>::const_iterator it = equations.begin();
it != equations.end(); it++) it != equations.end(); it++)
{
static_model.addEquation((*it)->toStatic(static_model)); static_model.addEquation((*it)->toStatic(static_model));
}
} }
void void

View File

@ -52,10 +52,12 @@ ExprNode::getDerivative(int deriv_id)
{ {
if (!preparedForDerivation) if (!preparedForDerivation)
prepareForDerivation(); prepareForDerivation();
// Return zero if derivative is necessarily null (using symbolic a priori) // Return zero if derivative is necessarily null (using symbolic a priori)
set<int>::const_iterator it = non_null_derivatives.find(deriv_id); set<int>::const_iterator it = non_null_derivatives.find(deriv_id);
if (it == non_null_derivatives.end()) if (it == non_null_derivatives.end())
return datatree.Zero; return datatree.Zero;
// If derivative is stored in cache, use the cached value, otherwise compute it (and cache it) // If derivative is stored in cache, use the cached value, otherwise compute it (and cache it)
map<int, NodeID>::const_iterator it2 = derivatives.find(deriv_id); map<int, NodeID>::const_iterator it2 = derivatives.find(deriv_id);
if (it2 != derivatives.end()) if (it2 != derivatives.end())
@ -306,7 +308,7 @@ VariableNode::prepareForDerivation()
{ {
if (preparedForDerivation) if (preparedForDerivation)
return; return;
int der_id;
preparedForDerivation = true; preparedForDerivation = true;
// Fill in non_null_derivatives // Fill in non_null_derivatives
@ -317,25 +319,12 @@ VariableNode::prepareForDerivation()
case eExogenousDet: case eExogenousDet:
case eParameter: case eParameter:
// For a variable or a parameter, the only non-null derivative is with respect to itself // 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)); non_null_derivatives.insert(datatree.getDerivID(symb_id, lag));
der_id = datatree.getDerivID(symb_id, lag);
non_null_derivatives = set<int>(&der_id, &der_id+1);
break; break;
case eModelLocalVariable: case eModelLocalVariable:
datatree.local_variables_table[symb_id]->prepareForDerivation(); datatree.local_variables_table[symb_id]->prepareForDerivation();
// Non null derivatives are those of the value of the local parameter // Non null derivatives are those of the value of the local parameter
non_null_derivatives = datatree.local_variables_table[symb_id]->non_null_derivatives; non_null_derivatives = datatree.local_variables_table[symb_id]->non_null_derivatives;
/*for(set<int>::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<int>::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; break;
case eModFileLocalVariable: case eModFileLocalVariable:
// Such a variable is never derived // Such a variable is never derived
@ -360,7 +349,6 @@ VariableNode::computeDerivative(int deriv_id)
else else
return datatree.Zero; return datatree.Zero;
case eModelLocalVariable: case eModelLocalVariable:
//datatree.local_variables_table[symb_id]->writeOutput(cout);
return datatree.local_variables_table[symb_id]->getDerivative(deriv_id); return datatree.local_variables_table[symb_id]->getDerivative(deriv_id);
case eModFileLocalVariable: case eModFileLocalVariable:
cerr << "ModFileLocalVariable is not derivable" << endl; cerr << "ModFileLocalVariable is not derivable" << endl;
@ -640,7 +628,7 @@ VariableNode::compile(ostream &CompileCode, bool lhs_rhs, const temporary_terms_
break; break;
case eModelLocalVariable: case eModelLocalVariable:
case eModFileLocalVariable: 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); datatree.local_variables_table[symb_id]->compile(CompileCode, lhs_rhs, temporary_terms, map_idx, dynamic, steady_dynamic);
break; break;
case eUnknownFunction: case eUnknownFunction:

View File

@ -241,7 +241,7 @@ public:
typedef map<const ExprNode *, const VariableNode *> subst_table_t; typedef map<const ExprNode *, const VariableNode *> subst_table_t;
//! Creates auxiliary lead variables corresponding to this expression //! 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. 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 \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 \param[in,out] subst_table The table to which new auxiliary variables and their correspondance will be added

View File

@ -53,15 +53,13 @@ ModelTree::writeDerivative(ostream &output, int eq, int symb_id, int lag,
void void
ModelTree::computeJacobian(const set<int> &vars) ModelTree::computeJacobian(const set<int> &vars)
{ {
int i = 0;
for(set<int>::const_iterator it = vars.begin(); for(set<int>::const_iterator it = vars.begin();
it != vars.end(); it++, i++) it != vars.end(); it++)
for (int eq = 0; eq < (int) equations.size(); eq++) for (int eq = 0; eq < (int) equations.size(); eq++)
{ {
NodeID d1 = equations[eq]->getDerivative(*it); NodeID d1 = equations[eq]->getDerivative(*it);
if (d1 == Zero) if (d1 == Zero)
continue; continue;
//printf("eq=%4d var=%4d i=%4d\n",eq,*it,i);
first_derivatives[make_pair(eq, *it)] = d1; first_derivatives[make_pair(eq, *it)] = d1;
++NNZDerivatives[0]; ++NNZDerivatives[0];
} }

View File

@ -250,8 +250,6 @@ StaticModel::computeNormalization()
#if 1 #if 1
bool check = checked_edmonds_maximum_cardinality_matching(g, &mate_map[0]); 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 #else // Alternative way to compute normalization, by giving an initial matching using natural normalizations
fill(mate_map.begin(), mate_map.end(), graph_traits<BipartiteGraph>::null_vertex()); fill(mate_map.begin(), mate_map.end(), graph_traits<BipartiteGraph>::null_vertex());
@ -406,11 +404,11 @@ StaticModel::computeSortedBlockDecomposition()
for(int i = 0; i < n; i++) for(int i = 0; i < n; i++)
blocks[unordered2ordered[endo2block[i]]].insert(i); blocks[unordered2ordered[endo2block[i]]].insert(i);
//#ifdef DEBUG #ifdef DEBUG
cout << "Found " << m << " blocks" << endl; cout << "Found " << m << " blocks" << endl;
for(int i = 0; i < m; i++) for(int i = 0; i < m; i++)
cout << " Block " << i << " of size " << blocks[i].size() << endl; cout << " Block " << i << " of size " << blocks[i].size() << endl;
//#endif #endif
} }
void void