-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetPlotPython.py
59 lines (46 loc) · 1.62 KB
/
getPlotPython.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
import os
import matplotlib.pyplot as plt
import numpy as np
os.system('javac -cp contest.jar player36.java Individual.java Population.java')
print(" (0) BentCigarFunction \n (1) Schaffers F17 \n (2) Katsuura \n Type your choice: ", end="")
what_function = int(input())
total = 0
maxi = 0
mini = 10
for i in range(0,1):
if what_function == 0:
java_output = os.popen('java -jar testrun.jar -submission=player36 -evaluation=BentCigarFunction -seed=1').read()
elif what_function == 1:
java_output = os.popen('java -jar testrun.jar -submission=player36 -evaluation=SchaffersEvaluation -seed=1').read()
elif what_function == 2:
java_output = os.popen('java -jar testrun.jar -submission=player36 -evaluation=KatsuuraEvaluation -seed=1').read()
else:
print("Dumbass, you couldn't complete the task of typing 0, 1 or 2")
exit(1);
score = float(java_output.split('\n')[-3].split(' ')[1])
total = total + score
print(score)
if score > maxi:
maxi = score
if score < mini:
mini = score
# avg = total/n
# print('Average:\t',avg)
# print('Maximum:\t',maxi)
# print('Minimum:\t',mini)
avg_array = []
best_array = []
for line in java_output.split('\n'):
if line.startswith("avg:"):
# avg_array.append(float(line[5:20].strip()))
# print(float(line.split(' ')[1]))
avg_array.append(float(line.split(' ')[1]))
elif line.startswith("best"):
# best_array.append(float(line[6:20].strip()))
# best_array.append(float(line[6:20].strip()))
# print(float(line.split(' ')[1]))
best_array.append(float(line.split(' ')[1]))
plt.plot(avg_array, color="C1", label="avg")
plt.plot(best_array, color="C0", label="best")
plt.legend()
plt.show()