Closed tanghaibao closed 6 years ago
Please correct your code so that the Travis build doesn't fail :)
@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
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 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 ofgrid_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