search
Class GeneticSearchObject

java.lang.Object
  |
  +--search.GeneticSearchObject
Direct Known Subclasses:
GeneticSearchObj1, GeneticSearchObj2

public class GeneticSearchObject
extends java.lang.Object

The GeneticSearchObject class is used to represent a member of the population being searched or optimized using a genetic search algorithm.


Field Summary
protected  java.lang.String chromosome
           
protected  int chromosomeLength
           
protected  double crossoverRate
           
protected  double fitness
           
protected  boolean fitnessComputed
           
protected  double mutationRate
           
protected  GeneticSearch searchAgent
           
protected  java.lang.String vocabulary
           
 
Constructor Summary
GeneticSearchObject()
          Creates a GeneticSearchObject.
 
Method Summary
 double binaryToInteger(java.lang.String binCode)
          Converts a binary code into a double integer.
 double computeFitness()
          Returns the fitness value for this population member.
 java.lang.String generateRandomChromosome()
          Generates a random chromosome for this population member, based on the chromosome length and vocabulary.
 java.lang.String getChromosome()
          Retrieves the chromosome for this population member.
 int getChromosomeLength()
          Retrieves the length of the chromosome.
 double getCrossoverRate()
          Retrieves the crossover rate used by any crossover operators.
 double getFitness()
          Retrieves the fitness value for this population member.
 double getMutationRate()
          Retrieves the mutation rate used by any mutation operators.
 java.util.Hashtable getOperatorFitness()
          Retrieves a table of operator names and fitness values.
 java.lang.String getRandomChromosome()
          Retrieves a random chromosome for this population member.
 java.lang.String getVocabulary()
          Retrieve the vocabulary used for the chromosomes, which is usually the alphabet "01" or "abc".
 void setChromosome(java.lang.String chromosome)
          Sets the chromosome for this population member and computes the member's fitness.
 void setCrossoverRate(double rate)
          Sets the crossover rate for use by any crossover operators.
 void setMutationRate(double rate)
          Sets the mutation rate for use by any mutation operators.
 java.lang.String toString()
          Generates a string from the chromosome and fitness values.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

searchAgent

protected GeneticSearch searchAgent

chromosome

protected java.lang.String chromosome

vocabulary

protected java.lang.String vocabulary

chromosomeLength

protected int chromosomeLength

fitness

protected double fitness

fitnessComputed

protected boolean fitnessComputed

crossoverRate

protected double crossoverRate

mutationRate

protected double mutationRate
Constructor Detail

GeneticSearchObject

public GeneticSearchObject()
Creates a GeneticSearchObject.
Method Detail

getFitness

public double getFitness()
Retrieves the fitness value for this population member.
Returns:
the fitness value

computeFitness

public double computeFitness()
Returns the fitness value for this population member.
Returns:
the computed fitness value for this population member

getRandomChromosome

public java.lang.String getRandomChromosome()
Retrieves a random chromosome for this population member.
Returns:
the String that represents a chromosome

setChromosome

public void setChromosome(java.lang.String chromosome)
Sets the chromosome for this population member and computes the member's fitness.
Parameters:
chromosome - the String that represents the chromosome

getChromosome

public java.lang.String getChromosome()
Retrieves the chromosome for this population member.
Returns:
the String that represents a chromosome

getChromosomeLength

public int getChromosomeLength()
Retrieves the length of the chromosome.
Returns:
the length of the chromosome.

getVocabulary

public java.lang.String getVocabulary()
Retrieve the vocabulary used for the chromosomes, which is usually the alphabet "01" or "abc".
Returns:
the String that represents the vocabulary alphabet

setCrossoverRate

public void setCrossoverRate(double rate)
Sets the crossover rate for use by any crossover operators.
Parameters:
rate - the double value of the crossover rate

getCrossoverRate

public double getCrossoverRate()
Retrieves the crossover rate used by any crossover operators.
Returns:
the crossover rate

setMutationRate

public void setMutationRate(double rate)
Sets the mutation rate for use by any mutation operators.
Parameters:
rate - the double value of the crossover rate

getMutationRate

public double getMutationRate()
Retrieves the mutation rate used by any mutation operators.
Returns:
the mutation rate

generateRandomChromosome

public java.lang.String generateRandomChromosome()
Generates a random chromosome for this population member, based on the chromosome length and vocabulary.
Returns:
the generated chromosome string

getOperatorFitness

public java.util.Hashtable getOperatorFitness()
Retrieves a table of operator names and fitness values. The sum of the fitness values must equal 100. This method is only called once from the GeneticSearch object's init() method.
Returns:
the hashtable of operators and fitness values

toString

public java.lang.String toString()
Generates a string from the chromosome and fitness values.
Returns:
a string formatted for display purposes
Overrides:
toString in class java.lang.Object

binaryToInteger

public double binaryToInteger(java.lang.String binCode)
Converts a binary code into a double integer.
Parameters:
binCode - a String of 1s and 0s with MSB being char[0] and LSB being char[n-1]
Returns:
the value of the string