From 99c39537fe5e23a365371692fe56f5392bad7138 Mon Sep 17 00:00:00 2001 From: leo Date: Thu, 9 Feb 2023 03:29:08 +0100 Subject: [PATCH] cec2020: add GetMaxFES --- bench/cec2020/helperFunctions.go | 12 ++++++++++++ bench/cec2020/vars.go | 9 --------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/bench/cec2020/helperFunctions.go b/bench/cec2020/helperFunctions.go index 2d17ead..22acc5d 100644 --- a/bench/cec2020/helperFunctions.go +++ b/bench/cec2020/helperFunctions.go @@ -98,6 +98,18 @@ func Asy(x []float64, beta float64) { } } +// GetMaxFES returns maxFES for the passed dimension, given that it's present +// in the MaxFES slice, returns -1 otherwise. +func GetMaxFES(dim int) int { + for i, d := range Dimensions { + if dim == d { + return MaxFES[i] + } + } + + return -1 +} + func newXopt(n int, mu0 float64) []float64 { gaussDist := &distuv.Normal{ Src: rand.NewSource(uint64(time.Now().UnixNano())), diff --git a/bench/cec2020/vars.go b/bench/cec2020/vars.go index 5b38780..18211f7 100644 --- a/bench/cec2020/vars.go +++ b/bench/cec2020/vars.go @@ -59,13 +59,4 @@ var ( 3000000, 10000000, } - // Dim2MaxFES glues Dimensions and MaxFES together. - Dim2MaxFES = map[int]int{} ) - -// init antipattern is "necessary" here to fill the map. -func init() { - for i := range Dimensions { - Dim2MaxFES[Dimensions[i]] = MaxFES[i] - } -}