Var Or and Mutation Probability

107 views
Skip to first unread message

gui...@gmail.com

unread,
Nov 28, 2020, 11:23:43 PM11/28/20
to deap-users
If I understood, while using varOr( ) function the individuals of an offspring are generated by crossover, or mutation, or reproduction, right?
The sum of CXPB and MUTPB must be lesser or equal to 1. 
E.g. if CXPB=0.7 and MUTPB=0.3, a random number r is generated in [0,1] and if r < 0.7 then crossover is performed, on other hand mutation is performed. 
In this case a indpb = 0.05 is the probability of the value of a gene being changed?

Please correct me  if I'm wrong. If there is some literature about this variation Or  that anyone can recommend me I will be very grateful.

Thank in advance

baldini...@gmail.com

unread,
Dec 24, 2020, 9:26:09 AM12/24/20
to deap-users
The code speaks itself:

       op_choice = random.random()
       if op_choice < cxpb:            # Apply crossover
            ...
      elif op_choice < cxpb + mutpb:  # Apply mutation
            ....
     else:                           # Apply reproduction

For what concern indpb, it usually indicate the "individual probability", that is the probabilty that a given variation will be applied to a given gene. Refering to mutation operator, it could be the probability that each gene is mutated. Needless to say, if varOr choose to mutate the individual, that individual could be not varied at all with some chances.

François-Michel De Rainville

unread,
Dec 29, 2020, 7:11:11 AM12/29/20
to deap-...@googlegroups.com
As for the literature, unfortunately I don’t recall where we took the idea.



--
You received this message because you are subscribed to the Google Groups "deap-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to deap-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/deap-users/24874d82-47ae-47d0-9306-07f615bdb2bcn%40googlegroups.com.

gui...@gmail.com

unread,
Feb 16, 2021, 11:52:39 AM2/16/21
to deap-users
Thank for your answers. I read the source in github and now I think I'm understanding the VarOr function. This variarion doesn't need a parent selection method, right?
...

if op_choice < cxpb: # Apply crossover
    ind1, ind2 = map(toolbox.clone, random.sample(population, 2))
    ind1, ind2 = toolbox.mate(ind1, ind2)
    del ind1.fitness.values
   offspring.append(ind1)
...
The parents are selected always from random if I understood

thanks in advance

Rachel

unread,
Feb 19, 2021, 3:29:51 AM2/19/21
to deap-users
VarOr function means that an offspring will always result from mutation OR crossover operation (never from both simultaneously). 
VarAnd function means that an offspring can result from mutation and crossover simultaneously, but it is also capable of resulting from mutation only or crossover only according to the assigned probabilities. 

You can check out more details about each function here: https://github.com/DEAP/deap/blob/master/deap/algorithms.py
Reply all
Reply to author
Forward
0 new messages