Class Chromosome

java.lang.Object
  extended by Chromosome

public class Chromosome
extends java.lang.Object


Field Summary
static double CROSSOVER_RATE
          A constant that specifies the cross over rate (see crossover).
static double MUTATION_RATE
          A constant that specifies the mutation rate (see mutate).
static int OVERLAP_PENALTY
          A penalty that will be applied for each overlapping constituent.
 
Constructor Summary
Chromosome(Chromosome other)
          A constructor that initializes the content of this Chromosome with that of other.
Chromosome(java.lang.String chain)
          A constructor that initializes this chromosome with random moves for this chain.
 
Method Summary
 Chromosome crossOver(Chromosome other)
          With probability CROSSOVER_RATE the method returns a new Chromosome consisting of a certain number of contiguous genes from this solution and the rest of the genes coming from other.
 java.lang.String getChain()
          Returns the chain of constitents of this chromosome.
 int getFitness()
          Returns an integer value that reflects the quality of the solution.
 Move getGene(int pos)
          Returns the value of the gene at the given position of the chromosome.
 void mutate()
          Applies mutations to this chromosome.
 int size()
          Returns the size of this chromosome, which is the number of genes.
 java.lang.String toString()
          Returns a String representation of this Chromosome.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

OVERLAP_PENALTY

public static final int OVERLAP_PENALTY
A penalty that will be applied for each overlapping constituent. The value is this constant is 100.

See Also:
Constant Field Values

MUTATION_RATE

public static final double MUTATION_RATE
A constant that specifies the mutation rate (see mutate). The suggested value is 0.1%.

See Also:
Constant Field Values

CROSSOVER_RATE

public static final double CROSSOVER_RATE
A constant that specifies the cross over rate (see crossover). The suggested value is 60%.

See Also:
Constant Field Values
Constructor Detail

Chromosome

public Chromosome(java.lang.String chain)
A constructor that initializes this chromosome with random moves for this chain.

Parameters:
chain - the chain of constituents

Chromosome

public Chromosome(Chromosome other)
A constructor that initializes the content of this Chromosome with that of other.

Parameters:
other - is an other Chromomose
Method Detail

getFitness

public int getFitness()
Returns an integer value that reflects the quality of the solution. Small negative values are best, larget positive values indicate solutions with overlapping constituents. The fitness value of a chromosome is the difference of two terms, one for the overlapping constituents and the other for the hydrophobic contacts. The first term is the number of overlapping constituents times OVERLAP_PENALTY. The second term is the number of non-contiguous hydrophobic constituents that are adjacent in the folded chain. E.g. a solution that has no overlapping constituents and forms two hydrophobic contacts has a fitness of -2, a solution that has four overlapping constituents and forms 6 hydrophobic contacts has a fitness value of 394.

Returns:
the fitness value of this solution

crossOver

public Chromosome crossOver(Chromosome other)
With probability CROSSOVER_RATE the method returns a new Chromosome consisting of a certain number of contiguous genes from this solution and the rest of the genes coming from other. Otherwise, the returned solution is a copy of this one.

Parameters:
other - the other chromosome that will be used for the crossover
Returns:
a new chromosome resulting from the crossover of this and the other parent

mutate

public void mutate()
Applies mutations to this chromosome. Each gene of the chromosome has MUTATION_RATE chances of being mutated.


toString

public java.lang.String toString()
Returns a String representation of this Chromosome. Here is an example.
Chromosome [fitness=-2, genes=[Down, Right, Right, Up, Left, Up, Right], chain=hphpphhp]

Overrides:
toString in class java.lang.Object
Returns:
the String representation of this Chromosome

size

public int size()
Returns the size of this chromosome, which is the number of genes.

Returns:
returns the size of the chromosome, which is the number of genes.

getGene

public Move getGene(int pos)
Returns the value of the gene at the given position of the chromosome. The first gene is found at position 0.

Parameters:
pos - the given position
Returns:
returns the gene at the given position.

getChain

public java.lang.String getChain()
Returns the chain of constitents of this chromosome.

Returns:
returns the chain of constituents.