-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSolve.py
executable file
·37 lines (29 loc) · 1.28 KB
/
Solve.py
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
#!/usr/bin/env python3
import sys # for argv
from pysat.solvers import Solver
from SatMemory import SatMemory
from SatInteger import SatInteger
from SatFormula import *
from CNF import CNF
from BitUtils import *
from DimacsFile import DimacsFile
if __name__ == "__main__":
if len(sys.argv) < 2:
print("Usage: " + sys.argv[0] + " <fileName.dimacs>")
exit(0)
df = DimacsFile(sys.argv[1])
df.load()
clauses = df.clauses()
print("#vars="+str(df.number_of_vars())+" #clauses="+str(df.number_of_clauses()))
with Solver(name="Cadical", bootstrap_with=clauses, use_timer=True) as solver:
is_sat = solver.solve()
print("Cadical result: ", is_sat, '{0:.4f}s'.format(solver.time()), len(clauses), " clauses")
print(solver.get_model())
with Solver(name="Glucose3", bootstrap_with=clauses, use_timer=True) as solver:
is_sat = solver.solve()
print("Gluecose3 result: ", is_sat, '{0:.4f}s'.format(solver.time()), len(clauses), " clauses")
print(solver.get_model())
with Solver(name="Glucose4", bootstrap_with=clauses, use_timer=True) as solver:
is_sat = solver.solve()
print("Gluecose4 result: ", is_sat, '{0:.4f}s'.format(solver.time()), len(clauses), " clauses")
print(solver.get_model())