go: clean up main
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
surtur 2022-07-18 23:12:33 +02:00
parent 3c8678a8d3
commit 333a5c4e48
Signed by: wanderer
GPG Key ID: 19CE1EC1D9E0486D
3 changed files with 58 additions and 40 deletions

41
main.go
View File

@ -3,45 +3,6 @@
package main
import (
"flag"
"log"
"sync"
"git.dotya.ml/wanderer/math-optim/algo"
"git.dotya.ml/wanderer/math-optim/report"
)
var version = "development"
func main() {
log.Println("starting math-optim version", "'"+version+"'")
doPrint := flag.Bool("printreport", true, "print report.tex to console")
generate := flag.Bool("generate", true, "run algos and generate plot pics/statistical tables (anew)")
flag.Parse()
if *generate {
// atm we're only doing Random search and SHC
algoCount := 2
var wg sync.WaitGroup
wg.Add(algoCount)
var m sync.Mutex
go algo.DoRandomSearch(&wg, &m)
go algo.DoStochasticHillClimbing(&wg, &m)
wg.Wait()
report.SaveTexAllPics()
report.SaveTexAllTables()
}
report.SaveAndPrint(*doPrint)
log.Println("looks like we're done")
log.Println("run an equivalent of `pdflatex -clean -shell-escape -interaction=nonstopmode ./report.tex` to get a pdf")
run()
}

47
run.go Normal file
View File

@ -0,0 +1,47 @@
// Copyright 2022 wanderer <a_mirre at utb dot cz>
// SPDX-License-Identifier: GPL-3.0-or-later
package main
import (
"flag"
"log"
"sync"
"git.dotya.ml/wanderer/math-optim/algo"
"git.dotya.ml/wanderer/math-optim/report"
)
var version = "development"
func run() {
log.Println("starting math-optim version", "'"+version+"'")
doPrint := flag.Bool("printreport", true, "print report.tex to console")
generate := flag.Bool("generate", true, "run algos and generate plot pics/statistical tables (anew)")
flag.Parse()
if *generate {
// atm we're only doing Random search and SHC
algoCount := 2
var wg sync.WaitGroup
wg.Add(algoCount)
var m sync.Mutex
go algo.DoRandomSearch(&wg, &m)
go algo.DoStochasticHillClimbing(&wg, &m)
wg.Wait()
report.SaveTexAllPics()
report.SaveTexAllTables()
}
report.SaveAndPrint(*doPrint)
log.Println("looks like we're done")
log.Println("run an equivalent of `pdflatex -clean -shell-escape -interaction=nonstopmode ./report.tex` to get a pdf")
}

10
run_test.go Normal file
View File

@ -0,0 +1,10 @@
// Copyright 2022 wanderer <a_mirre at utb dot cz>
// SPDX-License-Identifier: GPL-3.0-or-later
package main
import "testing"
func TestRun(t *testing.T) {
run()
}