go(de): implement Clear method on Population
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
leo 2023-01-20 18:44:45 +01:00
parent 93206b2cd1
commit 37710c95b3
Signed by: wanderer
SSH Key Fingerprint: SHA256:Dp8+iwKHSlrMEHzE3bJnPng70I7LEsa3IJXRH/U+idQ

View File

@ -78,7 +78,21 @@ func (p *Population) Reinit() {
// ReinitN reinitialises the individual at position n.
func (p *Population) ReinitN(n uint) {}
func (p *Population) Clear() {}
// Clear sets all vectors to 0.
func (p *Population) Clear() {
if p.Population != nil {
for _, v := range p.Population {
v.CurX = make([]float64, p.Dimen)
v.CurC = make([]float64, p.Dimen)
v.CurF = make([]float64, p.Dimen)
v.CurV = make([]float64, p.Dimen)
v.BestX = make([]float64, p.Dimen)
v.BestC = make([]float64, p.Dimen)
v.BestF = make([]float64, p.Dimen)
}
}
}
// meanVelocity computes the mean current velocity of all individuals in the population.
func (p *Population) MeanVelocity() float64 { return 0.0 }