From 3922e86625d82ed5874c6989e1bf1ff5322f9632 Mon Sep 17 00:00:00 2001 From: leo Date: Mon, 6 Feb 2023 22:25:49 +0100 Subject: [PATCH] cec2020: implement Schaffer func --- bench/cec2020/basicFunctions.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bench/cec2020/basicFunctions.go b/bench/cec2020/basicFunctions.go index 5f01d3d..9d2a213 100644 --- a/bench/cec2020/basicFunctions.go +++ b/bench/cec2020/basicFunctions.go @@ -162,8 +162,13 @@ func SchwefelModified(x []float64) float64 { return 418.9829*fnx - sum } -// Schaffer is the "Expanded Schaffer's Function" of CEC2020. -func Schaffer(x []float64) float64 { return 0 } +// Schaffer is the Schaffer's function. +func Schaffer(x, y float64) float64 { + return 0.5 + (math.Pow(math.Sin(math.Sqrt(math.Pow(x, 2)+math.Pow(y, 2))-0.5), 2) / (1 + 0.001*(math.Pow(x, 2)+math.Pow(y, 2)))) +} + +// SchafferExpanded is the "Expanded Schaffer's Function" of CEC2020. +func SchafferExpanded(x []float64) float64 { return 0 } // Weierstrass is the "Weierstrass Function" of CEC2020 with a=0.5, b=3 and // kmax=20.