From a9135c535fabd3962237724044e8dcddcadce990 Mon Sep 17 00:00:00 2001 From: leo Date: Wed, 8 Feb 2023 01:14:33 +0100 Subject: [PATCH] cec2020: implement Hybrid3 func --- bench/cec2020/benchFunctions.go | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/bench/cec2020/benchFunctions.go b/bench/cec2020/benchFunctions.go index 02836cf..5f9938f 100644 --- a/bench/cec2020/benchFunctions.go +++ b/bench/cec2020/benchFunctions.go @@ -156,7 +156,32 @@ func Hybrid2(x []float64) float64 { } // Hybrid3 is the "Hybrid Function 3" of CEC2020. -func Hybrid3(x []float64) float64 { return 0 } +func Hybrid3(x []float64) float64 { + nx := len(x) + fnx := float64(nx) + + funcs := []func([]float64) float64{ + SchafferExpanded, + HGBat, + Rosenbrock, + SchwefelModified, + HighConditionedElliptic, + } + // percentages used to control the amount of contribution of each func. + p := []float64{0.1, 0.2, 0.2, 0.2, 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 +} // Composition1 is the "Composition Function 1" of CEC2020. func Composition1(x []float64) float64 { return 0 }