DEAP / deap

Distributed Evolutionary Algorithms in Python
http://deap.readthedocs.org/
GNU Lesser General Public License v3.0
5.75k stars 1.12k forks source link

Why cxTwoPoint never swaps the first attribute? #438

Open discosultan opened 4 years ago

discosultan commented 4 years ago

I'm curious as to why the cxTwoPoint function does not perform crossover on the first attribute of both individuals. More specifically, why isn't line 50 written as cxpoint1 = random.randint(0, size) instead?

https://github.com/DEAP/deap/blob/454b4f65a9c944ea2c90b38a75d384cddf524220/deap/tools/crossover.py#L49-L58

guidotorresmx commented 4 years ago

I couldn't find any reason. Actually it behaves slower (without intensive tests nor digging deeper) than just including the first gen in the function. plots

guidotorresmx commented 4 years ago

I haven't realized the probability of change for each gen follows a pseudonormal distribution. couldn't find notes for fixing it but probably just replacing the random.randint with a normal complementary random function will solve it.

anyway, please create the pull request