Package: ruby-dep-selector / 1.0.3-2

0002-Port-to-libgecode-4.0-Closes-710104.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
From: =?utf-8?q?C=C3=A9dric_Boutillier?= <boutil@debian.org>
Date: Tue, 26 Nov 2013 15:18:56 +0100
Subject: Port to libgecode >= 4.0 (Closes: #710104)

* Port to libgecode >= 4.0 (Closes: #710104)
  - Restart class has been renamed to RBS which needs an Engine (chose DFS)
  - instances of RBS need a Search::Cutoff (arbitraly chose Geometric)
  - variable selection are now functions and need brackets
  - statistics about memory are not available in gecode (by default)
---
 ext/dep_gecode/dep_selector_to_gecode.cpp | 43 ++++++++++++++++---------------
 ext/dep_gecode/dep_selector_to_gecode.h   |  2 +-
 2 files changed, 23 insertions(+), 22 deletions(-)

diff --git a/ext/dep_gecode/dep_selector_to_gecode.cpp b/ext/dep_gecode/dep_selector_to_gecode.cpp
index 794d4af..1adf906 100644
--- a/ext/dep_gecode/dep_selector_to_gecode.cpp
+++ b/ext/dep_gecode/dep_selector_to_gecode.cpp
@@ -386,30 +386,30 @@ void VersionProblem::Finalize()
         DEBUG_STREAM.flush();
     }
     // This branching starts as far as possible from the solution, in order to exercise the optimization functions.
-    branch(*this, disabled_package_variables, INT_VAR_SIZE_MIN, INT_VAL_MAX);
-    branch(*this, package_versions, INT_VAR_SIZE_MIN, INT_VAL_MIN);
-    branch(*this, total_required_disabled, INT_VAL_MAX);
-    branch(*this, total_induced_disabled, INT_VAL_MAX);
-    branch(*this, total_suspicious_disabled, INT_VAL_MAX);
-    branch(*this, total_disabled, INT_VAL_MAX);
-    branch(*this, at_latest, INT_VAR_SIZE_MIN, INT_VAL_MIN);
-    branch(*this, total_preferred_at_latest, INT_VAL_MIN);
-    branch(*this, total_not_preferred_at_latest, INT_VAL_MIN);
+    branch(*this, disabled_package_variables, INT_VAR_SIZE_MIN(), INT_VAL_MAX());
+    branch(*this, package_versions, INT_VAR_SIZE_MIN(), INT_VAL_MIN());
+    branch(*this, total_required_disabled, INT_VAL_MAX());
+    branch(*this, total_induced_disabled, INT_VAL_MAX());
+    branch(*this, total_suspicious_disabled, INT_VAL_MAX());
+    branch(*this, total_disabled, INT_VAL_MAX());
+    branch(*this, at_latest, INT_VAR_SIZE_MIN(), INT_VAL_MIN());
+    branch(*this, total_preferred_at_latest, INT_VAL_MIN());
+    branch(*this, total_not_preferred_at_latest, INT_VAL_MIN());
 #else // USE_DUMB_BRANCHING
     if (debugLogging) {
         DEBUG_STREAM << debugPrefix << "    Adding branching (BEST)" << std::endl;
         DEBUG_STREAM.flush();
     }
     // This branching is meant to start with most probable solution
-    branch(*this, disabled_package_variables, INT_VAR_SIZE_MIN, INT_VAL_MIN);
-    branch(*this, package_versions, INT_VAR_SIZE_MIN, INT_VAL_MAX);
-    branch(*this, total_required_disabled, INT_VAL_MIN);
-    branch(*this, total_induced_disabled, INT_VAL_MIN);
-    branch(*this, total_suspicious_disabled, INT_VAL_MIN);
-    branch(*this, total_disabled, INT_VAL_MIN);
-    branch(*this, at_latest, INT_VAR_SIZE_MIN, INT_VAL_MAX);
-    branch(*this, total_preferred_at_latest, INT_VAL_MAX);
-    branch(*this, total_not_preferred_at_latest, INT_VAL_MAX);
+    branch(*this, disabled_package_variables, INT_VAR_SIZE_MIN(), INT_VAL_MIN());
+    branch(*this, package_versions, INT_VAR_SIZE_MIN(), INT_VAL_MAX());
+    branch(*this, total_required_disabled, INT_VAL_MIN());
+    branch(*this, total_induced_disabled, INT_VAL_MIN());
+    branch(*this, total_suspicious_disabled, INT_VAL_MIN());
+    branch(*this, total_disabled, INT_VAL_MIN());
+    branch(*this, at_latest, INT_VAR_SIZE_MIN(), INT_VAL_MAX());
+    branch(*this, total_preferred_at_latest, INT_VAL_MAX());
+    branch(*this, total_not_preferred_at_latest, INT_VAL_MAX());
 #endif // USE_DUMB_BRANCHING
 
     if (debugLogging) {
@@ -617,7 +617,9 @@ VersionProblem * VersionProblem::InnerSolve(VersionProblem * problem, int &iterc
     DEBUG_STREAM << "Creating solver" << std::endl << std::flush;
 #endif
     VersionProblem *best_solution = NULL;
-    Restart<VersionProblem> solver(problem);
+    Search::Options o;
+    o.cutoff = Search::Cutoff::geometric();
+    RBS<DFS,VersionProblem> solver(problem, o);
 
 #ifdef MEMORY_DEBUG
     DEBUG_STREAM << "Starting Solve" << std::endl << std::flush;
@@ -638,7 +640,7 @@ VersionProblem * VersionProblem::InnerSolve(VersionProblem * problem, int &iterc
                 DEBUG_STREAM << problem->debugPrefix << "Trial Solution #" << itercount << "===============================" << std::endl;
                 const Search::Statistics & stats = solver.statistics();
                 DEBUG_STREAM << problem->debugPrefix << "Solver stats: Prop:" << stats.propagate << " Fail:" << stats.fail << " Node:" << stats.node;
-                DEBUG_STREAM << " Depth:" << stats.depth << " memory:" << stats.memory << std::endl;
+                DEBUG_STREAM << " Depth:" << stats.depth << std::endl;
                 solution->Print(DEBUG_STREAM);
             }
         }
@@ -653,7 +655,6 @@ VersionProblem * VersionProblem::InnerSolve(VersionProblem * problem, int &iterc
         std::cerr << "Time: " << elapsed_time << "ms ";
         const Search::Statistics & final_stats = solver.statistics();
         std::cerr << "Stats: " << itercount << " steps, ";
-        std::cerr << final_stats.memory << " bytes, ";
         std::cerr << final_stats.propagate << " props, " << final_stats.node << " nodes, " << final_stats.depth << " depth ";
         std::cerr << std::endl << std::flush;
     }
diff --git a/ext/dep_gecode/dep_selector_to_gecode.h b/ext/dep_gecode/dep_selector_to_gecode.h
index f99ed5d..05cd9e2 100644
--- a/ext/dep_gecode/dep_selector_to_gecode.h
+++ b/ext/dep_gecode/dep_selector_to_gecode.h
@@ -159,7 +159,7 @@ class Solver {
   Solver(VersionProblem *s);
   VersionProblem GetNextSolution();
  private:
-  Restart<VersionProblem> solver;
+  RBS<DFS,VersionProblem> solver;
 };
 
 #endif // dep_selector_to_gecode_h