math-optim/run.go
leo 7585bd4889
All checks were successful
continuous-integration/drone/push Build is passing
go(run): add flags to allow algorithm selection
* jDE runs by default
* errors out if none of the algorithms is chosen
* also increase test timeout
2023-01-21 17:26:01 +01:00

74 lines
1.7 KiB
Go

// Copyright 2023 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)")
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 {
if !*jDE && !*sHC && !*rS {
log.Fatalln("at least one algo needs to be specified, exiting...")
}
var wg sync.WaitGroup
var m sync.Mutex
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)
// report.SaveComparisonOfMeans(*pL, benchCount)
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")
}