-
Notifications
You must be signed in to change notification settings - Fork 1
/
ibexopt_multicore_solver.py
64 lines (48 loc) · 1.96 KB
/
ibexopt_multicore_solver.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
from multiprocessing import Process
import multiprocessing
import os
import subprocess
import csv
import pandas as pd
#--------------CONFIGURATION HALL -------------
seed_Inicial=1
seed_Final=4
timeout=1
precision=0.001
criteria="testo"
path_to_benchs="/home/nico/codes/benchmarks/experiment_set.txt"
# results_tests='/home/nico/codes/benchmarks/dataset_set.txt'
ibexopt="/home/nico/Ibex/ibex-2.8.9/__build__/src/ibexopt"
csv_file="benchmarks/MC-4/benchmark_{0}.csv".format(criteria)
# ---------------------------------------------
# print("Number of cpu : ", multiprocessing.cpu_count())
def echo_sys(bench,seed_Inicial,seed_Final,timeout,ibexopt):
results=[]
for i in range(seed_Inicial,seed_Final+1):
cmd="{0} {1} --random-seed={2} --timeout={3}".format(ibexopt,bench,i,timeout)
output = subprocess.Popen( cmd, stdout=subprocess.PIPE, shell=True ).communicate()[0]
print(bench+" "+str(i)+" done")
output=output.decode("utf-8")
output=output.split('\n')
results.append([bench,i,output[-2],timeout,output[-3],output[-4],output[-5],output[-6],output[-7]])
df=pd.DataFrame(results)
df.to_csv(csv_file, mode='a', index=False, header=False)
if __name__ == "__main__": # confirms that the code is under main function
files=[]
with open(path_to_benchs,'r') as file:
for line in file:
files.append(line.strip('\n'))
#create csv of benchmarks set
headers=["File","Seed","Nodes",'Timeout',"Time","Relative precision","Simplex time","ANN time","Linearization time"]
with open(csv_file, "a", newline="") as file:
writer = csv.writer(file)
writer.writerow(headers)
procs = []
# instantiating process with arguments
for file in files:
proc = Process(target=echo_sys, args=(file,seed_Inicial,seed_Final,timeout,ibexopt,))
procs.append(proc)
proc.start()
# complete the processes
for proc in procs:
proc.join()