From bd28a94095d8aebe4eb70fedcbe0f511edd38b0b Mon Sep 17 00:00:00 2001 From: Kshitij Bansal Date: Thu, 6 Dec 2012 16:31:56 -0500 Subject: [PATCH] Fix performance issue in a DFS search (bug 474) (cherry picked from commit f056522a587d1b080224992355be070b73d97a3b) --- src/decision/justification_heuristic.cpp | 7 ++++++- src/decision/justification_heuristic.h | 6 ++++++ 2 files changed, 12 insertions(+), 1 deletion(-) 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), -- 2.30.2