ga: improve object/func init readability
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
e1fac11ec5
commit
dd92f3fb41
@ -76,7 +76,14 @@ const (
|
|||||||
var jDELogger = newLogger(" *** δ jDE:")
|
var jDELogger = newLogger(" *** δ jDE:")
|
||||||
|
|
||||||
// Init initialises the jDE algorithm, performs sanity checks on the inputs.
|
// 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 {
|
if j == nil {
|
||||||
jDELogger.Fatalln("jDE needs to be initialised before calling Run(), exiting...")
|
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()))
|
rngsrc := rand.NewSource(uint64(rand.Int63()))
|
||||||
|
|
||||||
j.rngF = distuv.Uniform{Min: fMin, Max: fMax, Src: rngsrc}
|
j.rngF = distuv.Uniform{
|
||||||
j.rngCR = distuv.Uniform{Min: crMin, Max: crMax, Src: rngsrc}
|
Min: fMin,
|
||||||
|
Max: fMax,
|
||||||
|
Src: rngsrc,
|
||||||
|
}
|
||||||
|
j.rngCR = distuv.Uniform{
|
||||||
|
Min: crMin,
|
||||||
|
Max: crMax,
|
||||||
|
Src: rngsrc,
|
||||||
|
}
|
||||||
|
|
||||||
j.Dimensions = dimensions
|
j.Dimensions = dimensions
|
||||||
j.BenchName = bench
|
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
|
// InitAndRun initialises the jDE algorithm, performs sanity checks on the
|
||||||
// inputs and calls the Run method.
|
// 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 {
|
if j == nil {
|
||||||
jDELogger.Fatalln("jDE is nil, NewjDE() needs to be called first. exiting...")
|
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()
|
j.Run()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user