From: Kshitij Bansal Date: Thu, 6 Dec 2012 21:31:56 +0000 (-0500) Subject: Fix performance issue in a DFS search (bug 474) X-Git-Tag: cvc5-1.0.0~7391^2~40 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=bd28a94095d8aebe4eb70fedcbe0f511edd38b0b;p=cvc5.git Fix performance issue in a DFS search (bug 474) (cherry picked from commit f056522a587d1b080224992355be070b73d97a3b) --- diff --git a/src/decision/justification_heuristic.cpp b/src/decision/justification_heuristic.cpp index ba8ab91b7..4ec4588f3 100644 --- a/src/decision/justification_heuristic.cpp +++ b/src/decision/justification_heuristic.cpp @@ -70,13 +70,17 @@ SatValue JustificationHeuristic::tryGetSatValue(Node n) void JustificationHeuristic::computeITEs(TNode n, IteList &l) { Trace("jh-ite") << " computeITEs( " << n << ", &l)\n"; + d_visitedComputeITE.insert(n); for(unsigned i=0; isecond)); Assert(n[i].getNumChildren() == 0); } - computeITEs(n[i], l); + if(d_visitedComputeITE.find(n[i]) == + d_visitedComputeITE.end()) { + computeITEs(n[i], l); + } } } @@ -89,6 +93,7 @@ const JustificationHeuristic::IteList& JustificationHeuristic::getITEs(TNode n) // Compute the list of ITEs // TODO: optimize by avoiding multiple lookup for d_iteCache[n] d_iteCache[n] = IteList(); + d_visitedComputeITE.clear(); computeITEs(n, d_iteCache[n]); return d_iteCache[n]; } diff --git a/src/decision/justification_heuristic.h b/src/decision/justification_heuristic.h index a3b05b1bb..de6bf5095 100644 --- a/src/decision/justification_heuristic.h +++ b/src/decision/justification_heuristic.h @@ -76,6 +76,12 @@ class JustificationHeuristic : public ITEDecisionStrategy { * term-ITE. */ hash_set d_visited; + + /** + * Set to track visited nodes in a dfs search done in computeITE + * function + */ + hash_set d_visitedComputeITE; public: JustificationHeuristic(CVC4::DecisionEngine* de, context::Context *c): ITEDecisionStrategy(de, c),