cec2020: add GetMaxFES
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
leo 2023-02-09 03:29:08 +01:00
parent 9fdce17516
commit 99c39537fe
Signed by: wanderer
SSH Key Fingerprint: SHA256:Dp8+iwKHSlrMEHzE3bJnPng70I7LEsa3IJXRH/U+idQ
2 changed files with 12 additions and 9 deletions

@ -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 { func newXopt(n int, mu0 float64) []float64 {
gaussDist := &distuv.Normal{ gaussDist := &distuv.Normal{
Src: rand.NewSource(uint64(time.Now().UnixNano())), Src: rand.NewSource(uint64(time.Now().UnixNano())),

@ -59,13 +59,4 @@ var (
3000000, 3000000,
10000000, 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]
}
}