cec2020: implement Ackley func
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
9795287dc9
commit
83a8c94ea9
@ -77,7 +77,22 @@ func Griewank(x []float64) float64 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Ackley is the "Ackley's Function" of CEC2020.
|
// Ackley is the "Ackley's Function" of CEC2020.
|
||||||
func Ackley(x []float64) float64 { return 0 }
|
func Ackley(x []float64) float64 {
|
||||||
|
var sum1 float64
|
||||||
|
|
||||||
|
var sum2 float64
|
||||||
|
|
||||||
|
for i := range x {
|
||||||
|
sum1 += math.Pow(x[i], 2)
|
||||||
|
|
||||||
|
sum2 += math.Cos(2 * math.Pi * x[i])
|
||||||
|
}
|
||||||
|
|
||||||
|
// float64 version of the length of x.
|
||||||
|
fnx := float64(len(x))
|
||||||
|
|
||||||
|
return -20*math.Exp(-0.2*math.Sqrt((1/fnx)*sum1)) - math.Exp((1/fnx)*sum2) + 20 + math.E
|
||||||
|
}
|
||||||
|
|
||||||
// Happycat is the "Happycat Function" of CEC2020.
|
// Happycat is the "Happycat Function" of CEC2020.
|
||||||
func Happycat(x []float64) float64 {
|
func Happycat(x []float64) float64 {
|
||||||
|
Loading…
Reference in New Issue
Block a user