jenes.chromosome
Interface Chromosome<T extends Chromosome>

Type Parameters:
T - The type of Chromosomes accepted as input and returned by operations.
All Superinterfaces:
java.lang.Cloneable
All Known Implementing Classes:
BitwiseChromosome, BooleanChromosome, DoubleChromosome, IntegerChromosome, ObjectChromosome, PermutationChromosome

public interface Chromosome<T extends Chromosome>
extends java.lang.Cloneable

The abstract class Chromosome is the superclass of all chromosomes, providing the specification of genoma operations used by genetic operators during the algorithm evolution. Concretizations of the Chromosome class are required to actually implement an algorithm. There are some concrete chromosome types based on boolean, double, integer and object values. All of these are fixed length chromosomes, as the number of genes dosen't change during the algorithm iterations.

If necessary, a variable length chromosome can be implemented by subclassing this abstract class and specifying the abstract methods.

Since:
1.0
Version:
1.2
Author:
Luigi Troiano, Pierpaolo Lombardi, Giuseppe Pascale, Thierry Bodhuin

Method Summary
 Chromosome clone()
          Performs a chromosome deep-cloning.
 void cross(T chromosome, int from)
          Exchanges the genes chromosome starting from a given position
 void cross(T chromosome, int from, int to)
          Exchanges the genes chromosome within the range [from,to]
 boolean equals(T chromosome)
          Compares the chromosome with another.
 void leftShift(int from, int to)
          Makes a left-shift of the genes between two positions.
 int length()
          Returns the number of genes contained in the chromosome.
 void randomize()
          Fills the chromosome with random value.
 void randomize(int pos)
          Sets a random value in the specified position
 void rightShift(int from, int to)
          Makes a right-shift of the genes between two positions.
 void setAs(T chromosome)
          Makes the chromosome a copy of another chromosome.
 void setDefaultValueAt(int pos)
          Sets the default value at a given position
 void swap(int pos1, int pos2)
          Exchanges two genes at the specified positions
 

Method Detail

swap

void swap(int pos1,
          int pos2)
Exchanges two genes at the specified positions

Parameters:
pos1 - the position of first gene
pos2 - the position of second gene

randomize

void randomize(int pos)
Sets a random value in the specified position

Parameters:
pos - a position where to set the random value

leftShift

void leftShift(int from,
               int to)
Makes a left-shift of the genes between two positions. The shift is circular, so the most left-side gene becomes the last gene on right.

Parameters:
from - the start position to be shifted
to - the final position to be shifted

rightShift

void rightShift(int from,
                int to)
Makes a right-shift of the genes between two positions. The shift is circular, so the most right-side gene becomes the first gene on left.

Parameters:
from - the start position to be shifted
to - the final position to be shifted

setDefaultValueAt

void setDefaultValueAt(int pos)
Sets the default value at a given position

Parameters:
pos - the position where to set the default value

clone

Chromosome clone()
Performs a chromosome deep-cloning.

Returns:
a chromosome clone.

length

int length()
Returns the number of genes contained in the chromosome.

Returns:
the length of chromosome.

randomize

void randomize()
Fills the chromosome with random value.


setAs

void setAs(T chromosome)
Makes the chromosome a copy of another chromosome.

Parameters:
chromosome - the chromosome to be copied

cross

void cross(T chromosome,
           int from,
           int to)
Exchanges the genes chromosome within the range [from,to]

Parameters:
chromosome - the chromosome to cross with
from - the start position of the genes to exchange
to - the final position of the genes to exchange

cross

void cross(T chromosome,
           int from)
Exchanges the genes chromosome starting from a given position

Parameters:
chromosome - the chromosome to cross with
from - the start position of the genes to exchange

equals

boolean equals(T chromosome)
Compares the chromosome with another.

Parameters:
chromosome - the cromosome to compare to.
Returns:
true if the two chromosome are equal, false otherwise.