diff --git a/bench/cec2020/benchFunctions.go b/bench/cec2020/benchFunctions.go index 678eabc..02836cf 100644 --- a/bench/cec2020/benchFunctions.go +++ b/bench/cec2020/benchFunctions.go @@ -129,7 +129,31 @@ func Hybrid1(x []float64) float64 { } // Hybrid2 is the "Hybrid Function 2" of CEC2020. -func Hybrid2(x []float64) float64 { return 0 } +func Hybrid2(x []float64) float64 { + nx := len(x) + fnx := float64(nx) + + funcs := []func([]float64) float64{ + SchafferExpanded, + HGBat, + Rosenbrock, + SchwefelModified, + } + // percentages used to control the amount of contribution of each func. + p := []float64{0.2, 0.2, 0.3, 0.3} + gnx := getGnx(p, fnx) + + z := newOpt(nx) + mz := getMz(x, z) + + var sum float64 + + for i := range funcs { + sum += funcs[i](mz) * gnx[i] + } + + return sum +} // Hybrid3 is the "Hybrid Function 3" of CEC2020. func Hybrid3(x []float64) float64 { return 0 }