Open iblancasa opened 8 years ago
Here I am comparing Deap library with Pythoneo.
Benchmarks are in the code section. I think I coded it well and I tried to do as in Pythoneo (and other "eos"). Only I have this issue -> #2
In the previous comment there are the results and we can compare with Pythoneo results. Only in bitflip the results are worse (I think the problem is #2).
What do you think? @jj @analca3
In general, Python access local variables faster than global ones. This doesn't solve your issue, but maybe you can avoid them to boost scripts a bit.
https://wiki.python.org/moin/PythonSpeed/PerformanceTips#Local_Variables
I think in all languages. @analca3, should I pass it as an argument? For example
In that page it suggests that you only have to reference it with a local variable
I fixed #3 and there is not improvement.
The result of fixing #2
I implement a bitflip similar to the bitflip of Pythoneo (where we change only one bit). I called this results: "own".
"native" results run with the Deap method (where you insert the probability to change one bit -I calcule this probability as 1/length -).
deap-Bitflip, 16, 0.397274 deap-Bitflip, 32, 0.407814 deap-Bitflip, 64, 0.4097259999999999 deap-Bitflip, 128, 0.4286700000000001 deap-Bitflip, 256, 0.47449299999999983 deap-Bitflip, 512, 0.5978970000000001 deap-Bitflip, 1024, 0.9630390000000002 deap-Bitflip, 2048, 1.1711029999999996 deap-Bitflip, 4096, 1.8827879999999997 deap-Bitflip, 8192, 3.395659 deap-Bitflip, 16384, 6.187431999999999 deap-Bitflip, 32768, 12.174989
bitflip numpy own deap-Bitflip, 16, 0.670491 deap-Bitflip, 32, 0.61322 deap-Bitflip, 64, 0.668091 deap-Bitflip, 128, 0.6323689999999997 deap-Bitflip, 256, 0.646274 deap-Bitflip, 512, 0.6775039999999999 deap-Bitflip, 1024, 0.7029209999999999 deap-Bitflip, 2048, 0.8872439999999999 deap-Bitflip, 4096, 0.8898149999999996 deap-Bitflip, 8192, 1.331175 deap-Bitflip, 16384, 1.686132999999999 deap-Bitflip, 32768, 3.163976999999999
deap-Bitflip, 16, 0.566189 deap-Bitflip, 32, 0.945729 deap-Bitflip, 64, 1.305168 deap-Bitflip, 128, 2.345645 deap-Bitflip, 256, 4.389294 deap-Bitflip, 512, 8.913457 deap-Bitflip, 1024, 16.047179999999997 deap-Bitflip, 2048, 32.410588 deap-Bitflip, 4096, 74.91340100000001 deap-Bitflip, 8192, 167.66436499999998
deap-Bitflip, 16, 0.54518 deap-Bitflip, 32, 0.7726349999999998 deap-Bitflip, 64, 1.2388820000000003 deap-Bitflip, 128, 2.1679329999999997 deap-Bitflip, 256, 3.8661529999999997 deap-Bitflip, 512, 7.93901 deap-Bitflip, 1024, 20.215876
I got these results with the actual implementation (I think all is ok).
Bitflip
Lists
deap-Bitflip, 16, 0.491734 deap-Bitflip, 32, 0.7047650000000001 deap-Bitflip, 64, 1.1109949999999997 deap-Bitflip, 128, 1.9927660000000005 deap-Bitflip, 256, 3.6297500000000005 deap-Bitflip, 512, 8.602868999999998 deap-Bitflip, 1024, 15.499465999999998 deap-Bitflip, 2048, 30.633792 deap-Bitflip, 4096, 63.346363 deap-Bitflip, 8192, 142.074204
Numpy arrays
deap-Bitflip, 16, 0.6340359999999999 deap-Bitflip, 32, 0.741613 deap-Bitflip, 64, 1.1845649999999999 deap-Bitflip, 128, 1.974949 deap-Bitflip, 256, 3.643091 deap-Bitflip, 512, 7.459453 deap-Bitflip, 1024, 16.951850999999998 deap-Bitflip, 2048, 30.432902999999996 deap-Bitflip, 4096, 65.359509
Onemax
Lists
deap-Onemax, 16, 1.497064 deap-Onemax, 32, 1.9806099999999998 deap-Onemax, 64, 2.7551819999999996 deap-Onemax, 128, 4.39448 deap-Onemax, 256, 7.506619000000001 deap-Onemax, 512, 15.026201000000004 deap-Onemax, 1024, 33.598774
Numpy arrays
deap-Onemax, 16, 2.9955819999999997 deap-Onemax, 32, 4.156472 deap-Onemax, 64, 6.487214 deap-Onemax, 128, 11.485790999999999 deap-Onemax, 256, 24.331519000000004 deap-Onemax, 512, 50.16815 deap-Onemax, 1024, 94.17976099999998
XOVER
Lists
deap-Xover, 16, 0.540602 deap-Xover, 32, 0.5850090000000001 deap-Xover, 64, 0.6433360000000001 deap-Xover, 128, 0.639224 deap-Xover, 256, 0.733222 deap-Xover, 512, 0.906752 deap-Xover, 1024, 1.2215570000000007 deap-Xover, 2048, 1.8783349999999999 deap-Xover, 4096, 3.2454669999999997 deap-Xover, 8192, 6.192470999999999 deap-Xover, 16384, 12.002845999999998 deap-Xover, 32768, 24.234619
Numpy
deap-Xover, 16, 0.733392 deap-Xover, 32, 0.7490990000000001 deap-Xover, 64, 0.7865799999999998 deap-Xover, 128, 0.7680350000000002 deap-Xover, 256, 0.765056 deap-Xover, 512, 0.8199110000000003 deap-Xover, 1024, 0.912865 deap-Xover, 2048, 0.9273950000000006 deap-Xover, 4096, 1.0325849999999992 deap-Xover, 8192, 1.2384209999999998 deap-Xover, 16384, 1.6255199999999999 deap-Xover, 32768, 2.688027