Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix MutatorMulti for > 2 mutators and make code more idiomatic #5

Merged
merged 5 commits into from
Dec 28, 2015

Conversation

subruber
Copy link
Contributor

Hello, I have fixed an issue with the GAMutatorMulti. The current code does not select the mutators with equal probability except in the case of 2 mutators (and the trivial case of 1 mutator).

I also cleaned up the code a bit, made it more idiomatic and added a test (which I used to test my fix).

Thanks!

The previous implementation only gave an uniform distribution with <= 2
mutators; else, in a series of N mutators, only the first one had
probability 1/N, while the other ones had decreasing ones (e.g. the
second had 1/N - 1/N^2) except the very last, which was too likely to be
invoked.

Also changed the receiver of Mutate() to a pointer receiver, which is
more correct (the value receiver only happened to work because the
fields of GAMutatorMulti are all slices, i.e. references.
thoj added a commit that referenced this pull request Dec 28, 2015
Fix MutatorMulti for > 2 mutators and make code more idiomatic
@thoj thoj merged commit 576b0bd into thoj:master Dec 28, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants