PrimitiveSet

39 views
Skip to first unread message

akhil patel

unread,
Nov 14, 2017, 11:10:06 AM11/14/17
to deap-users
This maybe a bit basic but can someone explain how exactly the components from here addPrimitive, addterminal and addEphemral are actually used to construct the individual?
What is the point of the terminal? For example here with just these primitives what would be an individual construction example? This is taken from the spambase example but I cant see anywhere that the primitives are actually used.
 
pset.addPrimitive(operator.add, [float,float], float)
pset.addPrimitive(operator.sub, [float,float], float)
pset.addPrimitive(operator.mul, [float,float], float)
pset.addPrimitive(protectedDiv, [float,float], float)

# logic operators
# Define a new if-then-else function
def if_then_else(input, output1, output2):
    if input: return output1
    else: return output2

pset.addPrimitive(operator.lt, [float, float], bool)
pset.addPrimitive(operator.eq, [float, float], bool)
pset.addPrimitive(if_then_else, [bool, float, float], float)

# terminals
pset.addEphemeralConstant("rand100", lambda: random.random() * 100, float)
pset.addTerminal(False, bool)
Reply all
Reply to author
Forward
0 new messages