-
Notifications
You must be signed in to change notification settings - Fork 6
/
hits.py
executable file
·99 lines (71 loc) · 2.84 KB
/
hits.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/usr/bin/python
#import math
import os
from sys import maxint
# Set these before running:
#outputDirectory = "Results/gecco13/pagie-normal/"
#outputDirectory = "Results/gecco13/pagie-ultra/"
#outputDirectory = "Results/gecco13/pagie-no-erc-normal/"
#outputDirectory = "Results/gecco13/pagie-hogeweg-no-erc-45/"
#outputDirectory = "Results/gecco13/pagie-no-erc-ultra/" #Uses non-equal size ULTRA
#outputDirectory = "Results/gecco13/equal-size-ULTRA/pagie-no-erc/"
#outputDirectory = "Results/GECCO14/order-lexicase/pagie-946/"
#outputDirectory = "Results/GECCO14/order-lexicase/pagie-895/"
#outputDirectory = "Results/GECCO14/order-lexicase/pagie-80/"
#outputDirectory = "Results/GECCO14/order-lexicase/pagie-64/"
#outputDirectory = "Results/GECCO14/order-lexicase/pagie-464/"
#outputDirectory = "Results/ULTRA-redo/pagie/subtree-80-10-10/"
#outputDirectory = "Results/ULTRA-redo/pagie/subtree-45-45-10/"
#outputDirectory = "Results/ULTRA-redo/pagie/ultra/"
#outputDirectory = "Results/padding-ultra/pagie/padding/"
#outputDirectory = "Results/padding-ultra/pagie/padding200/"
#outputDirectory = "Results/padding-ultra/pagie/padding150/"
#outputDirectory = "Results/padding-ultra/pagie/padding-bug-finding/"
outputDirectory = "Results/padding-ultra/pagie/fixed-padding/"
outputFilePrefix = "log"
outputFileSuffix = ".txt"
#outputFilePrefix = "bio-ultralog"
#outputFilePrefix = "bio-normallog"
errorType = "float"
# Main area
i = 0
if outputDirectory[-1] != '/':
outputDirectory += '/'
dirList = os.listdir(outputDirectory)
bestFitnessesOfRuns = []
while (outputFilePrefix + str(i) + outputFileSuffix) in dirList:
#sys.stdout.write('.')
#if i % 50 == 49:
# print
runs = i + 1 # After this loop ends, runs should be correct
fileName = (outputFilePrefix + str(i) + outputFileSuffix)
f = open(outputDirectory + fileName)
#final = False
gen = 0
best_hits = maxint
best_mean_error = maxint
done = False
for line in f:
try:
if line.startswith(";; -*- Report"):
gen = int(line.split()[-1])
if line.startswith("SUCCESS") or line.startswith("FAILURE"):
done = True
if line.startswith("Best's total error (hits)"):
gen_hits = int(line.split()[-1])
if gen_hits < best_hits:
best_hits = gen_hits
except ValueError:
print "ERROR: " + line
bestFitnessesOfRuns.append((gen, best_hits, done))
i += 1
#print
#print "Best fitnesses of runs:"
for i, (gen, hits, done) in enumerate(bestFitnessesOfRuns):
print "Run: %3i | Gen: %4i | Best Hits = %i" % (i, gen, hits)
success_hits = 0
for (gen, hits, done) in bestFitnessesOfRuns:
if hits == 0:
success_hits += 1
print "-----"
print "Number of successful runs based on hits: %i" % success_hits