math-optim/algo/algo.go
surtur d2c4f2b1db
All checks were successful
continuous-integration/drone/push Build is passing
go: add a way to iterate over func names for stats
2022-06-24 00:56:10 +02:00

54 lines
1.2 KiB
Go

// Copyright 2022 wanderer <a_mirre at utb dot cz>
// SPDX-License-Identifier: GPL-3.0-or-later
package algo
import (
"sync"
"git.dotya.ml/wanderer/math-optim/bench"
"git.dotya.ml/wanderer/math-optim/stats"
)
// Values type is just a fancy named []float64 that will allow us to define
// methods over it.
type Values []float64
var picPath = "res/"
// DoRandomSearch executes a search using the 'Random search' method.
func DoRandomSearch(wg *sync.WaitGroup) {
defer wg.Done()
printRandomSearch("starting...")
// funcCount is the number of bench functions available.
funcCount := len(bench.Functions)
// stats for the current algo (RandomSearch).
algoStats := make([][]stats.Stats, funcCount)
for i := range algoStats {
// ng y'all.
algoStats[i] = RandomSearchNG(10000, 30, []int{5, 10, 20}, bench.FuncNames[i])
}
for i := range algoStats {
plotAllDims(algoStats[i], "plot", ".svg")
}
stats.PrintStatisticTable(algoStats)
}
// DoStochasticHillClimbing performs a search using the 'Stochastic Hill
// Climbing' method.
func DoStochasticHillClimbing(wg *sync.WaitGroup) {
defer wg.Done()
printSHC("starting...")
}
func newValues() *Values {
var v Values
return &v
}