go: add a way to iterate over func names for stats
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
surtur 2022-06-24 00:56:10 +02:00
parent 63da28a8f0
commit d2c4f2b1db
Signed by: wanderer
GPG Key ID: 19CE1EC1D9E0486D
2 changed files with 10 additions and 4 deletions

@ -27,10 +27,10 @@ func DoRandomSearch(wg *sync.WaitGroup) {
// stats for the current algo (RandomSearch). // stats for the current algo (RandomSearch).
algoStats := make([][]stats.Stats, funcCount) algoStats := make([][]stats.Stats, funcCount)
for i := range algoStats {
// ng y'all. // ng y'all.
algoStats[0] = RandomSearchNG(10000, 30, []int{5, 10, 20}, "Schwefel") algoStats[i] = RandomSearchNG(10000, 30, []int{5, 10, 20}, bench.FuncNames[i])
algoStats[1] = RandomSearchNG(10000, 30, []int{5, 10, 20}, "De Jong 1st") }
algoStats[2] = RandomSearchNG(10000, 30, []int{5, 10, 20}, "De Jong 2nd")
for i := range algoStats { for i := range algoStats {
plotAllDims(algoStats[i], "plot", ".svg") plotAllDims(algoStats[i], "plot", ".svg")

@ -13,6 +13,12 @@ var Functions = map[string]func([]float64) float64{
"De Jong 2nd": DeJong2nd, "De Jong 2nd": DeJong2nd,
} }
var FuncNames = map[int]string{
0: "Schwefel",
1: "De Jong 1st",
2: "De Jong 2nd",
}
// Function params maps function names to their funcParams for easier iterable // Function params maps function names to their funcParams for easier iterable
// access. // access.
var FunctionParams = map[string]funcParams{ var FunctionParams = map[string]funcParams{