go(stats): Solution -> BenchResults in FuncStats
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
1f6bed98da
commit
c37ef263ae
@ -136,7 +136,7 @@ func plotAllDims(algoStats []stats.Stats, fPrefix, fExt string, ch chan report.P
|
||||
// https://stackoverflow.com/a/44872993
|
||||
lines := make([]interface{}, 0)
|
||||
|
||||
for _, iter := range dim.Solution {
|
||||
for _, iter := range dim.BenchResults {
|
||||
// mark the end of the X axis with len(iter.Results).
|
||||
p.X.Max = float64(len(iter.Results))
|
||||
|
||||
@ -174,7 +174,7 @@ func plotAllDims(algoStats []stats.Stats, fPrefix, fExt string, ch chan report.P
|
||||
util.SanitiseFName(dim.BenchName) + "-" +
|
||||
fmt.Sprint(s.Dimens) + "D-" +
|
||||
fmt.Sprint(s.Generations) + "G-" +
|
||||
fmt.Sprint(len(dim.Solution)) + "I"
|
||||
fmt.Sprint(len(dim.BenchResults)) + "I"
|
||||
filenameMean := filename + util.SanitiseFName(" Mean")
|
||||
|
||||
// NEVER EVER ATTEMPT TO INITIALISE THIS WITH `pic`!
|
||||
@ -190,7 +190,7 @@ func plotAllDims(algoStats []stats.Stats, fPrefix, fExt string, ch chan report.P
|
||||
picMean.FilePath = filenameMean
|
||||
|
||||
// get the *mean* plot.
|
||||
pMean := plotMeanVals(dim.Solution, meanTitle, s.Generations)
|
||||
pMean := plotMeanVals(dim.BenchResults, meanTitle, s.Generations)
|
||||
|
||||
elapsed := time.Since(start)
|
||||
info := "saving img to file: " + filename + "(-Mean)" + fExt +
|
||||
|
@ -117,7 +117,7 @@ func RandomSearchNG(maxFES, benchMinIters int, theD []int, benchFunc string, ch
|
||||
printRandomSearch("running bench \"" + benchFunc + "\" for " +
|
||||
fmt.Sprint(randomSearchStatDimX.Dimens) + "D")
|
||||
|
||||
funcStats.Solution = make([]stats.BenchRound, minIters)
|
||||
funcStats.BenchResults = make([]stats.BenchRound, minIters)
|
||||
|
||||
// perform the while dance 'minIters' times for "statistical relevance"
|
||||
for iter := 0; iter < minIters; iter++ {
|
||||
@ -125,7 +125,7 @@ func RandomSearchNG(maxFES, benchMinIters int, theD []int, benchFunc string, ch
|
||||
var bestResult float64
|
||||
|
||||
// set current iteration in funcStats.
|
||||
funcStats.Solution[iter].Iteration = iter
|
||||
funcStats.BenchResults[iter].Iteration = iter
|
||||
|
||||
// run the benchmarking function 'fes' times.
|
||||
for i := 0; i < fes; i++ {
|
||||
@ -149,8 +149,8 @@ func RandomSearchNG(maxFES, benchMinIters int, theD []int, benchFunc string, ch
|
||||
}
|
||||
|
||||
// save the 'best' result, since we only care about those.
|
||||
funcStats.Solution[iter].Results = append(
|
||||
funcStats.Solution[iter].Results,
|
||||
funcStats.BenchResults[iter].Results = append(
|
||||
funcStats.BenchResults[iter].Results,
|
||||
bestResult,
|
||||
)
|
||||
}
|
||||
|
@ -206,7 +206,7 @@ func HillClimb(maxFES, benchMinIters int, theD []int, benchFunc string, ch chan
|
||||
printSHC("running bench \"" + benchFunc + "\" for " +
|
||||
fmt.Sprint(stochasticHCStatDimX.Dimens) + "D")
|
||||
|
||||
funcStats.Solution = make([]stats.BenchRound, minIters)
|
||||
funcStats.BenchResults = make([]stats.BenchRound, minIters)
|
||||
|
||||
// create a source of preudo-randomness.
|
||||
src := rand.NewSource(uint64(rand.Int63()))
|
||||
@ -216,7 +216,7 @@ func HillClimb(maxFES, benchMinIters int, theD []int, benchFunc string, ch chan
|
||||
start := time.Now()
|
||||
|
||||
for iter := 0; iter < minIters; iter++ {
|
||||
funcStats.Solution[iter].Iteration = iter
|
||||
funcStats.BenchResults[iter].Iteration = iter
|
||||
|
||||
// create and stochastically populate the vals slice.
|
||||
initVals := make([]float64, dimens)
|
||||
@ -263,8 +263,8 @@ func HillClimb(maxFES, benchMinIters int, theD []int, benchFunc string, ch chan
|
||||
}
|
||||
}
|
||||
|
||||
funcStats.Solution[iter].Results = append(
|
||||
funcStats.Solution[iter].Results,
|
||||
funcStats.BenchResults[iter].Results = append(
|
||||
funcStats.BenchResults[iter].Results,
|
||||
bestResult,
|
||||
)
|
||||
}
|
||||
|
@ -19,8 +19,8 @@ type BenchRound struct {
|
||||
}
|
||||
|
||||
type FuncStats struct {
|
||||
BenchName string
|
||||
Solution []BenchRound
|
||||
BenchName string
|
||||
BenchResults []BenchRound
|
||||
}
|
||||
|
||||
type Stats struct {
|
||||
@ -31,10 +31,10 @@ type Stats struct {
|
||||
Generations int
|
||||
}
|
||||
|
||||
func GetFuncStats(funcName string, solution []BenchRound) FuncStats {
|
||||
func GetFuncStats(funcName string, benchResults []BenchRound) FuncStats {
|
||||
f := FuncStats{
|
||||
BenchName: funcName,
|
||||
Solution: solution,
|
||||
BenchName: funcName,
|
||||
BenchResults: benchResults,
|
||||
}
|
||||
|
||||
return f
|
||||
|
@ -69,7 +69,7 @@ func parseSingleBenchStats(benchStats []Stats) []report.Row {
|
||||
// collect the best.
|
||||
var best []float64
|
||||
|
||||
for _, iter := range dim.Solution {
|
||||
for _, iter := range dim.BenchResults {
|
||||
last := s.Generations - 1
|
||||
|
||||
best = append(best, iter.Results[last])
|
||||
|
@ -22,7 +22,7 @@ func TestParseBenchStats(t *testing.T) {
|
||||
benchFuncStats := []FuncStats{
|
||||
{
|
||||
BenchName: "De Jong 5th",
|
||||
Solution: []BenchRound{
|
||||
BenchResults: []BenchRound{
|
||||
{Iteration: 0, Results: []float64{2803.7015205977887, 2296.736381649773, 1763.9319525203364}},
|
||||
{Iteration: 1, Results: []float64{2169.7378893600176, 2169.7378893600176, 2169.7378893600176}},
|
||||
{Iteration: 2, Results: []float64{1909.6488355929007, 1336.3261400058473, 1336.3261400058473}},
|
||||
|
Loading…
Reference in New Issue
Block a user