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

Daniel Burrows dburrows@costa.debian.org
Wed, 27 Apr 2005 13:50:23 +0000


Author: dburrows
Date: Wed Apr 27 13:50:20 2005
New Revision: 3147

Modified:
   branches/aptitude-0.3/aptitude/ChangeLog
   branches/aptitude-0.3/aptitude/src/generic/aptcache.cc
   branches/aptitude-0.3/aptitude/src/generic/aptitude_resolver.cc
   branches/aptitude-0.3/aptitude/src/generic/aptitude_resolver.h
   branches/aptitude-0.3/aptitude/src/generic/problemresolver/problemresolver.h
Log:
Add support for dropping solutions that are 'too bad'.

Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog	(original)
+++ branches/aptitude-0.3/aptitude/ChangeLog	Wed Apr 27 13:50:20 2005
@@ -1,5 +1,11 @@
 2005-04-27  Daniel Burrows  <dburrows@debian.org>
 
+	* src/generic/aptcache.cc, src/generic/aptitude_resolver.cc, src/generic/aptitude_resolver.h, src/generic/problemresolver/problemresolver.h:
+
+	  Add basic support in the problem-resolver for specifying
+	  "infinity" -- a boundary for solution badness beyond which all
+	  solutions are dropped.
+
 	* src/generic/aptcache.cc:
 
 	  Decrease the default max_steps value so that hard-to-resolve

Modified: branches/aptitude-0.3/aptitude/src/generic/aptcache.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/generic/aptcache.cc	(original)
+++ branches/aptitude-0.3/aptitude/src/generic/aptcache.cc	Wed Apr 27 13:50:20 2005
@@ -1351,6 +1351,7 @@
 
   resolver=new aptitude_resolver(aptcfg->FindI(PACKAGE "::ProblemResolver::StepScore", -10),
 				 aptcfg->FindI(PACKAGE "::ProblemResolver::BrokenScore", -50),
+				 aptcfg->FindI(PACKAGE "::ProblemResolver::Infinity", 150000),
 				 aptcfg->FindI(PACKAGE "::ProblemResolver::ResolutionScore", 50));
 
   resolver->add_action_scores(aptcfg->FindI(PACKAGE "::ProblemResolver::PreserveManualScore", 40),

Modified: branches/aptitude-0.3/aptitude/src/generic/aptitude_resolver.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/generic/aptitude_resolver.cc	(original)
+++ branches/aptitude-0.3/aptitude/src/generic/aptitude_resolver.cc	Wed Apr 27 13:50:20 2005
@@ -21,8 +21,9 @@
 
 aptitude_resolver::aptitude_resolver(int step_penalty,
 				     int broken_penalty,
+				     int infinity,
 				     int resolution_score)
-  :generic_problem_resolver<aptitude_universe>(step_penalty, broken_penalty, resolution_score, universe),
+  :generic_problem_resolver<aptitude_universe>(step_penalty, broken_penalty, infinity, resolution_score, universe),
    universe()
 {
 }

Modified: branches/aptitude-0.3/aptitude/src/generic/aptitude_resolver.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/generic/aptitude_resolver.h	(original)
+++ branches/aptitude-0.3/aptitude/src/generic/aptitude_resolver.h	Wed Apr 27 13:50:20 2005
@@ -1092,7 +1092,8 @@
 {
   const aptitude_universe universe;
 public:
-  aptitude_resolver(int step_score, int broken_score, int resolution_score);
+  aptitude_resolver(int step_score, int broken_score,
+		    int infinity, int resolution_score);
 
   /** Assign scores to all packages and all package versions according
    *  to its arguments.  All scores are assigned with add_score, so

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	Wed Apr 27 13:50:20 2005
@@ -463,6 +463,11 @@
    */
   int step_score, broken_score;
 
+  /** Solutions whose score is smaller than this value will be
+   *  discarded rather than being enqueued.
+   */
+  int minimum_score;
+
   /** How much to reward real solutions -- solutions that fix all
    *  dependencies.  Make this big to immediately pick them up, or
    *  small to ignore "bad" solutions (at the risk of running out of
@@ -584,6 +589,13 @@
     if(new_broken.size() == 0)
       new_score+=full_solution_score;
 
+    if(new_score < minimum_score)
+      {
+	if(debug)
+	  std::cout << "Not generating solution (infinite badness " << new_score << "<" << minimum_score << ")" << std::endl;
+	return;
+      }
+
     solution s2=solution(action(v), s,
 			 new_broken,
 			 new_score,
@@ -692,16 +704,20 @@
 
   /** Construct a new generic_problem_resolver.
    *
-   *  \param _score_penalty the score per "step" of a (partial) solution.  Typically negative.
+   *  \param _score_score the score per "step" of a (partial) solution.  Typically negative.
    *  \param _broken_score the score to add per broken dependency of a (partial) solution.  Typically negative.
+   *  \param infinity a score value that will be considered to be "infinite".  Solutions
+   *  with less than -infinity points will be immediately discarded.
    *  \param _full_solution_score a bonus for goal nodes (things
    *  that solve all dependencies)
    *  \param _universe the universe in which we are working.
    */
   generic_problem_resolver(int _step_score, int _broken_score,
+			   int infinity,
 			   int _full_solution_score,
 			   const PackageUniverse &_universe)
     :step_score(_step_score), broken_score(_broken_score),
+     minimum_score(-infinity),
      full_solution_score(_full_solution_score),
      universe(_universe), finished(false), debug(false)
   {