public class TSPCityCenteredCrossover extends Crossover<IntegerChromosome>
parent1 5 2 1 4 6 3 parent2 1 3 2 4 6 5 child1 _ _ _ _ _ _ child2 _ _ _ _ _ _Step 1: a city is choosed randomly. We copy all the cities until the selected one from each parent to each child (parent1 in child1 and parent2 in child2)
parent1 5 2 1 4 6 3 parent2 1 3 2 4 6 5 child1 5 2 _ _ _ _ child2 1 3 2 _ _ _Step 2: we fill child1 getting missing elements from parent2; these ones will have the same parent2 order
parent1 5 2 1 4 6 3 parent2 1 3 2 4 6 5 child1 5 2 1 3 4 6 child2 1 3 2 5 4 6We repeat these steps for child2
Crossover.Statistics
probability
random, statistics
biggerIsBetter, fitness, ga
Constructor and Description |
---|
TSPCityCenteredCrossover(double pCross) |
Modifier and Type | Method and Description |
---|---|
protected void |
cross(Individual<IntegerChromosome>[] offsprings)
This method implements the crossover operation.
|
int |
spread()
Returns the number of chromosomes (i.e. 2) this operator entails.
|
getProbability, init, process, setProbability
getStatistics, updateStatistics
dispose, getFitness, isBiggerBetter, isFitnessChanged, setBiggerIsBetter, setBiggerIsBetter, setFitness, setFitness
public int spread()
spread
in class Crossover<IntegerChromosome>
protected void cross(Individual<IntegerChromosome>[] offsprings)
cross
in class Crossover<IntegerChromosome>
offsprings
- the chromosomes to be crossed.