algo: add PrepCEC2020ComparisonOfMeans+helper func
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
22e2703ed2
commit
80a9cd5743
91
algo/algo.go
91
algo/algo.go
@ -146,6 +146,97 @@ func PrepComparisonOfMeans(wg *sync.WaitGroup) (*report.PicList, int) {
|
|||||||
return pL, benchCount
|
return pL, benchCount
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PrepCEC2020ComparisonOfMeans prepares for comparison means of CEC2020 algos.
|
||||||
|
func PrepCEC2020ComparisonOfMeans(wg *sync.WaitGroup) (*report.PicList, int) {
|
||||||
|
pL := report.NewPicList()
|
||||||
|
meanStats := GetMeanStats()
|
||||||
|
algos := getAlgosFromAlgoMeans(meanStats.AlgoMeans)
|
||||||
|
|
||||||
|
// construct title consisting of names of all involved algorithms.
|
||||||
|
for _, v := range algos {
|
||||||
|
switch pL.Algo {
|
||||||
|
case "":
|
||||||
|
pL.Algo = v
|
||||||
|
default:
|
||||||
|
pL.Algo += " vs " + v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Println(`generating "Comparison of Means" plots`)
|
||||||
|
|
||||||
|
algoCount := len(algos)
|
||||||
|
dimLen := len(cec2020.Dimensions)
|
||||||
|
benchCount := len(cec2020.Functions)
|
||||||
|
|
||||||
|
for d := 0; d < dimLen; d++ {
|
||||||
|
// construct comparison for all benchmarking functions.
|
||||||
|
for i := 0; i < benchCount; i++ {
|
||||||
|
dimXAlgoMeanVals := make([]stats.AlgoMeanVals, 0, algoCount)
|
||||||
|
|
||||||
|
for j := 0; j < algoCount; j++ {
|
||||||
|
ms := &stats.AlgoMeanVals{
|
||||||
|
Title: meanStats.AlgoMeans[i+(j*benchCount)].Algo,
|
||||||
|
MeanVals: meanStats.AlgoMeans[i+(j*benchCount)].BenchMeans[d].MeanVals,
|
||||||
|
}
|
||||||
|
|
||||||
|
dimXAlgoMeanVals = append(dimXAlgoMeanVals, *ms)
|
||||||
|
}
|
||||||
|
|
||||||
|
dimens := meanStats.AlgoMeans[i].BenchMeans[d].Dimens
|
||||||
|
iterations := meanStats.AlgoMeans[i].BenchMeans[d].Iterations
|
||||||
|
bench := meanStats.AlgoMeans[i].BenchMeans[d].Bench
|
||||||
|
|
||||||
|
wg.Add(1)
|
||||||
|
|
||||||
|
// construct plots concurrently.
|
||||||
|
go PlotMeanValsMulti(
|
||||||
|
wg, dimens, iterations, bench, "plot-", ".pdf",
|
||||||
|
dimXAlgoMeanVals...,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// wait for all plotting goroutines.
|
||||||
|
wg.Wait()
|
||||||
|
|
||||||
|
pL.Pics = getComparisonOfMeansPics()
|
||||||
|
|
||||||
|
log.Printf("%#v", pL.Pics)
|
||||||
|
|
||||||
|
return pL, dimLen
|
||||||
|
}
|
||||||
|
|
||||||
|
// getAlgosFromAlgoMeans extracts algorithms used from the means list and
|
||||||
|
// returns it as a []string.
|
||||||
|
func getAlgosFromAlgoMeans(s []stats.AlgoBenchMean) []string {
|
||||||
|
algos := make([]string, 0)
|
||||||
|
|
||||||
|
// learn how many algos were processed based on the data.
|
||||||
|
for _, v := range s {
|
||||||
|
// if algos is empty just add the value directly, else determine if
|
||||||
|
// it's already been added or not.
|
||||||
|
if len(algos) > 0 {
|
||||||
|
alreadyadded := false
|
||||||
|
|
||||||
|
for _, algoName := range algos {
|
||||||
|
if algoName == v.Algo {
|
||||||
|
// early bail if already added.
|
||||||
|
alreadyadded = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if !alreadyadded {
|
||||||
|
algos = append(algos, v.Algo)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
algos = append(algos, v.Algo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return algos
|
||||||
|
}
|
||||||
|
|
||||||
// DoRandomSearch executes a search using the 'Random search' method.
|
// DoRandomSearch executes a search using the 'Random search' method.
|
||||||
func DoRandomSearch(wg *sync.WaitGroup, m *sync.Mutex) {
|
func DoRandomSearch(wg *sync.WaitGroup, m *sync.Mutex) {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
|
Loading…
Reference in New Issue
Block a user