-
Notifications
You must be signed in to change notification settings - Fork 0
/
happycat.py
40 lines (27 loc) · 984 Bytes
/
happycat.py
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
"""
File: happycat.py
By Peter Caven, [email protected]
Description:
HappyCat test function for the Stepping Stone Search Algorithm.
See: "HappyCat – A Simple Function Class Where Well-Known Direct Search Algorithms Do Fail",
by Hans-Georg Beyer and Steffen Finck, 2012
"""
import numpy
from numpy import *
from sss import Optimize
def HappyCat(x, alpha=1/8):
X = dot(x,x)
N = len(x)
return ((X - N)**2)**alpha + (X/2.0 + sum(x))/N + 0.5
optimum = Optimize( HappyCat,
dimensions = 10,
lowerDomain = -2.0,
upperDomain = 2.0,
maxMutations = 3,
maxIndexes = 1,
gamma = 0.99999,
minImprovements = 2,
popSize = 20,
maxIterations = 1000000,
targetLoss = 1.0e-5)
print(f"\nSolution:\n{optimum.rep}")