diff --git a/bench/cec2020/basicFunctions.go b/bench/cec2020/basicFunctions.go index 0c7a15d..3677473 100644 --- a/bench/cec2020/basicFunctions.go +++ b/bench/cec2020/basicFunctions.go @@ -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