-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbasic_test.py
169 lines (152 loc) · 5.34 KB
/
basic_test.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
import logging
import os
from generation.generate import generate
from file_parser.sdf3_parser import write_sdf3_file, read_sdf3_file
from file_parser.turbine_parser import write_tur_file, read_tur_file
from param.parameters import Parameters
def try_function(function, args):
try:
ret = function(*args)
except:
print "FAIL !"
else:
print "done !"
return ret
def try_property(prop):
try:
ret = prop
except:
print "FAIL !"
else:
print "done !"
return ret
print "Starting basic test !"
print ""
print "Acyclic SDF generation",
c_param = Parameters()
c_param.set_logging_level(logging.CRITICAL)
c_param.set_multi_arc(True)
c_param.set_reentrant(True)
c_param.set_acyclic(True)
try_function(generate, ("Test_of_SDFG", c_param))
print "Cyclic SDF generation",
c_param.set_acyclic(False)
SDF = try_function(generate, ("Test_of_SDFG", c_param))
print "SDF Compute repetition vector",
try_function(SDF.compute_repetition_vector, [])
print "Write SDF into sdf3 file",
try_function(write_sdf3_file, (SDF, "SDF.sdf3"))
print "Read SDF into sdf3 file",
try_function(read_sdf3_file, ["SDF.sdf3"])
os.remove("SDF.sdf3")
print "Write SDF into tur file",
try_function(write_tur_file, (SDF, "SDF.tur"))
print "Read SDF into tur file",
try_function(read_tur_file, ["SDF.tur"])
os.remove("SDF.tur")
print "Un-normalized SDF",
try_function(SDF.un_normalized, [])
print "Normalized SDF",
try_function(SDF.normalized, [])
print "SC1 on a SDF",
try_function(SDF.compute_initial_marking, ("SC1", False, None, None))
print "SC2 on a SDF",
try_function(SDF.compute_initial_marking, ("SC2", False, None, None))
print "SC1_k on a SDF",
try_function(SDF.compute_initial_marking, ("SC1", False, None, 1))
print "SC1_MIP on a SDF",
try_function(SDF.compute_initial_marking, ("SC1_MIP", False, None, None))
print "SC2_MIP on a SDF",
try_function(SDF.compute_initial_marking, ("SC2_MIP", False, None, None))
print "SC1_MIP_k on a SDF",
try_function(SDF.compute_initial_marking, ("SC1_MIP", False, None, 1))
print "Computing period on a SDF",
try_function(SDF.get_period, [])
print "Compute symbolic execution on a SDF",
try_property(SDF.is_dead_lock)
print ""
print "Acyclic SDF generation",
c_param.set_dataflow_type("CSDF")
c_param.set_logging_level(logging.CRITICAL)
c_param.set_multi_arc(True)
c_param.set_reentrant(True)
c_param.set_acyclic(True)
try_function(generate, ("Test_of_CSDFG", c_param))
print "Cyclic CSDF generation",
c_param.set_acyclic(False)
CSDF = try_function(generate, ("Test_of_CSDFG", c_param))
print "CSDF Compute repetition vector",
try_function(CSDF.compute_repetition_vector, [])
print "Write CSDF into sdf3 file",
try_function(write_sdf3_file, (CSDF, "CSDF.sdf3"))
print "Read CSDF into sdf3 file",
try_function(read_sdf3_file, ["CSDF.sdf3"])
os.remove("CSDF.sdf3")
print "Write CSDF into tur file",
try_function(write_tur_file, (CSDF, "CSDF.tur"))
print "Read CSDF into tur file",
try_function(read_tur_file, ["CSDF.tur"])
os.remove("CSDF.tur")
print "Un-normalized CSDF",
try_function(CSDF.un_normalized, [])
print "Normalized CSDF",
try_function(CSDF.normalized, [])
print "SC1 on a CSDF",
try_function(CSDF.compute_initial_marking, ("SC1", False, None, None))
print "SC2 on a CSDF",
try_function(CSDF.compute_initial_marking, ("SC2", False, None, None))
print "SC1_k on a CSDF",
try_function(CSDF.compute_initial_marking, ("SC1", False, None, 1))
print "SC1_MIP on a CSDF",
try_function(CSDF.compute_initial_marking, ("SC1_MIP", False, None, None))
print "SC2_MIP on a CSDF",
try_function(CSDF.compute_initial_marking, ("SC2_MIP", False, None, None))
print "SC1_MIP_k on a CSDF",
try_function(CSDF.compute_initial_marking, ("SC1_MIP", False, None, 1))
print "Compute symbolic execution on a CSDF",
try_property(CSDF.is_dead_lock)
print ""
print "Acyclic PCG generation",
c_param.set_dataflow_type("PCG")
c_param.set_logging_level(logging.CRITICAL)
c_param.set_acyclic(True)
c_param.set_multi_arc(True)
c_param.set_reentrant(True)
try_function(generate, ("Test_of_PCG", c_param))
print "Cyclic PCG generation",
c_param.set_acyclic(False)
PCG = try_function(generate, ("Test_of_PCGG", c_param))
print "PCG Compute repetition vector",
try_function(PCG.compute_repetition_vector, [])
print "Write PCG into sdf3 file",
try_function(write_sdf3_file, (PCG, "PCG.sdf3"))
print "Read PCG into sdf3 file",
try_function(read_sdf3_file, ["PCG.sdf3"])
os.remove("PCG.sdf3")
print "Write PCG into tur file",
try_function(write_tur_file, (PCG, "PCG.tur"))
print "Read PCG into tur file",
try_function(read_tur_file, ["PCG.tur"])
os.remove("PCG.tur")
print "Un-normalized PCG",
try_function(PCG.un_normalized, [])
print "Normalized PCG",
try_function(PCG.normalized, [])
print "SC1 on a PCG",
try_function(PCG.compute_initial_marking, ("SC1", False, None, None))
print "SC2 on a PCG",
try_function(PCG.compute_initial_marking, ("SC2", False, None, None))
print "SC1_k on a PCG",
try_function(PCG.compute_initial_marking, ("SC1", False, None, 1))
print "SC1_MIP on a PCG",
try_function(PCG.compute_initial_marking, ("SC1_MIP", False, None, None))
print "SC2_MIP on a PCG",
try_function(PCG.compute_initial_marking, ("SC2_MIP", False, None, None))
print "SC1_MIP_k on a PCG",
try_function(PCG.compute_initial_marking, ("SC1_MIP", False, None, 1))
print "Compute symbolic execution on a PCG",
try_property(PCG.is_dead_lock)
try:
os.remove("gurobi.log")
except OSError:
pass