Hi everyone,
The question is how to correctly works with custom types in GP module?
I have the code below:
pset = gp.PrimitiveSet("main", 0)
pset.addPrimitive(split,2,name="split")
pset.addEphemeralConstant("atom",lambda : random.choice(atom_set))
pset.addEphemeralConstant("nums",lambda : random.randint(0,4))
random.choice(atom_set) returns string.
But if I try to use a custom class, I face an error.
pset = gp.PrimitiveSet("main", 0)
pset.addPrimitive(split,2,name="split")
pset.addEphemeralConstant("atom",lambda : Atom(random.choice(atom_set)))
pset.addEphemeralConstant("nums",lambda : random.randint(0,4))
split(split(split(<__main__.Atom instance at 0x000000000DAF86C8>, 1)....
SyntaxError: invalid syntax
It seems as all arguments of functions were converted to strings. How to avoid that? How to use types in GP module?