[Aptitude-devel] r2945 - in branches/aptitude-0.3/aptitude: . src/generic/problemresolver

Daniel Burrows dburrows@costa.debian.org
Fri, 08 Apr 2005 02:04:13 +0000


Author: dburrows
Date: Fri Apr  8 02:04:08 2005
New Revision: 2945

Modified:
   branches/aptitude-0.3/aptitude/ChangeLog
   branches/aptitude-0.3/aptitude/src/generic/problemresolver/problemresolver.h
Log:
Viva la debugging code

Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog	(original)
+++ branches/aptitude-0.3/aptitude/ChangeLog	Fri Apr  8 02:04:08 2005
@@ -1,5 +1,9 @@
 2005-04-07  Daniel Burrows  <dburrows@debian.org>
 
+	* src/generic/problemresolver/test.cc:
+
+	  Add more debugging code; make dump() dump all info by default.
+
 	* src/generic/problemresolver/problemresolver.h, src/generic/problemresolver/test.cc:
 
 	  Make the broken dependency list a unique set (ow, big runtime

Modified: branches/aptitude-0.3/aptitude/src/generic/problemresolver/problemresolver.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/generic/problemresolver/problemresolver.h	(original)
+++ branches/aptitude-0.3/aptitude/src/generic/problemresolver/problemresolver.h	Fri Apr  8 02:04:08 2005
@@ -184,9 +184,6 @@
       /** The full list of currently broken dependencies. */
       std::set<dep> broken_deps;
 
-      /** The reference count of this solution. */
-      mutable unsigned int refcount;
-
       /** The score of this solution. */
       int score;
 
@@ -196,6 +193,9 @@
        */
       int action_score;
 
+      /** The reference count of this solution. */
+      mutable unsigned int refcount;
+
       public:
       void incref() const {++refcount;}
       void decref() const {assert(refcount>0); if(--refcount==0) delete this;}
@@ -205,14 +205,17 @@
        *
        *  \param ver the version to install beyond what is in the parent
        *  \param parent the parent solution
+       *  \param _broken_deps the dependencies that are broken in this partial solution
        *  \param _score the score of this solution
        *  \param _action_score the score not due to broken deps
        */
       solution_rep(const action &the_action,
 		   const solution &parent,
+		   const std::set<dep> &_broken_deps,
 		   int _score, int _action_score)
-	:actions(parent.get_actions()), refcount(1),
-	 score(_score), action_score(_action_score)
+	:actions(parent.get_actions()), broken_deps(_broken_deps),
+	 score(_score), action_score(_action_score),
+	 refcount(1)
       {
 	assert(actions.find(the_action.ver.get_package()) == actions.end());
 	actions[the_action.ver.get_package()] = the_action;
@@ -224,8 +227,8 @@
        */
       solution_rep(const std::set<dep> &_broken_deps,
 		   int _score)
-	:broken_deps(_broken_deps.begin(), _broken_deps.end()), refcount(1),
-	 score(_score), action_score(0)
+	:broken_deps(_broken_deps), score(_score),
+	 action_score(0), refcount(1)
       {
       }
 
@@ -275,8 +278,9 @@
     solution():real_soln(0) {}
 
     solution(const action &a, const solution &parent,
+	     const std::set<dep> &broken_deps,
 	     int score, int action_score)
-      :real_soln(new solution_rep(a, parent, score, action_score))
+      :real_soln(new solution_rep(a, parent, broken_deps, score, action_score))
     {
     }
 
@@ -386,7 +390,17 @@
 	    out << ", ";
 	  out << i->first.get_name() << ":=" << i->second.ver.get_name();
 	}
-      out << ">";
+      out << ">;[";
+
+      for(typename std::set<dep>::const_iterator i=get_broken().begin();
+	  i!=get_broken().end(); ++i)
+	{
+	  if(i!=get_broken().begin())
+	    std::cout << ", ";
+	  std::cout << *i;
+	}
+
+      std::cout << "];" << get_score();
     }
   }; // End solution wrapper
 private:
@@ -549,9 +563,16 @@
       if(dep_broken(s, v, *bd))
 	new_broken.insert(*bd);
 
-    open.push(solution(action(v), s,
-		       new_action_score+broken_score*new_broken.size(),
-		       new_action_score));
+    solution s2=solution(action(v), s,
+			 new_broken,
+			 new_action_score+broken_score*new_broken.size(),
+			 new_action_score);
+
+    std::cout << "Enqueuing ";
+    s2.dump(std::cout);
+    std::cout << endl;
+
+    open.push(s2);
   }
 
   /** Generates (and enqueues) successor nodes for the given broken
@@ -691,17 +712,7 @@
 
 	s.dump(std::cout);
 
-	std::cout << " with broken deps [";
-
-	for(typename std::set<dep>::const_iterator i=s.get_broken().begin();
-	    i!=s.get_broken().end(); ++i)
-	  {
-	    if(i!=s.get_broken().begin())
-	      std::cout << ", ";
-	    std::cout << *i;
-	  }
-
-	std::cout << "], score " << s.get_score() << std::endl;
+	std::cout << std::endl;
 
 	// If all dependencies are satisfied, we found a solution.
 	if(s.get_broken().empty())