go(de): implement Init(),Reinit() on Population
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
07d3d51ba7
commit
93206b2cd1
@ -3,6 +3,12 @@
|
||||
|
||||
package de
|
||||
|
||||
import (
|
||||
"golang.org/x/exp/rand"
|
||||
|
||||
"gonum.org/v1/gonum/stat/distuv"
|
||||
)
|
||||
|
||||
type (
|
||||
// DecisionVector is a []float64 abstraction representing the decision vector.
|
||||
DecisionVector []float64
|
||||
@ -51,11 +57,24 @@ func (p *Population) GetWorstIdx() int { return 0 }
|
||||
func (p *Population) SetX(n int, nuX DecisionVector) {}
|
||||
func (p *Population) SetV(n int, nuV DecisionVector) {}
|
||||
|
||||
// Init initialises all individuals.
|
||||
func (p *Population) Init() {}
|
||||
// Init initialises all individuals to random values.
|
||||
func (p *Population) Init() {
|
||||
uniform := distuv.Uniform{}
|
||||
uniform.Src = rand.NewSource(p.Seed)
|
||||
|
||||
for _, v := range p.Population {
|
||||
v.CurX = make([]float64, p.Dimen)
|
||||
|
||||
for i := 0; i < p.Dimen; i++ {
|
||||
v.CurX[i] = uniform.Rand()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Reinit reinitialises all individuals.
|
||||
func (p *Population) Reinit() {}
|
||||
func (p *Population) Reinit() {
|
||||
p.Init()
|
||||
}
|
||||
|
||||
// ReinitN reinitialises the individual at position n.
|
||||
func (p *Population) ReinitN(n uint) {}
|
||||
|
Loading…
Reference in New Issue
Block a user