-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathlong_csv_number_cases_over_generations.py
More file actions
79 lines (49 loc) · 1.84 KB
/
long_csv_number_cases_over_generations.py
File metadata and controls
79 lines (49 loc) · 1.84 KB
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
73
74
75
76
77
78
import os, sys
problems = ["compare-string-lengths",
"double-letters",
"replace-space-with-newline",
"string-lengths-backwards",
"last-index-of-zero",
"vector-average",
"mirror-image",
"x-word-lines",
"negative-to-zero",
"scrabble-score",
"smallest",
"syllables"
]
basedir = "/home/thelmuth/Collab/thelmuth/Results/counterexample-driven-gp/no-generational-case-additions/%s/"
#basedir = "/home/thelmuth/Collab/thelmuth/Results/counterexample-driven-gp/add-case-after-50-gens/%s/"
dirs = []
for problem in problems:
tup = (problem, basedir % problem)
dirs.append(tup)
# Don't change below here.
outputFilePrefix = "log"
outputFileSuffix = ".txt"
def print_active_cases_long(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
for line in f:
if line.startswith(";; -*- Report"):
gen = int(line.split()[-1])
if line.startswith("Number of cases this gen"):
active_cases = int(line.split()[-1])
print("%s,%i,%i,%i" % (method, run_num, gen, active_cases))
if line.startswith("SUCCESS"):
done = "SUCCESS"
break
if line.startswith("FAILURE"):
done = "FAILURE"
break
run_num += 1
print("method,trial,generation,active_cases")
for (method, directory) in dirs:
print(method, file=sys.stderr)
print_active_cases_long(method, directory)