cec2020: implement Happycat 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
ba0f4ff8b4
commit
9795287dc9
@ -80,7 +80,28 @@ func Griewank(x []float64) float64 {
|
|||||||
func Ackley(x []float64) float64 { return 0 }
|
func Ackley(x []float64) float64 { return 0 }
|
||||||
|
|
||||||
// Happycat is the "Happycat Function" of CEC2020.
|
// Happycat is the "Happycat Function" of CEC2020.
|
||||||
func Happycat(x []float64) float64 { return 0 }
|
func Happycat(x []float64) float64 {
|
||||||
|
var sum1 float64
|
||||||
|
|
||||||
|
var sum2 float64
|
||||||
|
|
||||||
|
var sum3 float64
|
||||||
|
|
||||||
|
// float64 version of the length of x.
|
||||||
|
fnx := float64(len(x))
|
||||||
|
|
||||||
|
for i := range x {
|
||||||
|
xipow2 := math.Pow(x[i], 2)
|
||||||
|
|
||||||
|
sum1 += xipow2 - fnx
|
||||||
|
|
||||||
|
sum2 += xipow2
|
||||||
|
|
||||||
|
sum3 += x[i]
|
||||||
|
}
|
||||||
|
|
||||||
|
return math.Pow(math.Abs(sum1), 0.25) + (((0.5 * sum2) + sum3) / (fnx + 0.5))
|
||||||
|
}
|
||||||
|
|
||||||
// Discus is the "Discus Function" of CEC2020.
|
// Discus is the "Discus Function" of CEC2020.
|
||||||
func Discus(x []float64) float64 {
|
func Discus(x []float64) float64 {
|
||||||
|
Loading…
Reference in New Issue
Block a user