be.optiloading
Class Chromosome

java.lang.Object
  extended by be.optiloading.Chromosome
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<Chromosome>

public class Chromosome
extends java.lang.Object
implements java.lang.Comparable<Chromosome>, java.lang.Cloneable, java.io.Serializable

Chromosome class which stores properties of each chromosome and handles methods as creation, mutation and crossover.

Author:
Tim Pintens, info@optiloading.be, www.optiloading.be
See Also:
Serialized Form

Constructor Summary
Chromosome()
          Constructor which creates a new Chromosome using the full tank method.
Chromosome(boolean chose)
          Constructor which creates a new Chromosome using the random tank method.
 
Method Summary
 java.lang.Object clone()
          clone method is the overwritten method of the Object object which also copies the ArrayList of volumes.
 int compareTo(Chromosome c)
          compareTo method is the overwritten method of the Object object which tells how two Chromosomes should be compared.
 void crossOverMean(Chromosome other)
          crossOverMean method is used to perform a crossover where the the mean value of each tank volume is taken.
 void crossOverOnePoint(Chromosome other)
          crossOverOnePoint method is used to perform a crossover where until a certain point we get volumes from this chromosome and from that point on combine them with volumes from the other chromosome.
 void crossOverTwoPoint(Chromosome other)
          crossOverTwoPoint method is used to perform a crossover where we take volumes from the other chromosome from one point to another and put those volumes in between the values of the original chromosome.
 void crossOverUniform(Chromosome other)
          crossOverUniform method is used to perform a crossover where the volume of a tank is randomly taken from this or the other chromosome, after which a correction is applied.
 float getBM()
          getBM method is used to get the BM of the current Chromosome.
 float getDaft()
          getDaft method is used to get the draught aft of the current Chromosome.
 float getDfwd()
          getDfwd method is used to get the draught fwd of the current Chromosome.
 float getDynstab()
          getDynstab method is used to get the area under 0-30 of the current Chromosome.
 float getFitness()
          getFitness method is used to get the fitness value of the current Chromosome.
 float getFSC()
          getFSC method is used to get the free surface correction of the current Chromosome.
 float getGM()
          getGM method is used to get the GM value of the current Chromosome.
 float getTrim()
          getTrim method is used to get the trim value of the current Chromosome.
 java.util.ArrayList<java.lang.Float> getVolumes()
          getVolumes method is used to get the ArrayList of the volume values of the current Chromosome.
 void mutateRandom()
          mutateRandom method subtracts a random value from one tank and add this value to another tank.
 void mutateSwitch()
          mutateSwitch method randomly switches tank volumes and checks if the new solution is valid.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Chromosome

public Chromosome()
Constructor which creates a new Chromosome using the full tank method. The full tank method fills tanks completely until one tank gets what left over.


Chromosome

public Chromosome(boolean chose)
Constructor which creates a new Chromosome using the random tank method. The random tank method fills tanks totally random.

Parameters:
chose - Boolean value indicating that u want to use this method to create new chromosomes.
Method Detail

compareTo

public int compareTo(Chromosome c)
compareTo method is the overwritten method of the Object object which tells how two Chromosomes should be compared. This method is used to sort the Chromosome ArrayList in the population to get the best Chromosome and to use rank selection.

Specified by:
compareTo in interface java.lang.Comparable<Chromosome>
Parameters:
c - Chromosome object which is to be compared to this Chromosome object.

getFitness

public float getFitness()
getFitness method is used to get the fitness value of the current Chromosome.

Returns:
Floating point value indicating the fitness of the Chromosome.

getVolumes

public java.util.ArrayList<java.lang.Float> getVolumes()
getVolumes method is used to get the ArrayList of the volume values of the current Chromosome.

Returns:
ArrayList which contains floating point values that indicate the volume of each tank.

getTrim

public float getTrim()
getTrim method is used to get the trim value of the current Chromosome.

Returns:
Floating point value indicating the trim of the Chromosome.

getDfwd

public float getDfwd()
getDfwd method is used to get the draught fwd of the current Chromosome.

Returns:
Floating point value indicating the draught fwd of the Chromosome.

getDaft

public float getDaft()
getDaft method is used to get the draught aft of the current Chromosome.

Returns:
Floating point value indicating the draught aft of the Chromosome.

getGM

public float getGM()
getGM method is used to get the GM value of the current Chromosome.

Returns:
Floating point value indicating the GM of the Chromosome.

getFSC

public float getFSC()
getFSC method is used to get the free surface correction of the current Chromosome.

Returns:
Floating point value indicating the free surface correction of the Chromosome.

getBM

public float getBM()
getBM method is used to get the BM of the current Chromosome.

Returns:
Floating point value indicating the BM of the Chromosome.

getDynstab

public float getDynstab()
getDynstab method is used to get the area under 0-30 of the current Chromosome.

Returns:
Floating point value indicating the area under 0-30 of the Chromosome.

crossOverMean

public void crossOverMean(Chromosome other)
crossOverMean method is used to perform a crossover where the the mean value of each tank volume is taken.

Parameters:
other - Chromosome object to crossover with this Chromosome object.

crossOverOnePoint

public void crossOverOnePoint(Chromosome other)
crossOverOnePoint method is used to perform a crossover where until a certain point we get volumes from this chromosome and from that point on combine them with volumes from the other chromosome.

Parameters:
other - Chromosome object to crossover with this Chromosome object.

crossOverTwoPoint

public void crossOverTwoPoint(Chromosome other)
crossOverTwoPoint method is used to perform a crossover where we take volumes from the other chromosome from one point to another and put those volumes in between the values of the original chromosome.

Parameters:
other - Chromosome object to crossover with this Chromosome object.

crossOverUniform

public void crossOverUniform(Chromosome other)
crossOverUniform method is used to perform a crossover where the volume of a tank is randomly taken from this or the other chromosome, after which a correction is applied.

Parameters:
other - Chromosome object to crossover with this Chromosome object.

mutateSwitch

public void mutateSwitch()
mutateSwitch method randomly switches tank volumes and checks if the new solution is valid.


mutateRandom

public void mutateRandom()
mutateRandom method subtracts a random value from one tank and add this value to another tank.


clone

public java.lang.Object clone()
clone method is the overwritten method of the Object object which also copies the ArrayList of volumes.

Overrides:
clone in class java.lang.Object
Returns:
Object object which is a clone of the current Chromosome object and should be cast as a Chromosome.