Operator.Operations
Class SinglePointCrossover

java.lang.Object
  extended by Operator.Operations.CrossoverOperation
      extended by Operator.Operations.SinglePointCrossover
All Implemented Interfaces:
Operation, ParameterI, Stochastic

public class SinglePointCrossover
extends CrossoverOperation

Single point crossover.

Version:
2007.0305
Author:
Blip

Field Summary
protected  boolean codonsUsedSensitive
           
protected  boolean fixedCrossoverPoint
           
 
Fields inherited from class Operator.Operations.CrossoverOperation
probability, rand
 
Constructor Summary
SinglePointCrossover(double prob, RandomNumberGenerator m)
          Creates a new instance of SinglePointCrossover
SinglePointCrossover(RandomNumberGenerator m, double prob)
          Creates a new instance of SinglePointCrossover
SinglePointCrossover(RandomNumberGenerator m, java.util.Properties p)
          New instance
 
Method Summary
 void doOperation(Individual operands)
          Performs the operation on an operand
 void doOperation(java.util.List<Individual> operands)
          Performes crossover on the 2 first individuals in the incoming list.
protected  int getMaxXOPoint(GEIndividual i)
          Get xover max point based on used codons.
protected  int getXoverPoint(int length1, int length2)
          Get the crossover point within the shortest of the incoming chromosomes
 boolean isFixedCrossoverPoint()
          Chech is the crossover point is fixed
static void main(java.lang.String[] args)
           
 int[] makeNewChromosome(GEChromosome c1, GEChromosome c2, int p1maxXOPoint, int p2maxXOPoint)
          Creates the new chromsome, with fixed crossver point or not, and returns the crossover points on the individuals.
 int[] performCrossover(GEIndividual indiv1, GEIndividual indiv2, GEChromosome chrome1, GEChromosome chrome2, int chrome1MaxXOPoint, int chrome2MaxXOPoint)
          This method actually performs the crossover and returns an int array with the crossover points.
 void setFixedCrossoverPoint(boolean fixedCrossoverPoint)
          Set crossover point to be fixed (same on both chromsomes) or not fixed
 void setProperties(java.util.Properties p)
          Set properties
 
Methods inherited from class Operator.Operations.CrossoverOperation
getRNG, setRNG
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fixedCrossoverPoint

protected boolean fixedCrossoverPoint

codonsUsedSensitive

protected boolean codonsUsedSensitive
Constructor Detail

SinglePointCrossover

public SinglePointCrossover(RandomNumberGenerator m,
                            double prob)
Creates a new instance of SinglePointCrossover

Parameters:
m - random number generator
prob - crossover probability

SinglePointCrossover

public SinglePointCrossover(double prob,
                            RandomNumberGenerator m)
Creates a new instance of SinglePointCrossover

Parameters:
m - random number generator
prob - crossover probability

SinglePointCrossover

public SinglePointCrossover(RandomNumberGenerator m,
                            java.util.Properties p)
New instance

Parameters:
m - random number generator
p - properties
Method Detail

setProperties

public void setProperties(java.util.Properties p)
Set properties

Specified by:
setProperties in interface ParameterI
Overrides:
setProperties in class CrossoverOperation
Parameters:
p - object containing properties

doOperation

public void doOperation(Individual operands)
Description copied from interface: Operation
Performs the operation on an operand

Parameters:
operands - operand to perform operation on

doOperation

public void doOperation(java.util.List<Individual> operands)
Performes crossover on the 2 first individuals in the incoming list. Depending on the crossover probability.

Specified by:
doOperation in interface Operation
Specified by:
doOperation in class CrossoverOperation
Parameters:
operands - Individuals to crossover

performCrossover

public int[] performCrossover(GEIndividual indiv1,
                              GEIndividual indiv2,
                              GEChromosome chrome1,
                              GEChromosome chrome2,
                              int chrome1MaxXOPoint,
                              int chrome2MaxXOPoint)
This method actually performs the crossover and returns an int array with the crossover points.

Parameters:
indiv1 - The first individual
indiv2 - The second individual
chrome1 - The first individual's chromosome
chrome2 - The second individual's chromosome
chrome1MaxXOPoint - The first Individual's maximum crossover point
chrome2MaxXOPoint - The second Individual's maximum crossover point
Returns:
int[] The crossover points for each individual

getMaxXOPoint

protected int getMaxXOPoint(GEIndividual i)
Get xover max point based on used codons. If used codons are 0 or not codon use sensitive chromosone length is returned (all are legal).

Parameters:
i - GEIndividual to get find the max XO point
Returns:
int Max crossover point

getXoverPoint

protected int getXoverPoint(int length1,
                            int length2)
Get the crossover point within the shortest of the incoming chromosomes

Parameters:
length1 - Chromsome length 1
length2 - Chromsome length 2
Returns:
The crossover point

makeNewChromosome

public int[] makeNewChromosome(GEChromosome c1,
                               GEChromosome c2,
                               int p1maxXOPoint,
                               int p2maxXOPoint)
Creates the new chromsome, with fixed crossver point or not, and returns the crossover points on the individuals.

Parameters:
c1 - Chromsome 1
c2 - Chromsome 2
p1maxXOPoint - Max crossover point Chromsome 1
p2maxXOPoint - Max crossover point Chromsome 2
Returns:
int[] Crossover points for both individuals

isFixedCrossoverPoint

public boolean isFixedCrossoverPoint()
Chech is the crossover point is fixed

Returns:
true if crossover point is fixed

setFixedCrossoverPoint

public void setFixedCrossoverPoint(boolean fixedCrossoverPoint)
Set crossover point to be fixed (same on both chromsomes) or not fixed

Parameters:
fixedCrossoverPoint - crossverpoint fixation

main

public static void main(java.lang.String[] args)