typed Primitive Set Index Error
Hi,
I was trying to formulate a problem two numpy arrays as terminals and undetermined number of random floats as ephemeral constants. (these random floats are the second input for function fmul that multiples an numpy array with a float).
The tree depth is limited to 10 and I added 300 constants, however i still get the following error.... is there a way to fix it? thanks.
IndexError: The gp.generate function tried to add a primitive of type '<type 'float'>', but there is none available.
`pset = gp.PrimitiveSetTyped("MAIN", [np.ndarray, np.ndarray],np.ndarray, 2) pset.addPrimitive(numpy.add, [np.ndarray, np.ndarray],np.ndarray, name="vadd") pset.addPrimitive(numpy.subtract, [np.ndarray, np.ndarray] ,np.ndarray, name="vsub") pset.addPrimitive(numpy.multiply, [np.ndarray, np.ndarray] ,np.ndarray, name="vmul") pset.addPrimitive(numpy.multiply, [np.ndarray, float] ,np.ndarray, name="fmul") pset.addPrimitive(numpy.negative, [np.ndarray] ,np.ndarray, name="vneg")
#adding many ephemeral constants for i in range(300): pset.addEphemeralConstant("rand%s"%i, lambda: random.randint(-1,1), float)
pset.renameArguments(ARG0='x') pset.renameArguments(ARG1='y') toolbox.register("expr", gp.genHalfAndHalf, pset=pset, min_=1, max_=10)`
Source: DEAP/deap