Skip to content

Commit 8668397

Browse files
conp-solutionstautschnig
authored andcommitted
Mergesat: get latest version from github
Signed-off-by: Norbert Manthey <[email protected]>
1 parent 72d73e8 commit 8668397

File tree

3 files changed

+113
-32
lines changed

3 files changed

+113
-32
lines changed

scripts/mergesat.patch

+108-20
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,32 @@
1-
diff -urN mergesat-3.0.orig/core/OnlineProofChecker.h mergesat-3.0/core/OnlineProofChecker.h
2-
--- mergesat-3.0.orig/core/OnlineProofChecker.h 2021-03-25 07:15:00.000000000 +0000
3-
+++ mergesat-3.0/core/OnlineProofChecker.h 2021-11-04 09:43:19.934897933 +0000
4-
@@ -832,6 +832,6 @@
1+
diff --git a/minisat/core/OnlineProofChecker.h b/minisat/core/OnlineProofChecker.h
2+
index 6bd9ff9..e642781 100644
3+
--- a/minisat/core/OnlineProofChecker.h
4+
+++ b/minisat/core/OnlineProofChecker.h
5+
@@ -833,6 +833,6 @@ inline void OnlineProofChecker::fullCheck()
56
}
67
}
78

89
-}; // namespace MERGESAT_NSPACE
910
+} // namespace MERGESAT_NSPACE
1011

1112
#endif
12-
diff -urN mergesat-3.0.orig/core/Solver.cc mergesat-3.0/core/Solver.cc
13-
--- mergesat-3.0.orig/core/Solver.cc 2021-03-25 07:15:00.000000000 +0000
14-
+++ mergesat-3.0/core/Solver.cc 2021-11-04 10:04:45.252778350 +0000
15-
@@ -215,22 +215,22 @@
13+
diff --git a/minisat/core/Proofs.h b/minisat/core/Proofs.h
14+
index b835924..08c31f0 100644
15+
--- a/minisat/core/Proofs.h
16+
+++ b/minisat/core/Proofs.h
17+
@@ -329,6 +329,6 @@ inline void Proof::flushToFile()
18+
inline void Proof::setVerbosity(int v) { verbosity = v; }
19+
20+
21+
-}; // namespace MERGESAT_NSPACE
22+
+} // namespace MERGESAT_NSPACE
23+
24+
#endif
25+
diff --git a/minisat/core/Solver.cc b/minisat/core/Solver.cc
26+
index b708a48..eec8d36 100644
27+
--- a/minisat/core/Solver.cc
28+
+++ b/minisat/core/Solver.cc
29+
@@ -224,22 +224,22 @@ bool MERGESAT_NSPACE::updateOptions()
1630
if (!args) return false;
1731
char *original_args = args;
1832

@@ -42,7 +56,7 @@ diff -urN mergesat-3.0.orig/core/Solver.cc mergesat-3.0/core/Solver.cc
4256
free(original_args);
4357
return false;
4458
}
45-
@@ -2601,7 +2601,7 @@
59+
@@ -2599,7 +2599,7 @@ lbool Solver::search(int &nof_conflicts)
4660

4761
/* grow limit after each rephasing */
4862
state_change_time = state_change_time + state_change_time_inc;
@@ -51,7 +65,16 @@ diff -urN mergesat-3.0.orig/core/Solver.cc mergesat-3.0/core/Solver.cc
5165

