forked from thelmuth/Clojush-Tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimplification_experiments.py
executable file
·57 lines (40 loc) · 1.55 KB
/
simplification_experiments.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 math
import os
import sys
# Set these before running:
#outputDirectory = "Results/GECCO14/simplification/dm3-simplified/"
#outputDirectory = "Results/GECCO14/simplification/odd-simplified/"
#outputDirectory = "Results/GECCO14/simplification/pagie-simplified/"
outputDirectory = "Results/GECCO14/simplification/wc-simplified/"
outputFilePrefix = "log"
outputFileSuffix = ".txt"
# Don't have to change anything below!
if outputDirectory[-1] != '/':
outputDirectory += '/'
dirList = os.listdir(outputDirectory)
starting_sizes = []
simplified_sizes = []
i = 0
while (outputFilePrefix + str(i) + outputFileSuffix) in dirList:
fileName = (outputFilePrefix + str(i) + outputFileSuffix)
f = open(outputDirectory + fileName)
program_num = 0
for line in f:
if i == 0:
if line.startswith("initial size: "):
start_size = int(line.split()[-1])
starting_sizes.append(start_size)
simplified_sizes.append([])
if line.startswith("program number:"):
program_num = int(line.split()[-1])
if line.startswith("sizes after 10000 simplifications:"):
simp_sizes = [int(x) for x in line[len("sizes after 10000 simplifications: ("):-2].split()]
simplified_sizes[program_num].extend(simp_sizes)
i += 1
for i, simp in enumerate(simplified_sizes):
sys.stdout.write("%d," % starting_sizes[i])
for j, s in enumerate(simp):
sys.stdout.write(str(s))
if j+1 != len(simp):
sys.stdout.write(",")
print