Skip to content

Commit 67b1923

Browse files
committed
Glucose 3.0
1 parent cf6d8fa commit 67b1923

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+659
-7248
lines changed

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
# Glucose SAT solver
22

3-
This is the release 2.1 of the glucose SAT solver.
3+
This is the release 3.0 of the glucose SAT solver.
44
It is based on [Minisat 2.2](http://minisat.se/MiniSat.html)
55

6-
For compiling: ```./build.sh```
6+
For compiling:
7+
- ```cd simp```
8+
- ```make```
9+
10+
11+
For running: ```simp/glucose BENCHNAME```
712

813

9-
For running: ```glucose.sh BENCHNAME```

build.sh

Lines changed: 0 additions & 11 deletions
This file was deleted.

clean.sh

Lines changed: 0 additions & 11 deletions
This file was deleted.

sources/glucose/core/BoundedQueue.h renamed to core/BoundedQueue.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWA
2727

2828
//=================================================================================================
2929

30-
namespace Minisat {
30+
namespace Glucose {
3131

3232
template <class T>
3333
class bqueue {
@@ -54,7 +54,7 @@ class bqueue {
5454
queuesize++;
5555
sumofqueue += x;
5656
elems[first] = x;
57-
if ((++first) == maxsize) first = 0;
57+
if ((++first) == maxsize) {first = 0;last = 0;}
5858
}
5959

6060
T peek() { assert(queuesize>0); return elems[last]; }
@@ -74,7 +74,7 @@ class bqueue {
7474

7575
void growTo(int size) {
7676
elems.growTo(size);
77-
first=0; maxsize=size; queuesize = 0;
77+
first=0; maxsize=size; queuesize = 0;last = 0;
7878
for(int i=0;i<size;i++) elems[i]=0;
7979
}
8080

File renamed without changes.

sources/glucose/core/Dimacs.h renamed to core/Dimacs.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
1818
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1919
**************************************************************************************************/
2020

21-
#ifndef Minisat_Dimacs_h
22-
#define Minisat_Dimacs_h
21+
#ifndef Glucose_Dimacs_h
22+
#define Glucose_Dimacs_h
2323

2424
#include <stdio.h>
2525

2626
#include "utils/ParseUtils.h"
2727
#include "core/SolverTypes.h"
2828

29-
namespace Minisat {
29+
namespace Glucose {
3030

3131
//=================================================================================================
3232
// DIMACS Parser:

sources/glucose/core/Main.cc renamed to core/Main.cc

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWA
3838
#include "core/Dimacs.h"
3939
#include "core/Solver.h"
4040

41-
using namespace Minisat;
41+
using namespace Glucose;
4242

4343
//=================================================================================================
4444

@@ -47,7 +47,7 @@ void printStats(Solver& solver)
4747
{
4848
double cpu_time = cpuTime();
4949
double mem_used = 0;//memUsedPeak();
50-
printf("c restarts : %"PRIu64" (%"PRIu64" conflicts in avg)\n", solver.starts,solver.conflicts/solver.starts);
50+
printf("c restarts : %"PRIu64" (%"PRIu64" conflicts in avg)\n", solver.starts,(solver.starts>0 ?solver.conflicts/solver.starts : 0));
5151
printf("c blocked restarts : %"PRIu64" (multiple: %"PRIu64") \n", solver.nbstopsrestarts,solver.nbstopsrestartssame);
5252
printf("c last block at restart : %"PRIu64"\n",solver.lastblockatrestart);
5353
printf("c nb ReduceDB : %lld\n", solver.nbReduceDB);
@@ -89,7 +89,7 @@ static void SIGINT_exit(int signum) {
8989

9090
int main(int argc, char** argv)
9191
{
92-
printf("c\nc This is glucose 2.1 -- based on MiniSAT (Many thanks to MiniSAT team)\nc\n");
92+
printf("c\nc This is glucose 3.0 -- based on MiniSAT (Many thanks to MiniSAT team)\nc\n");
9393
try {
9494
setUsageHelp("c USAGE: %s [options] <input-file> <result-output-file>\n\n where input may be either in plain or gzipped DIMACS.\n");
9595
// printf("This is MiniSat 2.0 beta\n");
@@ -102,17 +102,20 @@ int main(int argc, char** argv)
102102
// Extra options:
103103
//
104104
IntOption verb ("MAIN", "verb", "Verbosity level (0=silent, 1=some, 2=more).", 1, IntRange(0, 2));
105+
BoolOption mod ("MAIN", "model", "show model.", false);
105106
IntOption vv ("MAIN", "vv", "Verbosity every vv conflicts", 10000, IntRange(1,INT32_MAX));
106107
IntOption cpu_lim("MAIN", "cpu-lim","Limit on CPU time allowed in seconds.\n", INT32_MAX, IntRange(0, INT32_MAX));
107108
IntOption mem_lim("MAIN", "mem-lim","Limit on memory usage in megabytes.\n", INT32_MAX, IntRange(0, INT32_MAX));
108109

110+
109111
parseOptions(argc, argv, true);
110112

111113
Solver S;
112114
double initial_time = cpuTime();
113115

114116
S.verbosity = verb;
115117
S.verbEveryConflicts = vv;
118+
S.showModel = mod;
116119
solver = &S;
117120
// Use signal handlers that forcibly quit until the solver will be able to respond to
118121
// interrupts:
@@ -153,8 +156,11 @@ int main(int argc, char** argv)
153156

154157
parse_DIMACS(in, S);
155158
gzclose(in);
156-
FILE* res = (argc >= 3) ? fopen(argv[2], "wb") : NULL;
157159

160+
161+
162+
FILE* res = (argc >= 3) ? fopen(argv[argc-1], "wb") : NULL;
163+
158164
if (S.verbosity > 0){
159165
printf("c | Number of variables: %12d |\n", S.nVars());
160166
printf("c | Number of clauses: %12d |\n", S.nClauses()); }
@@ -170,6 +176,7 @@ int main(int argc, char** argv)
170176
//signal(SIGXCPU,SIGINT_interrupt);
171177

172178
if (!S.simplify()){
179+
if (S.certifiedOutput != NULL) fprintf(S.certifiedOutput, "0\n"), fclose(S.certifiedOutput);
173180
if (res != NULL) fprintf(res, "UNSAT\n"), fclose(res);
174181
if (S.verbosity > 0){
175182
printf("c =========================================================================================================\n");
@@ -179,35 +186,40 @@ int main(int argc, char** argv)
179186
printf("s UNSATISFIABLE\n");
180187
exit(20);
181188
}
182-
189+
183190
vec<Lit> dummy;
184191
lbool ret = S.solveLimited(dummy);
185192
if (S.verbosity > 0){
186193
printStats(S);
187194
printf("\n"); }
188-
if (res != NULL){
189-
if (ret == l_True){
190-
fprintf(res, "SAT\n");
191-
for (int i = 0; i < S.nVars(); i++)
192-
if (S.model[i] != l_Undef)
193-
fprintf(res, "%s%s%d", (i==0)?"":" ", (S.model[i]==l_True)?"":"-", i+1);
194-
fprintf(res, " 0\n");
195-
}else if (ret == l_False)
196-
fprintf(res, "UNSAT\n");
197-
else
198-
fprintf(res, "INDET\n");
199-
fclose(res);
200-
} else {
201-
printf(ret == l_True ? "s SATISFIABLE\n" : ret == l_False ? "s UNSATISFIABLE\n" : "s INDETERMINATE\n");
202-
if(ret==l_True) {
195+
196+
//-------------- Result is put in a external file
197+
if (res != NULL){
198+
if (ret == l_True){
199+
fprintf(res, "SAT\n");
200+
for (int i = 0; i < S.nVars(); i++)
201+
if (S.model[i] != l_Undef)
202+
fprintf(res, "%s%s%d", (i==0)?"":" ", (S.model[i]==l_True)?"":"-", i+1);
203+
fprintf(res, " 0\n");
204+
}else if (ret == l_False)
205+
fprintf(res, "UNSAT\n");
206+
else
207+
fprintf(res, "INDET\n");
208+
fclose(res);
209+
210+
//-------------- Want certified output
211+
} else {
212+
printf(ret == l_True ? "s SATISFIABLE\n" : ret == l_False ? "s UNSATISFIABLE\n" : "s INDETERMINATE\n");
213+
if(S.showModel && ret==l_True) {
203214
printf("v ");
204215
for (int i = 0; i < S.nVars(); i++)
205216
if (S.model[i] != l_Undef)
206217
printf("%s%s%d", (i==0)?"":" ", (S.model[i]==l_True)?"":"-", i+1);
207218
printf(" 0\n");
208219
}
209220
}
210-
221+
222+
211223
#ifdef NDEBUG
212224
exit(ret == l_True ? 10 : ret == l_False ? 20 : 0); // (faster than "return", which will invoke the destructor for 'Solver')
213225
#else
File renamed without changes.

0 commit comments

Comments
 (0)