From d835714dfd3ff3a8c9051a9f0b540ce9051549c2 Mon Sep 17 00:00:00 2001 From: leo Date: Sun, 5 Feb 2023 13:16:58 +0100 Subject: [PATCH] cec2020: implement Rosenbrock func --- bench/cec2020/basicFunctions.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/bench/cec2020/basicFunctions.go b/bench/cec2020/basicFunctions.go index 96bbae9..98682bd 100644 --- a/bench/cec2020/basicFunctions.go +++ b/bench/cec2020/basicFunctions.go @@ -16,7 +16,16 @@ func HighConditionedElliptic(x []float64) float64 { return 0 } func HGBat(x []float64) float64 { return 0 } // Rosenbrock is the "Rosenbrock's Function" of CEC2020. -func Rosenbrock(x []float64) float64 { return 0 } +// ref: https://infinity77.net/global_optimization/test_functions_nd_R.html#go_benchmark.Rosenbrock +func Rosenbrock(x []float64) float64 { + var sum float64 + + for i := 0; i < len(x)-1; i++ { + sum += 100*(math.Pow(math.Pow(x[i], 2)-x[i+1], 2)) + math.Pow(x[i]-1, 2) + } + + return sum +} // Griewank is the "Griewank's Function" of CEC2020. // ref: https://www.sfu.ca/~ssurjano/griewank.html