-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvisualization.py
More file actions
105 lines (84 loc) · 2.62 KB
/
visualization.py
File metadata and controls
105 lines (84 loc) · 2.62 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
from Individual import Individual
from GP import GP
import matplotlib.pyplot as plt
"""Generates the figures used in the README"""
def four_initial_example():
ind1 = Individual(200,200)
ind2 = Individual(200,200)
ind3 = Individual(200,200)
ind4 = Individual(200,200)
f, axarr = plt.subplots(2,2)
axarr[0,0].imshow(ind1.image)
axarr[0,0].set_title("Initial Individual 1")
axarr[0,1].imshow(ind2.image)
axarr[0,1].set_title("Initial Individual 2")
axarr[1,0].imshow(ind3.image)
axarr[1,0].set_title("Initial Individual 3")
axarr[1,1].imshow(ind4.image)
axarr[1,1].set_title("Initial Individual 4")
plt.show()
def crossover_illustration():
ind1 = Individual(200,200)
ind2 = Individual(200,200)
gp = GP(r"davidson3.png")
child1 = gp.crossover(ind1,ind2)
f, axarr = plt.subplots(1,3)
axarr[0].imshow(ind1.image)
axarr[0].set_title("Parent 1")
axarr[1].imshow(ind2.image)
axarr[1].set_title("Parent 2")
axarr[2].imshow(child1.image)
axarr[2].set_title("Child")
plt.show()
child2 = gp.crossover_2(ind1,ind2)
f, axarr = plt.subplots(1,3)
axarr[0].imshow(ind1.image)
axarr[0].set_title("Parent 1")
axarr[1].imshow(ind2.image)
axarr[1].set_title("Parent 2")
axarr[2].imshow(child2.image)
axarr[2].set_title("Child")
plt.show()
child3 = gp.crossover_3(ind1,ind2)
f, axarr = plt.subplots(1,3)
axarr[0].imshow(ind1.image)
axarr[0].set_title("Parent 1")
axarr[1].imshow(ind2.image)
axarr[1].set_title("Parent 2")
axarr[2].imshow(child3.image)
axarr[2].set_title("Child")
plt.show()
def mutation_illustration():
ind1 = Individual(200,200)
ind2 = Individual(200,200)
gp = GP(r"davidson3.png")
f, axarr = plt.subplots(1,2)
axarr[0].imshow(ind1.image)
axarr[0].set_title("Pre-Mutation")
# mutate
gp.mutate(ind1)
axarr[1].imshow(ind1.image)
axarr[1].set_title("Post-Mutation")
plt.show()
f, axarr = plt.subplots(1,2)
axarr[0].imshow(ind2.image)
axarr[0].set_title("Pre-Mutation")
# mutate
gp.mutate_2(ind2)
axarr[1].imshow(ind2.image)
axarr[1].set_title("Post-Mutation")
plt.show()
def vertical_test():
ind1 = Individual(200,200)
ind2 = Individual(200,200)
gp = GP(r"davidson3.png")
child1 = gp.crossover_2(ind1,ind2, 0.5)
f, axarr = plt.subplots(1,3)
axarr[0].imshow(ind1.image)
axarr[0].set_title("Parent 1")
axarr[1].imshow(ind2.image)
axarr[1].set_title("Parent 2")
axarr[2].imshow(child1.image)
axarr[2].set_title("Child")
plt.show()
vertical_test()