Answers.Body: <p>The crossover rate, <span class="math-container">$p_c \in [0, 1]$</span>, is a hyper-parameter that controls the rate at which solutions are subjected to crossover. So, the higher <span class="math-container">$p_c$</span>, the more crossovers you perform, so the more <strong>diversity</strong> (in terms of solutions/chromosomes) you may introduce in the population. Typical values of <span class="math-container">$p_c$</span> are in the range <span class="math-container">$[0.5, 1.0]$</span>.  For example, in <a href="https://github.com/nbro/function_max_with_ga" rel="nofollow noreferrer">this simple implementation</a>, I used <span class="math-container">$p_c = 0.8$</span>. In this case, I manually searched for this value (and it didn't take me much time to make the GA find the solution I was looking for), but in other cases/problems you may need to perform some hyper-parameter optimization (e.g. with grid search).</p>
  <p>The mutation rate, <span class="math-container">$p_m \in [0, 1]$</span> (also a hyper-parameter) controls the rate at which you mutate single chromosomes or the genes of single chromosomes. For example, if you have a binary chromosome of <span class="math-container">$n$</span> bits, you could flip the <span class="math-container">$i$</span>th bit with probability <span class="math-container">$p_m$</span>, for all <span class="math-container">$i$</span> independently. Mutation can <strong>prevent premature convergence</strong>, but, if <span class="math-container">$p_m$</span> is very high, the genetic algorithm becomes a random search, so the value of <span class="math-container">$p_m$</span> is typically not high. <a href="https://ieeexplore.ieee.org/stamp/stamp.jsp?arnumber=286385" rel="nofollow noreferrer">This paper</a> (which you probably should read because it contains more information about the mutation and crossover operations, although it is a bit old) states that typical values are in the range <span class="math-container">$[0.005, 0.05]$</span>, but, in <a href="https://github.com/nbro/function_max_with_ga" rel="nofollow noreferrer">this implementation</a>, I used <span class="math-container">$p_m = 0.5$</span>.</p>
  <p>So, in general, higher values of these rates promote exploration at the expense of exploitation. In this sense, this is similar to the <span class="math-container">$\epsilon$</span> in the <span class="math-container">$\epsilon$</span>-greedy behaviour policy in Q-learning (a famous reinforcement learning algorithm).</p>
  <p>However, note that each of these operations may undo the other operation. For instance, let's suppose that we have the binary chromosomes <span class="math-container">$p_1 = [0, 1, 0]$</span>  and <span class="math-container">$p_2 = [0, 0, 1]$</span>, which we can combine by replacing (with probability <span class="math-container">$p_c$</span>) the bit at position <span class="math-container">$i$</span> of <span class="math-container">$p_1$</span> with the bit of the chromosome <span class="math-container">$p_2$</span> at the same position <span class="math-container">$i$</span>. So, after the crossover, you could get the children <span class="math-container">$c_1 = [0, 0, 0]$</span> and <span class="math-container">$c_2 = [0, 1, 1]$</span>. If you perform a mutation by flipping the bits, then you could end up with the same chromosomes as the original ones, that's also one of the reasons why you may not want to have a very high mutation rate. So, it's not completely true that, the higher the mutation rate, the more you explore, because you can end up with the same solutions as before, so you have not explored anything.</p>
  <p>You could also have an adaptive value for these parameters. See e.g. <a href="https://ieeexplore.ieee.org/stamp/stamp.jsp?arnumber=286385" rel="nofollow noreferrer">this paper</a> for an example of such an adaptive schedule.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-11-27T16:54:01.993Z
Answers.LastActivityDate: 2020-11-28T02:55:49.340Z
Answers.LastEditDate: 2020-11-28T02:55:49.340Z
Answers.UserDisplayName: nbro
Body: <p>What is the impact of using a:</p>
  <ul>
  <li><p>low crossover rate</p>
  </li>
  <li><p>high crossover rate</p>
  </li>
  <li><p>low mutation rate</p>
  </li>
  <li><p>high mutation rate</p>
  </li>
  </ul>
  
Tags: <genetic-algorithms><hyperparameter-optimization><crossover-operators><mutation-operators><genetic-operators>
Title: What is the impact of changing the crossover and mutation rates?
UserDisplayName: fathese
ThreadText: # What is the impact of changing the crossover and mutation rates?
  
  (Asked by: username_0 on 2020-11-25)
  
  What is the impact of using a:
  
  * low crossover rate
  * high crossover rate
  * low mutation rate
  * high mutation rate
  
  **Tags:** genetic-algorithms, hyperparameter-optimization, crossover-operators, mutation-operators, genetic-operators
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-11-27. Score: 3
  
  The crossover rate, $p\_c \in [0, 1]$, is a hyper-parameter that controls the rate at which solutions are subjected to crossover. So, the higher $p\_c$, the more crossovers you perform, so the more **diversity** (in terms of solutions/chromosomes) you may introduce in the population. Typical values of $p\_c$ are in the range $[0.5, 1.0]$. For example, in [this simple implementation](https://github.com/nbro/function_max_with_ga), I used $p\_c = 0.8$. In this case, I manually searched for this value (and it didn't take me much time to make the GA find the solution I was looking for), but in other cases/problems you may need to perform some hyper-parameter optimization (e.g. with grid search).
  
  The mutation rate, $p\_m \in [0, 1]$ (also a hyper-parameter) controls the rate at which you mutate single chromosomes or the genes of single chromosomes. For example, if you have a binary chromosome of $n$ bits, you could flip the $i$th bit with probability $p\_m$, for all $i$ independently. Mutation can **prevent premature convergence**, but, if $p\_m$ is very high, the genetic algorithm becomes a random search, so the value of $p\_m$ is typically not high. [This paper](https://ieeexplore.ieee.org/stamp/stamp.jsp?arnumber=286385) (which you probably should read because it contains more information about the mutation and crossover operations, although it is a bit old) states that typical values are in the range $[0.005, 0.05]$, but, in [this implementation](https://github.com/nbro/function_max_with_ga), I used $p\_m = 0.5$.
  
  So, in general, higher values of these rates promote exploration at the expense of exploitation. In this sense, this is similar to the $\epsilon$ in the $\epsilon$-greedy behaviour policy in Q-learning (a famous reinforcement learning algorithm).
  
  However, note that each of these operations may undo the other operation. For instance, let's suppose that we have the binary chromosomes $p\_1 = [0, 1, 0]$ and $p\_2 = [0, 0, 1]$, which we can combine by replacing (with probability $p\_c$) the bit at position $i$ of $p\_1$ with the bit of the chromosome $p\_2$ at the same position $i$. So, after the crossover, you could get the children $c\_1 = [0, 0, 0]$ and $c\_2 = [0, 1, 1]$. If you perform a mutation by flipping the bits, then you could end up with the same chromosomes as the original ones, that's also one of the reasons why you may not want to have a very high mutation rate. So, it's not completely true that, the higher the mutation rate, the more you explore, because you can end up with the same solutions as before, so you have not explored anything.
  
  You could also have an adaptive value for these parameters. See e.g. [this paper](https://ieeexplore.ieee.org/stamp/stamp.jsp?arnumber=286385) for an example of such an adaptive schedule.
  
  
  ---
  
  