go(run): add flags to allow algorithm selection
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
* jDE runs by default * errors out if none of the algorithms is chosen * also increase test timeout
This commit is contained in:
parent
47b21dca0b
commit
7585bd4889
35
run.go
35
run.go
@ -19,25 +19,44 @@ func run() {
|
||||
|
||||
doPrint := flag.Bool("printreport", true, "print report.tex to console")
|
||||
generate := flag.Bool("generate", true, "run algos and generate plot pics/statistical tables (anew)")
|
||||
rS := flag.Bool("randomsearch", false, "run Random Search algorithm")
|
||||
sHC := flag.Bool("shc", false, "run Stochastic Hill Climbing algorithm")
|
||||
N100 := flag.Bool("N100", false, "run the \"100 Neighbours\" variant of SHC")
|
||||
// run jDE by default.
|
||||
jDE := flag.Bool("jde", true, "run Differential Evolution algorithm with parameter self adaptation")
|
||||
// TODO(me): add flag for plot output format: -plotout=(svg,eps,pdf)
|
||||
flag.Parse()
|
||||
|
||||
if *generate {
|
||||
// atm we're only doing Random search and SHC
|
||||
// algoCount := 2
|
||||
algoCount := 1
|
||||
if !*jDE && !*sHC && !*rS {
|
||||
log.Fatalln("at least one algo needs to be specified, exiting...")
|
||||
}
|
||||
|
||||
var wg sync.WaitGroup
|
||||
|
||||
wg.Add(algoCount)
|
||||
|
||||
var m sync.Mutex
|
||||
|
||||
// go algo.DoRandomSearch(&wg, &m)
|
||||
// go algo.DoStochasticHillClimbing(&wg, &m)
|
||||
// // go algo.DoStochasticHillClimbing100Neigh(&wg, &m)
|
||||
switch {
|
||||
case *jDE:
|
||||
wg.Add(1)
|
||||
|
||||
go algo.DojDE(&wg, &m)
|
||||
|
||||
case *rS:
|
||||
wg.Add(1)
|
||||
|
||||
go algo.DoRandomSearch(&wg, &m)
|
||||
|
||||
case *sHC:
|
||||
wg.Add(1)
|
||||
|
||||
if *N100 {
|
||||
go algo.DoStochasticHillClimbing100Neigh(&wg, &m)
|
||||
} else {
|
||||
go algo.DoStochasticHillClimbing(&wg, &m)
|
||||
}
|
||||
}
|
||||
|
||||
wg.Wait()
|
||||
|
||||
// pL, benchCount := algo.PrepComparisonOfMeans(&wg)
|
||||
|
14
run_test.go
14
run_test.go
@ -3,9 +3,21 @@
|
||||
|
||||
package main
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"flag"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestRun(t *testing.T) {
|
||||
t.Log("call run() (TODO: improve this test)")
|
||||
|
||||
timeout := "1m10s"
|
||||
|
||||
t.Log("increase test timeout to", timeout)
|
||||
|
||||
if err := flag.Set("test.timeout", timeout); err != nil {
|
||||
t.Errorf("failed to set timeout to %s", timeout)
|
||||
}
|
||||
|
||||
run()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user