Class Chromosome

java.lang.Object
  |
  +--Chromosome

public class Chromosome
extends java.lang.Object

Chromosome representation of vehicle routes.

Since:
2002

Constructor Summary
Chromosome(int length)
          Creates a chromosome with customers randomly distributed.
Chromosome(int[] gene)
          Creates a chromosome based on an already defined array of customers.
Chromosome(java.util.Vector genes)
          Creates a chromosome based on an already defined Vector of customers.
 
Method Summary
 int getGene(int i)
          Gets the gene at a certain location within the chromosome.
 int getSize()
           
 void swap(int i, int j)
          Swaps two genes in a chromosome.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Chromosome

public Chromosome(int length)
Creates a chromosome with customers randomly distributed.

Parameters:
length - Number of customers.

Chromosome

public Chromosome(int[] gene)
Creates a chromosome based on an already defined array of customers.

Parameters:
gene - Array of customers reperesented as ints.

Chromosome

public Chromosome(java.util.Vector genes)
Creates a chromosome based on an already defined Vector of customers.

Parameters:
genes - Vector of customers represented as Integers.
Method Detail

swap

public void swap(int i,
                 int j)
Swaps two genes in a chromosome.

Parameters:
i - First gene to be swapped.
j - Second gene to be swapped.

getGene

public int getGene(int i)
Gets the gene at a certain location within the chromosome.

Parameters:
i - Location within the chromosome.
Returns:

getSize

public int getSize()
Returns:
Number of genes in a chromosome.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
List of genes separeated with dashes.