-
Notifications
You must be signed in to change notification settings - Fork 0
/
naive_ldfi.py
54 lines (43 loc) · 1.5 KB
/
naive_ldfi.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
50
51
52
53
from ldfi_py.pbool import *
import ldfi_py.pilp
import ldfi_py.psat
class NaiveLDFI():
def __init__(self):
self.graphs = []
def add_graph(self, graph):
self.graphs.append([graph.label, graph.active_nodeset()])
def current_formula(self):
outerset = set()
for trace in self.graphs:
labels = filter(lambda x: x != trace[0], map(lambda x: x.label, trace[1]))
#print "LABELS is " + str(sorted(labels))
if labels is None:
print "ONO"
outerset.add(frozenset(labels))
conjuncts = None
for inner in outerset:
disjunction = None
for item in inner:
if disjunction is None:
disjunction = Literal(item)
else:
disjunction = OrFormula(Literal(item), disjunction)
if conjuncts is None:
conjuncts = disjunction
else:
conjuncts = AndFormula(disjunction, conjuncts)
#print "CONJ " + str(conjuncts)
return conjuncts
def suggestions(self):
formula = self.current_formula()
#print "FORMO " + str(formula)
cnf = CNFFormula(formula)
#print "FORMO " + str(formula)
#print "clauses " + str(len(cnf.conjuncts()))
s = ldfi_py.pilp.Solver(cnf)
#s = ldfi_py.psat.Solver(cnf)
crs = s.solutions()
#for s in crs:
# print "ESS " + str(s)
return crs
#class NaiveLDFIWrapper():