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

[tanghaibao] Add support for CrossRate in models #27

Merged
merged 3 commits into from Jan 15, 2018
Merged

[tanghaibao] Add support for CrossRate in models #27

merged 3 commits into from Jan 15, 2018

Conversation

tanghaibao
Copy link
Contributor

@MaxHalford
Thanks for the awesome package - I'm adding support to specify crossover rate. Naturally, the MutRate controls how fast one explore new solutions; CrossRate controls how much mixing amongst good solutions.

The old behavior was essentially CrossRate = 1, which, for most applications is too much. One could see this pathological behavior in the example of grid_tsp.go, where it seems to lack the ability to mutate (since crossover is dominating).

This PR allows one to specify CrossRate inside the model.

Haibao

@MaxHalford
Copy link
Owner

Please correct your code so that the Travis build doesn't fail :)

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.4%) to 98.775% when pulling 3120a02 on tanghaibao:master into cd089b9 on MaxHalford:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.007%) to 99.207% when pulling 47df520 on tanghaibao:master into cd089b9 on MaxHalford:master.

@tanghaibao
Copy link
Contributor Author

@MaxHalford
While all the tests now pass, I should add that now the default CrossRate (when you don't specify it) is 0. There is a potential risk to break someone else's existing code - when they just initialize the struct without CrossRate. However, this is the same expected as MutRate, when nothing is specified, no mutations. Here when nothing is specified, no crossovers.

Or perhaps you could come up with a cleaner way to deal with defaults here?

Haibao

@MaxHalford
Copy link
Owner

Okay I'm going to merge this PR. As for the value of the crossover rate that has to be comprised between 0 and 1, that's why I impose each model has a Validate() bool method to ensure the parameters are correct. Go doesn't supports default values!

@MaxHalford MaxHalford merged commit 1ce3f44 into MaxHalford:master Jan 15, 2018
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.

None yet

3 participants