diff --git a/.gitignore b/.gitignore index f541c39..dc1b878 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,8 @@ result result-* math-optim +# output dir for generated plot pics/tex files +out .vimrc diff --git a/algo/algo.go b/algo/algo.go index f33b3f2..0396752 100644 --- a/algo/algo.go +++ b/algo/algo.go @@ -14,8 +14,6 @@ import ( // methods over it. type Values []float64 -var picPath = "res/" - var plotWg sync.WaitGroup // DoRandomSearch executes a search using the 'Random search' method. diff --git a/algo/algo_test.go b/algo/algo_test.go index 6232aaa..38322aa 100644 --- a/algo/algo_test.go +++ b/algo/algo_test.go @@ -7,6 +7,8 @@ import ( "os" "sync" "testing" + + "git.dotya.ml/wanderer/math-optim/report" ) var wg sync.WaitGroup @@ -18,7 +20,9 @@ func TestDoRandomSearchExec(t *testing.T) { wg.Wait() - if err := os.RemoveAll(picPath); err != nil { + picsDir := report.GetPicsDir() + + if err := os.RemoveAll(picsDir); err != nil { t.Error(err) } } @@ -30,7 +34,9 @@ func TestDoSHCExec(t *testing.T) { wg.Wait() - if err := os.RemoveAll(picPath); err != nil { + picsDir := report.GetPicsDir() + + if err := os.RemoveAll(picsDir); err != nil { t.Error(err) } } diff --git a/algo/plot.go b/algo/plot.go index 1d97421..37fc4eb 100644 --- a/algo/plot.go +++ b/algo/plot.go @@ -9,6 +9,7 @@ import ( "sync" "time" + "git.dotya.ml/wanderer/math-optim/report" "git.dotya.ml/wanderer/math-optim/stats" "git.dotya.ml/wanderer/math-optim/util" "gonum.org/v1/gonum/floats" @@ -26,6 +27,13 @@ func plotAllDims(algoStats []stats.Stats, fPrefix, fExt string, wg *sync.WaitGro defer wg.Done() // does this work with panic in the mix? TODO(me): find out. start := time.Now() + + picsDir := report.GetPicsDir() + + if err := util.CreatePath(picsDir); err != nil { + log.Println(err) + } + pWidth := 13 * vg.Centimeter pHeight := 13 * vg.Centimeter @@ -89,11 +97,7 @@ func plotAllDims(algoStats []stats.Stats, fPrefix, fExt string, wg *sync.WaitGro log.Panic(err) } - if err := util.CreatePath(picPath); err != nil { - log.Println(err) - } - - filename := picPath + + filename := picsDir + fPrefix + "-" + util.SanitiseFName(s.Algo) + "-" + util.SanitiseFName(dim.BenchName) + "-" + diff --git a/report/report.go b/report/report.go index 0d689a7..cdbe039 100644 --- a/report/report.go +++ b/report/report.go @@ -12,6 +12,16 @@ import ( "os" ) +const ( + outPrefix = "out/" + picsDir = "pics/" +) + +// GetPicsDirPrefix returns the path to the folder meant for plot pics. +func GetPicsDir() string { + return outPrefix + picsDir +} + // Print prints stats in a report format. func Print() { fmt.Fprint(os.Stderr, "\n* printing the report...\n\n")