added schaffer2 function

added output for improvement of fitness
added CMAES algorithm, that requires further testing
This commit is contained in:
Daniel Lukats
2019-09-23 14:11:46 +02:00
parent 93e9234ce6
commit 14c7756802
4 changed files with 97 additions and 42 deletions

View File

@@ -17,17 +17,29 @@ class Function:
X, Y = np.meshgrid(x, y)
return x, y, self.eval(X, Y)
class Rastrigin(Function):
def __init__(self, A: int = 10):
super().__init__(
xlim=(-5.12, 5.12),
ylim=(-5.12, 5.12),
xlim=(-6.12, 6.12),
ylim=(-6.12, 6.12),
minimum=(0, 0),
eval=lambda x, y: self.A * 2 + \
(x**2 - self.A * np.cos(2 * np.pi * x)) + \
(y**2 - self.A * np.cos(2 * np.pi * y)))
self.A = A
class Schaffer2(Function):
def __init__(self):
super().__init__(
xlim=(-50, 50),
ylim=(-50, 50),
minimum=(0, 0),
eval=lambda x, y: 0.5 + \
(np.sin(x**2 - y**2)**2 - 0.5) / \
((1 + 0.001 * (x**2 + y**2))**2))
class Sphere(Function):
def __init__(self):
super().__init__(