trevorstephens / gplearn

Genetic Programming in Python, with a scikit-learn inspired API
http://gplearn.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
1.59k stars 281 forks source link

how programs converge technically and use less time in later generations #275

Closed stanleyzhangmagma closed 2 years ago

stanleyzhangmagma commented 2 years ago

Hi, Thanks for developing this tool! When I use it, I found the generation time for later generations becomes smaller and smaller. Intuitively, I can explain it as the programs converge, but I do not quite understand how it technically achieves this. Even if the programs gradually converge, in each generation, it still needs to undergo tournament selection based on fitness, and then do crossover, replication, and mutation based on the parents' program. Why is the time used to generate later generations less than early generations? Thanks for any clarification.

(some results from my code:

generation_time (in sec) for 30 generations:

[1754.6549005508423, 1022.8551511764526, 813.5316517353058, 787.0290083885193, 952.5349950790405, 1036.9426124095917, 1279.1931009292603, 1213.6020560264587, 1003.6455512046814, 722.122278213501, 467.26189613342285, 241.77101802825928, 173.08998942375183, 112.58735489845276, 60.181232929229736, 88.70745420455933, 114.37861943244934, 146.17656683921814, 90.55016803741455, 101.32579016685486, 119.86616730690002, 154.69795751571655, 187.64493775367737, 165.23964071273804, 210.00622010231018, 211.79804468154907, 220.92804646492004, 205.57106351852417, 227.38415336608887, 177.15054440498352]

As you can see, the generation time generally has a downtrend)