cec2020: implement HGBat func
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
leo 2023-02-06 15:30:59 +01:00
parent ce615d8a26
commit de1b2021c5
Signed by: wanderer
SSH Key Fingerprint: SHA256:Dp8+iwKHSlrMEHzE3bJnPng70I7LEsa3IJXRH/U+idQ

@ -32,7 +32,22 @@ func HighConditionedElliptic(x []float64) float64 {
}
// HGBat is the "HGBat Function" of CEC2020.
func HGBat(x []float64) float64 { return 0 }
func HGBat(x []float64) float64 {
var sum1 float64
var sum2 float64
for i := range x {
sum1 += math.Pow(x[i], 2)
sum2 += x[i]
}
// float64 version of the length of x.
fnx := float64(len(x))
return math.Pow(math.Abs(math.Pow(sum1, 2)-math.Pow(sum2, 2)), 0.5) + (((0.5 * sum1) + sum2) / (fnx + 0.5))
}
// Rosenbrock is the "Rosenbrock's Function" of CEC2020.
// ref: https://infinity77.net/global_optimization/test_functions_nd_R.html#go_benchmark.Rosenbrock