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

This commit is contained in:
leo 2023-02-08 01:13:30 +01:00
parent e34922d6e5
commit 6782702f16
Signed by: wanderer
SSH Key Fingerprint: SHA256:Dp8+iwKHSlrMEHzE3bJnPng70I7LEsa3IJXRH/U+idQ

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