Pyevolve icon indicating copy to clipboard operation
Pyevolve copied to clipboard

Added generic GP with value types support

Open tomerf opened this issue 13 years ago • 1 comments

GP tree can now define value types to nodes in the tree. It now support building trees with mixed types, like integers and booleans.

tomerf avatar Oct 01 '12 17:10 tomerf

Yes, that's exactly what my patch does. I already forgot about it, so now I need to reverse engineer it. Or not, apparently I also posted the modifications and explanation on the pyevolve google group :) What I do is detect the function prefix by the input/output types and set a different prefix for each combo, e.g.:

ga.setParams(gpi_terminals = ['x', 'y', 'ephemeral:random.randint(-10,10)', gpii_function_prefix = "gp_i_", gpbi_function_prefix = "gp_i2b_", gpbb_function_prefix = "gp_b_")

The first character is the output type and the second is the input type. So, in this example the first prefix is from integer ('i') to integer ('i'), the second is from input integer ('i') to output boolean ('b') and the last is boolean ('b') to boolean ('b').

It is also "invisible" if one doesn't want to define multiple types, since the default type has an empty prefix ('') so it shouldn't break any existing programs that use pyevolve.

I haven't figured what how to mix multiple input types, it's just the basic framework and should be extended. And probably be more user friendly before...

tomerf avatar May 25 '13 20:05 tomerf