jenes.tutorials.problem3
Class TSPCityCenteredCrossover

java.lang.Object
  extended by jenes.stage.AbstractStage<T>
      extended by jenes.stage.operator.Operator<T>
          extended by jenes.stage.operator.Crossover<IntegerChromosome>
              extended by jenes.tutorials.problem3.TSPCityCenteredCrossover

public class TSPCityCenteredCrossover
extends Crossover<IntegerChromosome>

Tutorial showing how to implement problem specific operators. The problem faced in this example is the well known Tavel Salesman Problem (TSP) This class implements a specific crossover aimed at preserving permutations. Algorithm description:

      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 6
We repeat these steps for child2

Since:
1.0
Version:
1.0
Author:
Luigi Troiano, Pierpaolo Lombardi

Nested Class Summary
 
Nested classes/interfaces inherited from class jenes.stage.operator.Crossover
Crossover.Statistics
 
Field Summary
 
Fields inherited from class jenes.stage.operator.Crossover
probability
 
Fields inherited from class jenes.stage.operator.Operator
random, statistics
 
Fields inherited from class jenes.stage.AbstractStage
biggerIsBetter, ga
 
Constructor Summary
TSPCityCenteredCrossover(double pCross)
           
 
Method Summary
protected  void cross(Individual<IntegerChromosome>[] offsprings)
          This method implements the crossover operation.
protected  int spread()
          Returns the number of chromosomes (i.e. 2) this operator entails.
 
Methods inherited from class jenes.stage.operator.Crossover
getProbability, init, process, setProbability
 
Methods inherited from class jenes.stage.operator.Operator
getStatistics, updateStatistics
 
Methods inherited from class jenes.stage.AbstractStage
dispose, isBiggerBetter, setBiggerIsBetter, setBiggerIsBetter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TSPCityCenteredCrossover

public TSPCityCenteredCrossover(double pCross)
Method Detail

spread

protected int spread()
Returns the number of chromosomes (i.e. 2) this operator entails.

Specified by:
spread in class Crossover<IntegerChromosome>
Returns:
the number of individuals required by crossover

cross

protected void cross(Individual<IntegerChromosome>[] offsprings)
This method implements the crossover operation.

Specified by:
cross in class Crossover<IntegerChromosome>
Parameters:
offsprings - the chromosomes to be crossed.