added schaffer2 function
added output for improvement of fitness added CMAES algorithm, that requires further testing
This commit is contained in:
18
functions.py
18
functions.py
@@ -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__(
|
||||
|
||||
Reference in New Issue
Block a user