-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrunReluplex.py
76 lines (61 loc) · 1.88 KB
/
runReluplex.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
import sys
from reluplexFunctions import checkRegionConfig, checkRegion
from advisoryParams import *
import multiprocessing
import os
import time
'''
Check an advisory from config file
'''
def runConfig():
cfg_file = "./reluplex.cfg"
if len(sys.argv)>1:
cfg_file = sys.argv[1]
checkRegionConfig(cfg_file)
'''
Run convergence experiments on different threads
'''
def runExpConv(pra):
ras = getPossibleAdvisories(advInd(pra))
overApprox = False
dts = [0.125, 0.25, 0.5, 1, 2]
threads = []
vmin = float(-100.)
vmax = float(100.)
deltaV = float(2.)
eps = 1
dti = float(0.0625)
pd = 0
pra = advInd(pra)
verbose = False
# Create Threads to run for the convergence problem
for dt in dts:
for ra in ras:
dt = float(dt)
# Build Folder Name
if overApprox:
s = "overApprox"
else:
s = "underApprox"
# Make the folder to hold results
folder = "res_%s_dt%.3f_dti0.0625_v4"%(s, dt)
if not os.path.exists(folder):
os.mkdir(folder)
# Creating separate threads
threads += [multiprocessing.Process(target=checkRegion,
args=(pra,ra,vmin,vmax,deltaV,eps,pd,overApprox,dt,dti,folder,verbose))]
print("Running %d threads ...."%(len(threads)))
# Start all threads
for t in threads:
t.start()
# Wait until threads are complete
for t in threads:
t.join()
if __name__== "__main__":
pra = "COC"
if advInd(pra) == -1:
print("ERROR: %s is a invalid advisory!"%pra)
exit(1)
start_time = time.time() # Start timer
runExpConv(pra)
print("------ Finished running in %s seconds ------"%(time.time() - start_time))