DEAP / deap

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

question about the height of gp tree #731

Open cghsncg opened 11 months ago

cghsncg commented 11 months ago

I use the code "toolsbox.decorate("mate", gp.staticLimit(key=operator.attrgetter("height"), max_value=12))" to set the limit of the tree but when I use the code "toolsbox.mate(child1, child2)" after many steps, deap shows that "Error in tree evaluation : Python cannot evaluate a tree higher than 90. To avoid this problem, you should use bloat control on your operators." Is there any where ,I need to add new hight limit code? Thanks a lot !

Mujtaba1986 commented 8 months ago

Do it like this `# bloat control: LIMIT_TREE_HEIGHT = 50 toolbox.decorate("mate", gp.staticLimit(key=operator.attrgetter("height"), max_value=LIMIT_TREE_HEIGHT)) toolbox.decorate("mutate", gp.staticLimit(key=operator.attrgetter("height"), max_value=LIMIT_TREE_HEIGHT))

toolbox.decorate("mate", gp.staticLimit(key=len, max_value=limitLength)) toolbox.decorate("mutate", gp.staticLimit(key=len, max_value=limitLength)) `