-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathsuccess_programs.py
executable file
·62 lines (45 loc) · 1.53 KB
/
success_programs.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
import math
import os
import sys
# Set these before running:
outputDirectory = "Collab/aabdelha/results/last-index-of-zero10p/lexicase/last-index-of-zero/"
outputDirectory = "Collab/aabdelha/results/scrabble-score10p/lexicase/scrabble-score/"
outputFilePrefix = "log"
outputFileSuffix = ".txt"
# Don't have to change anything below!
verbose = True
if(len(sys.argv) > 1):
verbose = False
if outputDirectory[-1] != '/':
outputDirectory += '/'
dirList = os.listdir(outputDirectory)
i = 0
while (outputFilePrefix + str(i) + outputFileSuffix) in dirList:
fileName = (outputFilePrefix + str(i) + outputFileSuffix)
f = open(outputDirectory + fileName)
success = False
simpl = False
if verbose:
print
print "-------------------------------------------------"
print "------------------ Run %i ------------------------" % i
print
testForBest = 5
for line in f:
if line.startswith("Successful program: "):
if verbose:
print line
print
else:
if sys.argv[1] != "test" or testForBest == 0:
print line[len("Successful program: "):-1]
success = True
if simpl == True and verbose:
print "Simplification after 1000 steps:"
print line
break
if success and line.startswith("step: 1000"):
simpl = True
if line.startswith("Test total error for best:"):
testForBest = int(line.split()[-1].strip("Nn"))
i += 1