Crossover Algorithm Implementation

I started to dig into GA a little to study, and I can not find the answer to the crossover generation breakpoints. For example, if I start with my parents:
Father = [A,B,B,A,C]
Mother = [D,D,B,A,A]

At what point can I legally stop producing children to prove that all possible combinations have been exhausted? The code is as follows:

void reproduce(String[] father, String[] mother) {
double choice = Math.random() * 100;
if((int) choice % 10 < 2){
//start at father[1] and swap.
//Continue for other choices

This is a small part regarding the logic I use. So my question goes back to how can I legally determine when to stop creating children? Or is it just a math problem when I should just look at the direct permutation generator and ignore GA at the moment?

+3
source share
2 answers

. .

public String[] reproduce(String[] father, String[] mother) {
  int[] child=new String[father.length];
  int crossPoint = Math.random()*father.length;//make a crossover point
  for (int i=0;i<father.length;++i)
  {
    if (i<crossPoint)
      child[i]=father[i];
    else
      child[i]=mother[i];
  }
  return child;
}

, . , , .

+2

, , X . , . , , GA.

+1

Source: https://habr.com/ru/post/1767805/


All Articles