-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcores.py
executable file
·49 lines (43 loc) · 1.27 KB
/
cores.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
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env python
import argparse
from signal import signal, SIGPIPE, SIG_DFL
from decomposer import Decomposer
from dp import Table
from formula import Formula
from graph import Graph
signal(SIGPIPE, SIG_DFL)
parser = argparse.ArgumentParser(
description="Dynamic programming on a TD of a MaxSAT instance")
parser.add_argument("file")
args = parser.parse_args()
with open(args.file) as f:
print("Parsing...")
formula = Formula(f)
print(formula)
print("Constructing primal graph...")
g = formula.primal_graph()
print(g)
#td = Decomposer(g, Graph.min_degree_vertex, max_width=8).decompose()
print("Decomposing...")
tds = Decomposer(g, Graph.min_degree_vertex,
max_width=5).decompose_partially()
#td.weakly_normalize()
for td in tds:
print(td)
print()
td.weakly_normalize()
print("Solving...")
for td in tds:
if not td.children:
continue # maybe not so interesting...?
print(td)
table = Table(td, formula)
table.compute()
print()
table.write_recursively()
if table.unsat():
print("Unsat.")
print("Some cores:")
for core in table.unsat_cores():
print(core)
print()