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")
|
doPrint := flag.Bool("printreport", true, "print report.tex to console")
|
||||||
generate := flag.Bool("generate", true, "run algos and generate plot pics/statistical tables (anew)")
|
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)
|
// TODO(me): add flag for plot output format: -plotout=(svg,eps,pdf)
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
if *generate {
|
if *generate {
|
||||||
// atm we're only doing Random search and SHC
|
if !*jDE && !*sHC && !*rS {
|
||||||
// algoCount := 2
|
log.Fatalln("at least one algo needs to be specified, exiting...")
|
||||||
algoCount := 1
|
}
|
||||||
|
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
|
|
||||||
wg.Add(algoCount)
|
|
||||||
|
|
||||||
var m sync.Mutex
|
var m sync.Mutex
|
||||||
|
|
||||||
// go algo.DoRandomSearch(&wg, &m)
|
switch {
|
||||||
// go algo.DoStochasticHillClimbing(&wg, &m)
|
case *jDE:
|
||||||
// // go algo.DoStochasticHillClimbing100Neigh(&wg, &m)
|
wg.Add(1)
|
||||||
|
|
||||||
go algo.DojDE(&wg, &m)
|
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()
|
wg.Wait()
|
||||||
|
|
||||||
// pL, benchCount := algo.PrepComparisonOfMeans(&wg)
|
// pL, benchCount := algo.PrepComparisonOfMeans(&wg)
|
||||||
|
14
run_test.go
14
run_test.go
@ -3,9 +3,21 @@
|
|||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import "testing"
|
import (
|
||||||
|
"flag"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
func TestRun(t *testing.T) {
|
func TestRun(t *testing.T) {
|
||||||
t.Log("call run() (TODO: improve this test)")
|
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()
|
run()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user