ga: improve object/func init readability
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
leo 2023-02-22 23:26:28 +01:00
parent e1fac11ec5
commit dd92f3fb41
Signed by: wanderer
SSH Key Fingerprint: SHA256:Dp8+iwKHSlrMEHzE3bJnPng70I7LEsa3IJXRH/U+idQ

View File

@ -76,7 +76,14 @@ type JDE struct {
var jDELogger = newLogger(" *** δ jDE:")
// Init initialises the jDE algorithm, performs sanity checks on the inputs.
func (j *JDE) Init(generations, benchMinIters, mutStrategy, adptScheme, np int, f, cr float64, dimensions []int, bench string, ch chan []stats.Stats, chAlgoMeans chan *stats.AlgoBenchMean) {
func (j *JDE) Init(
generations, benchMinIters, mutStrategy, adptScheme, np int,
f, cr float64,
dimensions []int,
bench string,
ch chan []stats.Stats,
chAlgoMeans chan *stats.AlgoBenchMean,
) {
if j == nil {
jDELogger.Fatalln("jDE needs to be initialised before calling Run(), exiting...")
}
@ -124,8 +131,16 @@ func (j *JDE) Init(generations, benchMinIters, mutStrategy, adptScheme, np int,
rngsrc := rand.NewSource(uint64(rand.Int63()))
j.rngF = distuv.Uniform{Min: fMin, Max: fMax, Src: rngsrc}
j.rngCR = distuv.Uniform{Min: crMin, Max: crMax, Src: rngsrc}
j.rngF = distuv.Uniform{
Min: fMin,
Max: fMax,
Src: rngsrc,
}
j.rngCR = distuv.Uniform{
Min: crMin,
Max: crMax,
Src: rngsrc,
}
j.Dimensions = dimensions
j.BenchName = bench
@ -139,12 +154,25 @@ func (j *JDE) Init(generations, benchMinIters, mutStrategy, adptScheme, np int,
// InitAndRun initialises the jDE algorithm, performs sanity checks on the
// inputs and calls the Run method.
func (j *JDE) InitAndRun(generations, benchMinIters, mutStrategy, adptScheme, np int, f, cr float64, dimensions []int, bench string, ch chan []stats.Stats, chAlgoMeans chan *stats.AlgoBenchMean) {
func (j *JDE) InitAndRun(
generations, benchMinIters, mutStrategy, adptScheme, np int,
f, cr float64,
dimensions []int,
bench string,
ch chan []stats.Stats,
chAlgoMeans chan *stats.AlgoBenchMean,
) {
if j == nil {
jDELogger.Fatalln("jDE is nil, NewjDE() needs to be called first. exiting...")
}
j.Init(generations, benchMinIters, mutStrategy, adptScheme, np, f, cr, dimensions, bench, ch, chAlgoMeans)
j.Init(
generations, benchMinIters, mutStrategy, adptScheme, np,
f, cr,
dimensions,
bench,
ch, chAlgoMeans,
)
j.Run()
}