math-optim/main.go

48 lines
1018 B
Go
Raw Normal View History

2022-06-14 16:46:11 +02:00
// Copyright 2022 wanderer <a_mirre at utb dot cz>
// SPDX-License-Identifier: GPL-3.0-or-later
package main
import (
2022-07-18 01:58:56 +02:00
"flag"
2022-06-14 16:46:11 +02:00
"log"
2022-06-14 22:34:52 +02:00
"sync"
"git.dotya.ml/wanderer/math-optim/algo"
"git.dotya.ml/wanderer/math-optim/report"
2022-06-14 16:46:11 +02:00
)
var version = "development"
func main() {
2022-06-14 22:34:52 +02:00
log.Println("starting math-optim version", "'"+version+"'")
2022-07-18 01:58:56 +02:00
doPrint := flag.Bool("printreport", true, "print report.tex to console")
2022-07-18 02:33:17 +02:00
generate := flag.Bool("generate", true, "run algos and generate plot pics/statistical tables (anew)")
2022-07-18 01:58:56 +02:00
flag.Parse()
2022-07-18 02:33:17 +02:00
if *generate {
// atm we're only doing Random search and SHC
algoCount := 2
2022-06-14 22:34:52 +02:00
2022-07-18 02:33:17 +02:00
var wg sync.WaitGroup
2022-06-14 22:34:52 +02:00
2022-07-18 02:33:17 +02:00
wg.Add(algoCount)
2022-06-14 22:34:52 +02:00
2022-07-18 02:33:17 +02:00
var m sync.Mutex
2022-07-18 02:33:17 +02:00
go algo.DoRandomSearch(&wg, &m)
go algo.DoStochasticHillClimbing(&wg, &m)
2022-06-14 22:34:52 +02:00
2022-07-18 02:33:17 +02:00
wg.Wait()
report.SaveTexAllPics()
report.SaveTexAllTables()
}
2022-06-14 22:34:52 +02:00
2022-07-18 01:58:56 +02:00
report.SaveAndPrint(*doPrint)
2022-06-14 22:34:52 +02:00
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")
2022-06-14 16:46:11 +02:00
}