Answers.Body: <p>You have two broad categories of options, prevention and repair.</p>
  
  <p>Prevention means defining a crossover and mutation operator that try to be more intelligent about respecting the constraints. Suppose you have an encoding where each individual is a list of integers, and the constraint is that there can't be duplicates. You might define a crossover operator that did something like the following. For each position in the offspring, choose randomly from one parent such that, if possible, you choose a value that hasn't already appeared in the offspring. If both parents have values at that position that are already used in the offspring, choose a random value.</p>
  
  <p>That operator would avoid violating the constraint in the first place, while attempting as much as possible to have the offspring inherit information from the parents.</p>
  
  <p>Another option is to just let the operator violate constraints and then deal with the ramifications afterward. You don't go into details about what your constraints actually are, just that <code>c1=[0.1, 0.6, 0.7]</code> violates them. Let's say the constraint is that the third position should not be more than 4x greater than the first one. OK, so then let's take this offspring and adjust either the first or third item. Maybe we make the new individual into <code>c1=[0.2, 0.6, 0.7]</code>.</p>
  
  <p>Often, you want some element of randomness in either option so that you don't strongly bias the production of new search points. In my example, don't always make the first element larger. Sometimes, make the third element smaller or produce some random combination of both to repair the constraint violation.</p>
  
  <p>Finally, both options typically strongly benefit from domain knowledge. Design an operator that understands your problem and tries to intelligently solve the problem.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-08T15:37:28.287Z
Answers.LastActivityDate: 2019-02-08T15:37:28.287Z
Answers.UserDisplayName: deong
Body: <p>I have chromosomes with floating-point representation with values between <span class="math-container">$0$</span> and <span class="math-container">$1$</span>. For example</p>
  <p>Let <span class="math-container">$p_1 = [0.1, 0.2, 0.3]$</span> and <span class="math-container">$p_2 = [0.5, 0.6, 0.7]$</span> be two parents. Both comply with the set of constraints. In my case, the major constraint is <span class="math-container">$$ p_1[1]*p_1[2] - k*p_1[0] \geq 0 $$</span> for any chromosome <span class="math-container">$p_1$</span>. For the example above we can take <span class="math-container">$k=0.3$</span>, which renders <span class="math-container">$c_2$</span> infeasible.</p>
  <p>However, the children produced by 1 point crossover, we get <span class="math-container">$c_1 = [0.1, 0.6, 0.7]$</span> and <span class="math-container">$c_2 = [0.5, 0.2, 0.3]$</span> out of which 1 or both may not comply with the given constraints.</p>
  <p>A similar scenario can also occur with a small perturbation of values due to mutation strategy. Correct me if I am wrong in the belief that such kind of scenarios might arise irrespective of the strategy employed for crossover and mutation.</p>
  <p>What are the options to handle such kinds of cases?</p>
  
Tags: <genetic-algorithms><crossover-operators><mutation-operators><constrained-optimization>
Title: How to handle infeasibility caused due to crossover and mutation in genetic algorithm for optimization?
UserDisplayName: CharcoalG
ThreadText: # How to handle infeasibility caused due to crossover and mutation in genetic algorithm for optimization?
  
  (Asked by: username_0 on 2019-02-08)
  
  I have chromosomes with floating-point representation with values between $0$ and $1$. For example
  
  Let $p\_1 = [0.1, 0.2, 0.3]$ and $p\_2 = [0.5, 0.6, 0.7]$ be two parents. Both comply with the set of constraints. In my case, the major constraint is $$ p\_1[1]\*p\_1[2] - k\*p\_1[0] \geq 0 $$ for any chromosome $p\_1$. For the example above we can take $k=0.3$, which renders $c\_2$ infeasible.
  
  However, the children produced by 1 point crossover, we get $c\_1 = [0.1, 0.6, 0.7]$ and $c\_2 = [0.5, 0.2, 0.3]$ out of which 1 or both may not comply with the given constraints.
  
  A similar scenario can also occur with a small perturbation of values due to mutation strategy. Correct me if I am wrong in the belief that such kind of scenarios might arise irrespective of the strategy employed for crossover and mutation.
  
  What are the options to handle such kinds of cases?
  
  **Tags:** genetic-algorithms, crossover-operators, mutation-operators, constrained-optimization
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-02-08. Score: 1
  
  You have two broad categories of options, prevention and repair.
  
  Prevention means defining a crossover and mutation operator that try to be more intelligent about respecting the constraints. Suppose you have an encoding where each individual is a list of integers, and the constraint is that there can't be duplicates. You might define a crossover operator that did something like the following. For each position in the offspring, choose randomly from one parent such that, if possible, you choose a value that hasn't already appeared in the offspring. If both parents have values at that position that are already used in the offspring, choose a random value.
  
  That operator would avoid violating the constraint in the first place, while attempting as much as possible to have the offspring inherit information from the parents.
  
  Another option is to just let the operator violate constraints and then deal with the ramifications afterward. You don't go into details about what your constraints actually are, just that `c1=[0.1, 0.6, 0.7]` violates them. Let's say the constraint is that the third position should not be more than 4x greater than the first one. OK, so then let's take this offspring and adjust either the first or third item. Maybe we make the new individual into `c1=[0.2, 0.6, 0.7]`.
  
  Often, you want some element of randomness in either option so that you don't strongly bias the production of new search points. In my example, don't always make the first element larger. Sometimes, make the third element smaller or produce some random combination of both to repair the constraint violation.
  
  Finally, both options typically strongly benefit from domain knowledge. Design an operator that understands your problem and tries to intelligently solve the problem.
  
  
  ---
  
  