These are chat archives for DEAP/deap

10th
Jul 2016
Eddie Pantridge
@erp12
Jul 10 2016 02:57

Hi all,
Quick question on using toolbox.decorate() to prevent gp tree's from exceeding a depth of 90, and causing a crash.
Let's say that the only operators I am using to change the trees are mate and mutate. Would the following two lines be enough to always keep my trees small enough?

toolbox.decorate("mate", gp.staticLimit(key=operator.attrgetter("height"), max_value=89))
toolbox.decorate("mutate", gp.staticLimit(key=operator.attrgetter("height"), max_value=89))

or am I not understanding things correctly?

François-Michel De Rainville
@fmder
Jul 10 2016 12:35
This message was deleted
François-Michel De Rainville
@fmder
Jul 10 2016 12:43
@erp12 Yes, but if you use your own algorithm, be sure to use the returned infividuals of the variation. Normally, the individuals modified inplace are the same as the ones returned except when using decoration. In fact, it is recommended in every situation to use the returned individuals to avoid confusion.
@erp12 Moreover, a static limit of 17 has often proven more than enough in most problems. A full tree at this depth has 131072 nodes!
Eddie Pantridge
@erp12
Jul 10 2016 19:33
Thanks @fmder. I am still a bit unclear about decorations in general. Does the decoration I mentioned above check to make sure that the child produced by "mate" and "mutate" have a depth less than 89? or does it check to make sure that the no more than 89 nodes are added to the existing tree (which might be already be large)?
Eddie Pantridge
@erp12
Jul 10 2016 19:39
To give some context: I am trying to test the difference between a few selection methods I have written. I am running a modified version of the even parity problem. I have been testing with 3 to 5 input bits, but I am taking out the 'xor' primitive. This makes it much harder. I need my population size to be 100 or higher, and when comparing to some literature I should expect well over 100 generations as well. It seems when I let DEAP run for that long, it always crashed due to a tree reaching above 90 depth.
I still get this problem when adding decorations, although it seems I can have longer generations. Ideally, I would like to add something that forces trees to stay below a depth of 90, and not just encourages it. Are the decorations still what I am looking for?
Eddie Pantridge
@erp12
Jul 10 2016 20:06
Using @fmder 's warning about using returned individuals instead of inplace ones solved my problem, but I just want to make sure I am understanding what is happening when I set the max_value to 17 or 89 or any other number.
François-Michel De Rainville
@fmder
Jul 10 2016 21:06
@erp12 If a child or mutant has higher than max_value depth, the parent or pre-mutated individual is returned.
Hakim
@h4k1m0u
Jul 10 2016 21:16
In Deap's implementation of the tournament selection, it's possible that the same individual is selected multiple times in the produced population, right?
François-Michel De Rainville
@fmder
Jul 10 2016 21:34
@h4k1m0u yes
Eddie Pantridge
@erp12
Jul 10 2016 22:52
@fmder Thanks a bunch. That clears it up.