5266
/* actually rephase */
5367
if (rand() % 100 < 50)
54-
@@ -3042,7 +3042,8 @@
68+
@@ -2755,7 +2755,7 @@ lbool Solver::search(int &nof_conflicts)
69+
70+
if (verbosity >= 1 && (conflicts % status_every) == 0)
71+
printf("c | %9d | %7d %8d %8d | %8d %8d %6.0f | %6.3f %% |\n", (int)conflicts,
72+
- (int)dec_vars - (trail_lim.size() == 0 ? trail.size() : trail_lim[0]), nClauses(), (int)clauses_literals,
73+
+ (int)dec_vars - (trail_lim.size() == 0 ? trail.size() : trail_lim[0]), (int)nClauses(), (int)clauses_literals,
74+
(int)max_learnts, nLearnts(), (double)learnts_literals / nLearnts(), progressEstimate() * 100);
75+
76+
// the top_trail_soln should be update after each conflict
77+
@@ -3013,7 +3013,8 @@ void Solver::disableDISTANCEheuristic()
5578
order_heap_CHB.build(order_heap_DISTANCE.elements());
5679
order_heap = &order_heap_CHB;
5780
break;
@@ -61,7 +84,7 @@ diff -urN mergesat-3.0.orig/core/Solver.cc mergesat-3.0/core/Solver.cc
6184
break;
6285
}
6386
assert(!considersDISTANCE() && "we should have disabled DISTANCE heuristic");
64-
@@ -3062,7 +3063,8 @@
87+
@@ -3033,7 +3034,8 @@ void Solver::enableDISTANCEheuristic()
6588
order_heap_DISTANCE.build(order_heap_CHB.elements());
6689
order_heap = &order_heap_DISTANCE;
6790
break;
@@ -71,10 +94,47 @@ diff -urN mergesat-3.0.orig/core/Solver.cc mergesat-3.0/core/Solver.cc
7194
break;
7295
}
7396
assert(considersDISTANCE() && "we should have enabled DISTANCE heuristic");
74-
diff -urN mergesat-3.0.orig/core/SolverTypes.h mergesat-3.0/core/SolverTypes.h
75-
--- mergesat-3.0.orig/core/SolverTypes.h 2021-03-25 07:15:00.000000000 +0000
76-
+++ mergesat-3.0/core/SolverTypes.h 2021-11-04 09:47:03.613323317 +0000
77-
@@ -187,6 +187,16 @@
97+
@@ -3081,7 +3083,7 @@ lbool Solver::solve_()
98+
if (assumptions.size() > 0) solved_by_ls = false;
99+
100+
/* allow to disable SLS for larger clauses */
101+
- if ((sls_var_lim != -1 && nVars() > sls_var_lim) || (sls_clause_lim != -1 && nClauses() > sls_clause_lim)) {
102+
+ if ((sls_var_lim != -1 && nVars() > sls_var_lim) || (sls_clause_lim != -1 && nClauses() > (size_t)sls_clause_lim)) {
103+
use_ccnr = false;
104+
}
105+
106+
diff --git a/minisat/core/Solver.h b/minisat/core/Solver.h
107+
index ed63db4..fc3b648 100644
108+
--- a/minisat/core/Solver.h
109+
+++ b/minisat/core/Solver.h
110+
@@ -198,9 +198,9 @@ class Solver
111+
lbool modelValue(Var x) const; // The value of a variable in the last model. The last call to solve must have been satisfiable.
112+
lbool modelValue(Lit p) const; // The value of a literal in the last model. The last call to solve must have been satisfiable.
113+
int nAssigns() const; // The current number of assigned literals.
114+
- int nClauses() const; // The current number of original clauses.
115+
+ size_t nClauses() const; // The current number of original clauses.
116+
int nLearnts() const; // The current number of learnt clauses.
117+
- int nUnits() const; // The current number of unit clauses.
118+
+ size_t nUnits() const; // The current number of unit clauses.
119+
const Lit getUnit(size_t unit_idx) const; // The clause with a given index;
120+
const Clause &getClause(size_t cls_idx) const; // The clause with a given index;
121+
int nVars() const; // The current number of variables.
122+
@@ -895,8 +895,8 @@ inline lbool Solver::value(Lit p) const { return assigns[var(p)] ^ sign(p); }
123+
inline lbool Solver::modelValue(Var x) const { return model[x]; }
124+
inline lbool Solver::modelValue(Lit p) const { return model[var(p)] ^ sign(p); }
125+
inline int Solver::nAssigns() const { return trail.size(); }
126+
-inline int Solver::nClauses() const { return clauses.size(); }
127+
-inline int Solver::nUnits() const { return trail_lim.size() < 1 ? trail.size() : trail_lim[0]; }
128+
+inline size_t Solver::nClauses() const { return clauses.size(); }
129+
+inline size_t Solver::nUnits() const { return trail_lim.size() < 1 ? trail.size() : trail_lim[0]; }
130+
inline const Lit Solver::getUnit(size_t unit_idx) const
131+
{
132+
assert(unit_idx < nUnits() && "can only access valid unit clauses");
133+
diff --git a/minisat/core/SolverTypes.h b/minisat/core/SolverTypes.h
134+
index 4e366ac..3a150dd 100644
135+
--- a/minisat/core/SolverTypes.h
136+
+++ b/minisat/core/SolverTypes.h
137+
@@ -189,6 +189,16 @@ class Clause
78138
unsigned onQueue : 1;
79139
unsigned size : 30;
80140
} header;
@@ -91,7 +151,7 @@ diff -urN mergesat-3.0.orig/core/SolverTypes.h mergesat-3.0/core/SolverTypes.h
91151
union {
92152
Lit lit;
93153
float act;
94-
@@ -194,6 +204,13 @@
154+
@@ -196,6 +206,13 @@ class Clause
95155
uint32_t touched;
96156
CRef rel;
97157
} data[0];
@@ -106,30 +166,32 @@ diff -urN mergesat-3.0.orig/core/SolverTypes.h mergesat-3.0/core/SolverTypes.h
106166
friend class ClauseAllocator;
107167

108168
diff --git a/minisat/mtl/Vec.h b/minisat/mtl/Vec.h
169+
index 4abb5db..e9c0d93 100644
109170
--- a/minisat/mtl/Vec.h
110171
+++ b/minisat/mtl/Vec.h
111-
@@ -159,8 +159,7 @@
172+
@@ -167,8 +167,7 @@ template <class T> void vec<T>::capacity(int min_cap)
112173
int add = imax((min_cap - cap + 1) & ~1, ((cap >> 1) + 2) & ~1); // NOTE: grow by approximately 3/2
113174
if (add > INT_MAX - cap) throw OutOfMemoryException();
114175

115176
- T *newdata = (T *)::realloc(data, (cap + add) * sizeof(T));
116-
+ T *newdata = (T *)xrealloc(data, (cap + add) * sizeof(T));
117177
- if (newdata == NULL && errno == ENOMEM) throw OutOfMemoryException();
178+
+ T *newdata = (T *)xrealloc(data, (cap + add) * sizeof(T));
118179

119180
cap += add;
120181
data = newdata;
121182
diff --git a/minisat/mtl/XAlloc.h b/minisat/mtl/XAlloc.h
183+
index 1f43745..50809cb 100644
122184
--- a/minisat/mtl/XAlloc.h
123185
+++ b/minisat/mtl/XAlloc.h
124-
@@ -21,7 +21,6 @@
186+
@@ -21,7 +21,6 @@ OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWA
125187
#ifndef MergeSat_XAlloc_h
126188
#define MergeSat_XAlloc_h
127189

128190
-#include <errno.h>
129191
#include <stdlib.h>
130192

131193
// To not introduce this multiple times, use this header, as it's rather central
132-
@@ -41,7 +40,7 @@
194+
@@ -41,7 +40,7 @@ class OutOfMemoryException
133195
static inline void *xrealloc(void *ptr, size_t size)
134196
{
135197
void *mem = realloc(ptr, size);
@@ -138,3 +200,29 @@ diff --git a/minisat/mtl/XAlloc.h b/minisat/mtl/XAlloc.h
138200
throw OutOfMemoryException();
139201
} else
140202
return mem;
203+
diff --git a/minisat/parallel/ParSolver.cc b/minisat/parallel/ParSolver.cc
204+
index ad4c235..b76566b 100644
205+
--- a/minisat/parallel/ParSolver.cc
206+
+++ b/minisat/parallel/ParSolver.cc
207+
@@ -44,7 +44,7 @@ ParSolver::ParSolver()
208+
: par_reparsed_options(updateOptions())
209+
, parsing(false)
210+
, verbosity(0)
211+
- , use_simplification(true)
212+
+ , use_simplification(false)
213+
, sync_mode(opt_sync_mode == 0 ? NON_DETERMINISTIC : (opt_sync_mode == 1 ? DETERMINISTIC_STATIC : DETERMINISTIC_DYNAMIC))
214+
, cores(opt_cores)
215+
, initialized(false)
216+
diff --git a/minisat/simp/SimpSolver.cc b/minisat/simp/SimpSolver.cc
217+
index a5d9581..3c8d2bf 100644
218+
--- a/minisat/simp/SimpSolver.cc
219+
+++ b/minisat/simp/SimpSolver.cc
220+
@@ -45,7 +45,7 @@ static BoolOption opt_use_asymm(_cat, "asymm", "Shrink clauses by asymmetric bra
221+
static BoolOption opt_use_rcheck(_cat, "rcheck", "Check if a clause is already implied. (costly)", false, false);
222+
static BoolOption opt_use_elim(_cat, "elim", "Perform variable elimination.", true);
223+
static IntOption opt_grow(_cat, "grow", "Allow a variable elimination step to grow by a number of clauses.", 0);
224+
-static BoolOption opt_grow_iterations(_cat, "grow-iter", "Run iterative eliminations with growing.", true);
225+
+static BoolOption opt_grow_iterations(_cat, "grow-iter", "Run iterative eliminations with growing.", false);
226+
static IntOption opt_clause_lim(_cat,
227+
"cl-lim",
228+
"Variables are not eliminated if it produces a resolvent with a length above this "

src/Makefile

+3-10
Original file line numberDiff line numberDiff line change
@@ -135,18 +135,11 @@ minisat2-download:
135135

136136
mergesat-download:
137137
@echo "Downloading MergeSat (replacing Minisat 2.2.1)"
138-
@for i in $$(seq 1 3) ; do \
139-
$(DOWNLOADER) \
140-
https://github.com/conp-solutions/mergesat/archive/refs/tags/v3.0.tar.gz && \
141-
exit 0 ; \
142-
$(RM) v3.0.tar.gz ; \
143-
if [ $$i -lt 3 ] ; then echo "Re-trying in 10 seconds" 1>&2 ; sleep 10 ; fi ; \
144-
done ; exit 1
145-
@$(TAR) xfz v3.0.tar.gz # will create mergesat-3.0
146138
@rm -Rf ../mergesat-3.0
147-
@mv mergesat-3.0 ../
139+
@git clone https://github.com/conp-solutions/mergesat.git ../mergesat-3.0
148140
@(cd ../mergesat-3.0; patch -p1 < ../scripts/mergesat.patch)
149-
@rm v3.0.tar.gz
141+
@sed -i 's:eliminations with growing.", true);:eliminations with growing.", false);:g' ../mergesat-3.0/minisat/simp/SimpSolver.cc
142+
@sed -i 's:use_simplification(true):use_simplification(false):g' ../mergesat-3.0/minisat/parallel/ParSolver.cc
150143

151144
cudd-download:
152145
@echo "Downloading Cudd 3.0.0"

src/solvers/sat/satcheck_minisat2.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ void satcheck_minisat2_baset<T>::clear_interrupt()
106106
const std::string satcheck_minisat_no_simplifiert::solver_text()
107107
{
108108
#ifdef HAVE_MERGESAT
109-
return "Mergesat 3.0 without simplifier";
109+
return "Mergesat (latest) without simplifier";
110110
#else
111111
return "MiniSAT 2.2.1 without simplifier";
112112
#endif
@@ -115,7 +115,7 @@ const std::string satcheck_minisat_no_simplifiert::solver_text()
115115
const std::string satcheck_minisat_simplifiert::solver_text()
116116
{
117117
#ifdef HAVE_MERGESAT
118-
return "Mergesat 3.0 with simplifier";
118+
return "Mergesat (latest) with simplifier";
119119
#else
120120
return "MiniSAT 2.2.1 with simplifier";
121121
#endif

0 commit comments

Comments
 (0)