title: Non-Dominated Rank based Sorting Genetic Algorithm Elitism Issue
body: <p>I am trying to implement a genetic algorithm for my Master's Thesis relating to satellite constellation design.  I want to obtain pareto-fronts for multiple objective functions.  I am writing my own algorithm based on a Non-Dominated Rank based Sorting Genetic Algorithm by Ashish Ghosh and Mrinal Kanti Das ( <a href="http://www.isical.ac.in/~ash/Mrinal-fi-08.pdf" rel="nofollow">http://www.isical.ac.in/~ash/Mrinal-fi-08.pdf</a> ) which is based on the NSGA-II.  This algorithm uses elitism by combining the parent and child populations into a single set of individuals, size 2N, and then selecting the N best individuals to become the new child population, where N is the size of the initial population.  The fitness is based on non-dominated fronts, the ranking within each front, and the spacing between individuals in that front. </p>
  
  <p>The algorithm I wrote works fine until nearly every individual in the combined parent/child population is in the first non-dominated front (they are all non-dominated).  When this occurs, the only thing that distinguishes fitness between every individual is the spacing between individuals.  Therefore, I could have an individual that performs very well and should be passed on to the next generation, but it does not get selected for because it may be close to another individual.  If I take a plot of every solution over the entire GA run, there are some solutions in the first non-dominated front at the end of the GA that are dominated by previous individuals that did not get passed on to the next generation.  This could be a problem with my code, but after thinking about the way the algorithm works, I am wondering if it is a problem with the algorithm.  </p>
  
  <p>Thanks for your help!</p>
  
  <p>Here is my Pseudo Code:</p>
  
  <ol>
  <li><p>Initialize random population of size N.</p></li>
  <li><p>Compute the fitness, f, of each individual for each objective function.</p></li>
  <li><p>Classify each individual into non-dominated fronts (non-dominated solutions go into first front, then discard solutions in first front and the next set of non-dominated solutions go into second front, until entire population is sorted into sets of non-dominated fronts).</p></li>
  <li><p>Assign ranks to each solution, where the rank of solution i is the number of solutions that dominate solution i.</p></li>
  <li><p>Calculate the minimum distance between solution i and the next closest solution in the same front as solution i, for all i.</p></li>
  <li><p>Compute the new fitness value, F, based on front, rank, and minimum distance:</p>
  
  <p>The average fitness value Favg is assigned to the first front where Favg(i) = N for all solutions i in front 1 and N = number of individuals in population</p>
  
  <p>The average fitness for each individual in current front is then adjusted based on rank where, Fadj(i) = Favg(i) – g(i) for all solutions i in current front, and where g(i) is the number of solutions in the same front as solution I having rank less than or equal to that of solution i</p>
  
  <p>The density factor is then considered where F(i) = Fadj(i) – 1/Min, where Min is the minimum distance between solution I and the next closest solution in the same front as solution i, and F(i) is the final fitness value of solution i</p>
  
  <p>If Fj is the minimum fitness of solution j and Fj &lt; 0 then add (0 – Fj) to the fitness of all solutions to make them positive</p>
  
  <p>The Favg value is assigned for the next front, Favg(ii) = Favg(i) – e, where e is some small value thereby ensuring the fitness values of front f is less than that of any solution of front f-1</p></li>
  <li><p>Next perform the genetic operations (tournament based selection, crossover, and mutation) to obtain a child population of size N.</p></li>
  <li><p>Compute the fitness, f, of each individual in the child population for each objective function.</p></li>
  <li><p>Combine the parent population and child population into a single set of size 2N.</p></li>
  <li><p>Next repeat steps 3-6 to classify and compute the fitness F of the combined parent/child population.</p></li>
  <li><p>Perform elitism by sorting the fitness values, F, of the combined population.  Select the best N individuals which will become the new child population.</p></li>
  <li><p>Repeat from step 3 until the maximum number of generations is reached.</p></li>
  </ol>