-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAlgorithmExecutes.py
More file actions
94 lines (76 loc) · 3.37 KB
/
AlgorithmExecutes.py
File metadata and controls
94 lines (76 loc) · 3.37 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
import numpy as np
from Functions import Functions
# Used for executing individual algorithms and generating corresponding gif
class AlgorithmExecutes:
@staticmethod
def sphere(alg, generations = 1000, population = 10, method_display="3d", *other):
algorithm = alg(Functions.Sphere, -10, 10, 2, "Sphere")
algorithm.execute(generations, population, *other)
if method_display == "3d":
algorithm.animate_result()
else:
algorithm.animate_heatmap()
@staticmethod
def ashley(alg, generations = 1000, population = 10, method_display="3d", *other):
algorithm = alg(Functions.Ackley, -40, 40, 2, "Ackley")
algorithm.execute(generations, population, *other)
if method_display == "3d":
algorithm.animate_result()
else:
algorithm.animate_heatmap()
@staticmethod
def rastrigin(alg, generations = 1000, population = 10, method_display="3d", *other):
algorithm = alg(Functions.Rastrigin, -5, 5, 2, "Rastrigin")
algorithm.execute(generations, population, *other)
if method_display == "3d":
algorithm.animate_result()
else:
algorithm.animate_heatmap()
@staticmethod
def rosenbrock(alg, generations = 1000, population = 10, method_display="3d", *other):
algorithm = alg(Functions.Rosenbrock, -6, 6, 2, "Rosenbrock")
algorithm.execute(generations, population, *other)
if method_display == "3d":
algorithm.animate_result()
else:
algorithm.animate_heatmap()
@staticmethod
def griewank(alg, generations = 1000, population = 10, method_display="3d", *other):
algorithm = alg(Functions.Griewank, -5, 5, 2, "Griewank")
algorithm.execute(generations, population, *other)
if method_display == "3d":
algorithm.animate_result(wired=True)
else:
algorithm.animate_heatmap()
@staticmethod
def schwefel(alg, generations = 1000, population = 10, method_display="3d", *other):
algorithm = alg(Functions.Schwefel, -500, 500, 2, "Schwefel")
algorithm.execute(generations, population, *other)
if method_display == "3d":
algorithm.animate_result(wired=True)
else:
algorithm.animate_heatmap()
@staticmethod
def levy(alg, generations = 1000, population = 10, method_display="3d", *other):
algorithm = alg(Functions.Levy, -10, 10, 2, "Levy")
algorithm.execute(generations, population, *other)
if method_display == "3d":
algorithm.animate_result()
else:
algorithm.animate_heatmap()
@staticmethod
def michelewicz(alg, generations = 1000, population = 10, method_display="3d", *other):
algorithm = alg(Functions.Michelewicz, 0, np.pi, 2, "Michelewicz")
algorithm.execute(generations, population, *other)
if method_display == "3d":
algorithm.animate_result(wired=True)
else:
algorithm.animate_heatmap()
@staticmethod
def zakharow(alg, generations = 1000, population = 10, method_display="3d", *other):
algorithm = alg(Functions.Zakharow, -10, 10, 2, "Zakharow")
algorithm.execute(generations, population, *other)
if method_display == "3d":
algorithm.animate_result()
else:
algorithm.animate_heatmap()