ga/population: idiomaticise init
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
leo 2023-02-21 22:03:10 +01:00
parent c4efcbb103
commit 5e4eee8853
Signed by: wanderer
SSH Key Fingerprint: SHA256:Dp8+iwKHSlrMEHzE3bJnPng70I7LEsa3IJXRH/U+idQ

@ -230,16 +230,12 @@ func (p *Population) Size() int {
// newPopulation returns a pointer to a new, uninitialised population. // newPopulation returns a pointer to a new, uninitialised population.
func newPopulation(benchProblem string, np, dimen int) *Population { func newPopulation(benchProblem string, np, dimen int) *Population {
p := &Population{} p := &Population{
Problem: benchProblem,
p.Problem = benchProblem ProblemFunc: cec2020.Functions[benchProblem],
Dimen: dimen,
p.ProblemFunc = cec2020.Functions[benchProblem] Population: make([]PopulationIndividual, np),
}
p.Dimen = dimen
// pre-alloc.
p.Population = make([]PopulationIndividual, np)
return p return p
} }