cec2020: implement Rosenbrock func
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
leo 2023-02-05 13:16:58 +01:00
parent 6b20fc8ea5
commit d835714dfd
Signed by: wanderer
SSH Key Fingerprint: SHA256:Dp8+iwKHSlrMEHzE3bJnPng70I7LEsa3IJXRH/U+idQ

@ -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