-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobligationmonitor.py
58 lines (53 loc) · 1.77 KB
/
obligationmonitor.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
54
55
56
57
import livesynthesis
import pygraphviz as viz
from itertools import chain, combinations
import output
import spot
import transitionsystems
def list_of_2ap(set):
s = list(set)
return chain.from_iterable(combinations(s,r) for r in range(len(s)+1))
def OM_from_formula_dep(f, aps):
powerset_ap = list_of_2ap(aps)
list_ap = []
for x in powerset_ap:
list_ap.append(x)
om = viz.AGraph(directed=True, strict=False)
queue = []
explored = set()
om.add_node(f, label=livesynthesis.strip(f))
om.add_edge('Initial',f)
queue.append(f)
while queue:
current = queue.pop(0)
explored.add(current)
for current_ap in list_ap:
g = livesynthesis.after(current, current_ap)
if not g in explored:
om.add_node(g, label=livesynthesis.strip(g))
queue.append(g)
om.add_edge(current, g, label=current_ap)
output.dump_dot_graph(om, 'test')
def OM_from_formula(f, aps):
powerset_ap = list_of_2ap(aps)
list_ap = []
for x in powerset_ap:
list_ap.append(x)
om = transitionsystems.Transitionsystem()
queue = []
explored = set()
init_node = transitionsystems.Node(f, livesynthesis.strip(f), True)
om.add_node(init_node)
#om.add_edge('Initial',f)
queue.append(init_node)
while queue:
current = queue.pop(0)
explored.add(current)
for current_ap in list_ap:
g_prime = livesynthesis.after(current.get_name(), current_ap)
g = transitionsystems.Node(g_prime, livesynthesis.strip(g_prime))
if not g in explored:
om.add_node(g)
queue.append(g)
om.create_edge(current, g, current_ap)
output.dump_dot_graph(output.TS_to_dot(om), 'test')