strongly typed GP mixing boolean and float vectors

29 views
Skip to first unread message

Martin Karas

unread,
Jun 22, 2022, 6:34:58 AM6/22/22
to deap-users
Hi guys,

in vectorized strongly typed GP i want to separate boolean and float numpy arrays.
Primitives looks like this:

class bool_array(numpy.ndarray):
    pass
   
def if_then_else(input, output1, output2):
    return numpy.where(input,output1,output2)

pset.addPrimitive(operator.add, [numpy.ndarray, numpy.ndarray], numpy.ndarray)

pset.addPrimitive(numpy.logical_and, [bool_array, bool_array], bool_array)

pset.addPrimitive(if_then_else, [bool_array, numpy.ndarray, numpy.ndarray], numpy.ndarray)

pset.addPrimitive(numpy.less, [numpy.ndarray, numpy.ndarray], bool_array)


but since the bool_array class is inherited from numpy.ndarray those two types of arrays (float and boolean) are now interchangable which is not what i want to acheive. How do i separate those two classes? How to create separate classes for float and boolean numpy arrays?
 

Reply all
Reply to author
Forward
0 new messages