MaxHalford / eaopt

:four_leaf_clover: Evolutionary optimization library for Go (genetic algorithm, partical swarm optimization, differential evolution)
https://pkg.go.dev/github.com/MaxHalford/eaopt
MIT License
888 stars 96 forks source link

Fix neighbor index in island ring model #38

Closed ghost closed 5 years ago

ghost commented 5 years ago

The ring model is currently crossing over each individual with itself.

I had to stare at this to make sure my eyes weren't deceiving me.

In ModRing Apply():

var (
    indi      = pop.Individuals[i].Clone(pop.RNG)
    neighbour = pop.Individuals[i%len(pop.Individuals)]
)
indi.Crossover(neighbour, pop.RNG)

I guess that's supposed to be (i+1)%len(...)

The PR includes a couple other minor things.

coveralls commented 5 years ago

Pull Request Test Coverage Report for Build 287


Totals Coverage Status
Change from base Build 286: 0.0%
Covered Lines: 1621
Relevant Lines: 1627

💛 - Coveralls
MaxHalford commented 5 years ago

LGTM! You made two good catches :). Thanks a lot.