From 138e6f1d0b5d115f76eb66b7aabaaebc64d08a59 Mon Sep 17 00:00:00 2001 From: leo Date: Sun, 12 Feb 2023 14:07:34 +0100 Subject: [PATCH] fix: clear up Hybrid funcs --- bench/cec2020/benchFunctions.go | 15 +++------------ bench/cec2020/benchFunctions_test.go | 6 +++--- bench/cec2020/helperFunctions.go | 1 + 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/bench/cec2020/benchFunctions.go b/bench/cec2020/benchFunctions.go index b098c4d..d454aac 100644 --- a/bench/cec2020/benchFunctions.go +++ b/bench/cec2020/benchFunctions.go @@ -81,13 +81,10 @@ func Hybrid1(x []float64) float64 { p := []float64{0.3, 0.3, 0.4} gnx := getGnx(p, fnx) - z := newOpt(nx) - mz := getMz(x, z) - var sum float64 for i := range funcs { - sum += funcs[i](mz) * gnx[i] + sum += funcs[i](x) * gnx[i] } return sum @@ -108,13 +105,10 @@ func Hybrid2(x []float64) float64 { 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] + sum += funcs[i](x) * gnx[i] } return sum @@ -136,13 +130,10 @@ func Hybrid3(x []float64) float64 { p := []float64{0.1, 0.2, 0.2, 0.2, 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] + sum += funcs[i](x) * gnx[i] } return sum diff --git a/bench/cec2020/benchFunctions_test.go b/bench/cec2020/benchFunctions_test.go index 5f1e6b8..2fe14d3 100644 --- a/bench/cec2020/benchFunctions_test.go +++ b/bench/cec2020/benchFunctions_test.go @@ -51,7 +51,7 @@ func TestGriewank(t *testing.T) { func TestHybrid1(t *testing.T) { in := []float64{-9.2, 10, .7, 3, -80.2843} - want := 0.00025455132345086895 + want := 2.0385039193698734e+08 got := Hybrid1(in) @@ -62,7 +62,7 @@ func TestHybrid1(t *testing.T) { func TestHybrid2(t *testing.T) { in := []float64{-9.2, 10, .7, 3, -80.2843} - want := 25.298615746321026 + want := 4.6901057350488175e+06 got := Hybrid2(in) @@ -73,7 +73,7 @@ func TestHybrid2(t *testing.T) { func TestHybrid3(t *testing.T) { in := []float64{-9.2, 10, .7, 3, -80.2843} - want := 16.298615746321026 + want := 2.0618485725498265e+08 got := Hybrid3(in) diff --git a/bench/cec2020/helperFunctions.go b/bench/cec2020/helperFunctions.go index 79147d1..fc71d7f 100644 --- a/bench/cec2020/helperFunctions.go +++ b/bench/cec2020/helperFunctions.go @@ -173,6 +173,7 @@ func getGnx(p []float64, fnx float64) []float64 { } // getMz calculates Mz. +// nolint: unused func getMz(x []float64, z []float64) []float64 { nx := len(x) mz := make([]float64, nx)