-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgraph_ga_ids.py
More file actions
66 lines (50 loc) · 1.82 KB
/
Copy pathgraph_ga_ids.py
File metadata and controls
66 lines (50 loc) · 1.82 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
from matplotlib import pyplot as plt
import numpy as np
from scipy.optimize import curve_fit
import csv
score_array_1 = []
time_array_1 = []
score_array_2 = []
time_array_2 = []
with open('ga_log_pop500.csv') as csv_file:
csv_reader = csv.reader(csv_file, delimiter=',')
header = next(csv_reader)
for i in csv_reader:
# get lowest score from list
temp_score = i[1]
temp_score = temp_score[1:-1:]
temp_score = temp_score.split('),')
temp_lowest = temp_score[0][1::].split(',')
score_array_1.append(int(temp_lowest[1]))
# get time
time_array_1.append(float(i[4]))
with open('depth_log_pop500.csv') as csv_file:
csv_reader = csv.reader(csv_file, delimiter=',')
header = next(csv_reader)
for i in csv_reader:
# get lowest score from list
temp_score = i[3]
temp_score = temp_score[1:-1:]
temp_score = temp_score.split('),')
temp_lowest = temp_score[0][1::].split(',')
score_array_2.append(int(temp_lowest[1]))
# get time
time_array_2.append(float(i[6]))
x1 = np.array(time_array_1)
y1 = np.array(score_array_1)
x2 = np.array(time_array_2)
y2 = np.array(score_array_2)
def func(x, a, b, c):
return a*np.exp(-b*x) + c
# popt1, pcov1 = curve_fit(func, x1, y1)
# popt2, pcov2 = curve_fit(func, x2, y2)
plt.figure(figsize=(8, 6))
ga100_data = plt.plot(x1, y1, label="GA (Population: 500)")
idsga100_data = plt.plot(x2, y2, label="IDS-GA (Population: 500)")
# f1 = plt.plot(x1, func(x1, popt1[0], popt1[1], popt1[2]), label="Fitted Curve (GA POP100)")
# f2 = plt.plot(x2, func(x2, popt2[0], popt2[1], popt2[2]), label="Fitted Curve (GA POP500)")
plt.xlabel("Time (s)")
plt.ylabel("Fitness Score (Lower is Better)")
plt.title("GA (Population: 500) vs IDSGA (Population: 500)")
plt.legend()
plt.show()