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.
func newPopulation(benchProblem string, np, dimen int) *Population {
p := &Population{}
p.Problem = benchProblem
p.ProblemFunc = cec2020.Functions[benchProblem]
p.Dimen = dimen
// pre-alloc.
p.Population = make([]PopulationIndividual, np)
p := &Population{
Problem: benchProblem,
ProblemFunc: cec2020.Functions[benchProblem],
Dimen: dimen,
Population: make([]PopulationIndividual, np),
}
return p
}