-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
57 lines (41 loc) · 1.75 KB
/
run.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
import os
import sys
import diameter
import bmc
import time
compute_diameter = diameter.compute_diameter
bounded_model_checking = bmc.bounded_model_checking
alg_list = [alg[:-3] for alg in os.listdir("algorithms") if alg[-3:] == ".py" and alg[0] != "_"]
alg_list.sort()
solver = ""
if len(sys.argv) != 2:
print("Usage: python run.py 'solver'")
exit()
else:
solver = sys.argv[1].strip()
if solver != "cvc4" and solver != "z3":
print("Currently the only supported solvers are cvc4 and z3")
exit()
output = open("output_" + solver + ".txt", "w")
output.write("Experimental results for bounded model checking with the " + solver + " SMT solver\n")
output.write("Diameter computed using SMT solver\n\n")
for alg in alg_list:
print("Checking " + alg + " with " + solver + " ...\n")
output.write("Algorithm " + alg + "\n")
start = time.time()
err, diam = compute_diameter(alg, "algorithms", solver, 0, 5)
diam_time = time.time() - start
print("Diameter " + str(diam) + "\n")
pretty_time = "%s%s" % (time.strftime("%H:%M:%S", time.gmtime(diam_time)), str(diam_time)[str(diam_time).index("."):8])
output.write("diameter: \t" + str(diam) + "\n\ttime to compute diameter: \t" + pretty_time + "\n\n")
output.write("bounded model checking results:\n")
start = time.time()
result = bounded_model_checking(alg, "algorithms", solver, diam)
bmc_time = time.time() - start
print(result)
output.write(result)
pretty_time = "%s%s" % (time.strftime("%H:%M:%S", time.gmtime(bmc_time)), str(bmc_time)[str(bmc_time).index("."):8])
output.write("\ttime to check properties: \t" + pretty_time + "\n\n")
print(alg + " done!\n\n")
output.close()
print("Results found in output_" +solver + ".txt\n")