cec2020: implement Composition3 func
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
be349f689b
commit
7c8c17007a
@ -265,4 +265,43 @@ func Composition2(x []float64) float64 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Composition3 is the "Composition Function 3" of CEC2020.
|
// Composition3 is the "Composition Function 3" of CEC2020.
|
||||||
func Composition3(x []float64) float64 { return 0 }
|
func Composition3(x []float64) float64 {
|
||||||
|
nx := len(x)
|
||||||
|
fnx := float64(nx)
|
||||||
|
|
||||||
|
// optimum positions.
|
||||||
|
o := newOpt(nx)
|
||||||
|
sigma := []float64{10, 20, 30, 40, 50}
|
||||||
|
lambda := []float64{10, 1, 10, 1e-6, 1}
|
||||||
|
bias := []float64{0, 100, 200, 300, 400}
|
||||||
|
omega := make([]float64, nx)
|
||||||
|
funcs := []func([]float64) float64{
|
||||||
|
Rastrigin,
|
||||||
|
Happycat,
|
||||||
|
Ackley,
|
||||||
|
Discus,
|
||||||
|
Rosenbrock,
|
||||||
|
}
|
||||||
|
|
||||||
|
var sum float64
|
||||||
|
|
||||||
|
var weights []float64
|
||||||
|
|
||||||
|
for i := range funcs {
|
||||||
|
wi := getWeight(x, o, sigma[i], fnx)
|
||||||
|
|
||||||
|
weights = append(weights, wi)
|
||||||
|
|
||||||
|
var wsum float64
|
||||||
|
|
||||||
|
for j := range weights {
|
||||||
|
wsum += weights[j]
|
||||||
|
}
|
||||||
|
|
||||||
|
omega = append(omega, wi/wsum)
|
||||||
|
|
||||||
|
sum += (omega[i] * (lambda[i]*funcs[i](x) + bias[i])) + funcs[i](x)
|
||||||
|
}
|
||||||
|
|
||||||
|
return sum
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user