Skip to content

Commit 31b75e2

Browse files
committed
Make Glucose support compile
Hardness support was added to minisat2 only. Also update the source patch to ensure Glucose compiles without warnings when using recent versions of GCC.
1 parent 6717949 commit 31b75e2

File tree

3 files changed

+48
-2
lines changed

3 files changed

+48
-2
lines changed

scripts/glucose-syrup-patch

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,22 @@ diff -rupNw glucose-syrup/mtl/Vec.h glucose-syrup-patched/mtl/Vec.h
9898
throw OutOfMemoryException();
9999
}
100100

101+
diff -rupNw glucose-syrup/mtl/Vec.h glucose-syrup-patched/mtl/Vec.h
102+
--- glucose-syrup/mtl/Vec.h
103+
+++ glucose-syrup-patched/mtl/Vec.h
104+
@@ -103,8 +103,10 @@
105+
void vec<T>::capacity(int min_cap) {
106+
if (cap >= min_cap) return;
107+
int add = imax((min_cap - cap + 1) & ~1, ((cap >> 1) + 2) & ~1); // NOTE: grow by approximately 3/2
108+
- if (add > INT_MAX - cap || (((data = (T*)::realloc(data, (cap += add) * sizeof(T))) == NULL) && errno == ENOMEM))
109+
- throw OutOfMemoryException();
110+
+ if (add > INT_MAX - cap)
111+
+ throw OutOfMemoryException();
112+
+
113+
+ data = (T*)xrealloc(data, (cap += add) * sizeof(T));
114+
}
115+
116+
101117
diff -rupNw glucose-syrup/simp/SimpSolver.cc glucose-syrup-patched/simp/SimpSolver.cc
102118
--- glucose-syrup/simp/SimpSolver.cc 2014-10-03 11:10:22.000000000 +0200
103119
+++ glucose-syrup-patched/simp/SimpSolver.cc 2018-04-21 16:58:22.950005391 +0200
@@ -201,6 +217,15 @@ diff -rupNw glucose-syrup/utils/ParseUtils.h glucose-syrup-patched/utils/ParseUt
201217

202218
int operator * () const { return (pos >= size) ? EOF : buf[pos]; }
203219
void operator ++ () { pos++; assureLookahead(); }
220+
@@ -96,7 +96,7 @@
221+
if (*in != '.') printf("PARSE ERROR! Unexpected char: %c\n", *in),exit(3);
222+
++in; // skip dot
223+
currentExponent = 0.1;
224+
- while (*in >= '0' && *in <= '9')
225+
+ while (*in >= '0' && *in <= '9')
226+
accu = accu + currentExponent * ((double)(*in - '0')),
227+
currentExponent /= 10,
228+
++in;
204229
diff -rupNw glucose-syrup/utils/System.h glucose-syrup-patched/utils/System.h
205230
--- glucose-syrup/utils/System.h 2014-10-03 11:10:22.000000000 +0200
206231
+++ glucose-syrup-patched/utils/System.h 2018-04-21 16:58:22.950005391 +0200

src/solvers/sat/satcheck_glucose.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ void satcheck_glucose_baset<T>::lcnf(const bvt &bv)
121121

122122
solver->addClause_(c);
123123

124+
with_solver_hardness(
125+
[&bv](solver_hardnesst &hardness) { hardness.register_clause(bv); });
126+
124127
clause_counter++;
125128
}
126129
catch(Glucose::OutOfMemoryException)

src/solvers/sat/satcheck_glucose.h

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ Author: Daniel Kroening, [email protected]
1212

1313
#include "cnf.h"
1414

15+
#include <solvers/hardness_collector.h>
16+
1517
// Select one: basic solver or with simplification.
1618
// Note that the solver with simplifier isn't really robust
1719
// when used incrementally, as variables may disappear
@@ -23,8 +25,8 @@ class Solver; // NOLINT(readability/identifiers)
2325
class SimpSolver; // NOLINT(readability/identifiers)
2426
}
2527

26-
template<typename T>
27-
class satcheck_glucose_baset:public cnf_solvert
28+
template <typename T>
29+
class satcheck_glucose_baset : public cnf_solvert, public hardness_collectort
2830
{
2931
public:
3032
satcheck_glucose_baset(T *, message_handlert &message_handler);
@@ -51,13 +53,29 @@ class satcheck_glucose_baset:public cnf_solvert
5153
return true;
5254
}
5355

56+
void
57+
with_solver_hardness(std::function<void(solver_hardnesst &)> handler) override
58+
{
59+
if(solver_hardness.has_value())
60+
{
61+
handler(solver_hardness.value());
62+
}
63+
}
64+
65+
void enable_hardness_collection() override
66+
{
67+
solver_hardness = solver_hardnesst{};
68+
}
69+
5470
protected:
5571
resultt do_prop_solve() override;
5672

5773
T *solver;
5874

5975
void add_variables();
6076
bvt assumptions;
77+
78+
optionalt<solver_hardnesst> solver_hardness;
6179
};
6280

6381
class satcheck_glucose_no_simplifiert:

0 commit comments

Comments
 (0)