예제 #1
0
  // Crossover individuals
  private static Individual crossover(Individual indiv1, Individual indiv2, EventList eventList) {
    Individual newSol = new Individual(indiv1.geneSize(), eventList);

    for (int i = 0; i < indiv1.geneSize(); i++) {
      // Crossover
      if (Math.random() <= uniformRate) {
        newSol.setGene(i, indiv1.getGene(i));
      } else {
        newSol.setGene(i, indiv2.getGene(i));
      }
    }
    return newSol;
  }