From aaa6e6f298c93bb240af415cd0a0e2616016ddc6 Mon Sep 17 00:00:00 2001 From: surtur Date: Fri, 8 Jul 2022 21:40:04 +0200 Subject: [PATCH] go(algo): do HillClimb --- algo/algo.go | 15 +++++++++++++++ algo/algo_test.go | 4 ++++ 2 files changed, 19 insertions(+) diff --git a/algo/algo.go b/algo/algo.go index 7cbf605..1afe11f 100644 --- a/algo/algo.go +++ b/algo/algo.go @@ -45,6 +45,21 @@ func DoStochasticHillClimbing(wg *sync.WaitGroup) { defer wg.Done() printSHC("starting...") + + // funcCount is the number of bench functions available. + funcCount := len(bench.Functions) + // stats for the current algo (StochasticHillClimber). + algoStats := make([][]stats.Stats, funcCount) + + for i := range algoStats { + algoStats[i] = HillClimb(10000, 30, []int{5, 10, 20}, bench.FuncNames[i]) + } + + for _, algoStat := range algoStats { + plotAllDims(algoStat, "plot", ".svg") + } + + stats.PrintStatisticTable(algoStats) } func newValues() *Values { diff --git a/algo/algo_test.go b/algo/algo_test.go index 2ace823..6232aaa 100644 --- a/algo/algo_test.go +++ b/algo/algo_test.go @@ -29,6 +29,10 @@ func TestDoSHCExec(t *testing.T) { go DoStochasticHillClimbing(&wg) wg.Wait() + + if err := os.RemoveAll(picPath); err != nil { + t.Error(err) + } } func TestNewValues(t *testing.T) {