-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathlong_csv_program_sizes.py
executable file
·69 lines (44 loc) · 1.99 KB
/
long_csv_program_sizes.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
#!/usr/bin/python
import os
from sys import maxint
# Set these before running:
######## For GPTP Plush Paper
dirs = [("Replace Space With Newline", "Results/bench-prog-synth/replace-space-with-newline/parent-selection/lexicase/"),
("Syllables", "Results/bench-prog-synth/syllables/parent-selection/lexicase/"),
("Negative To Zero", "Results/bench-prog-synth/negative-to-zero/parent-selection/lexicase/"),
("X-Word Lines", "Results/bench-prog-synth/x-word-lines/parent-selection/lexicase/"),
("Count Odds", "Results/bench-prog-synth/count-odds/parent-selection/lexicase/")]
outputFilePrefix = "log"
outputFileSuffix = ".txt"
# Main area
def printSizesLong(method, outputDirectory):
run_num = 0
if outputDirectory[-1] != '/':
outputDirectory += '/'
dirList = os.listdir(outputDirectory)
while (outputFilePrefix + str(run_num) + outputFileSuffix) in dirList:
fileName = (outputFilePrefix + str(run_num) + outputFileSuffix)
f = open(outputDirectory + fileName)
gen = 0
done = False
behavioral_diversity = -1
point_evals = -1
for line in f:
if line.startswith(";; -*- Report"):
gen = int(line.split()[-1])
if line.startswith("Average genome size in population (length):"):
mean_genome_size = float(line.split()[-1])
if line.startswith("Average program size in population (points):"):
mean_program_size = float(line.split()[-1])
print "%s,%i,%i,%0.3f,%0.3f" % (method, run_num, gen, mean_genome_size, mean_program_size)
if line.startswith("SUCCESS"):
done = "SUCCESS"
break
if line.startswith("FAILURE"):
done = "FAILURE"
break
run_num += 1
return
print "method,trial,generation,mean_genome_size,mean_program_size"
for (method, directory) in dirs:
printSizesLong(method, directory)