ABLE 2.0.0 07/02/2003 10:25:01

com.ibm.able.beans
Class AbleGeneticObject

java.lang.Object
  |
  +--com.ibm.able.beans.AbleGeneticObject
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
TstGeneticFunction1, TstGeneticFunction2, TstGeneticFunction2a, TstGeneticFunction3

public class AbleGeneticObject
extends java.lang.Object
implements java.io.Serializable

See Also:
Serialized Form

Field Summary
protected  java.lang.Object chromosome
          The population member's chromosome String or array
protected  int chromosomeLength
          The length of the chromosome String or array
protected  java.lang.Class chromosomeType
          The type (class) of chromosome
protected  double crossoverRate
          The crossoverRate -- probability of doing a crossover once a crossover operator is selected
protected  AbleAgent evaluationAgent
          The single evaluationAgent used to compute fitness (optional)
protected  double fitness
          The current raw fitness value
protected  boolean fitnessComputed
          A boolean flag that is true if the fitness has already been computed.
protected  AbleBean member
          The associated AbleBean used to compute fitness (optional)
protected  double mutationRate
          The mutationRate -- probability of mutating a bit once a mutation operator is selected
protected  double normalizedFitness
          The normalized fitness value (set by the search agent)
protected  AbleAgent searchAgent
          The parent genetic search agent
protected static long serialVersionUID
           
protected  java.lang.String vocabulary
          The vocabulary used by String chromosomes
 
Constructor Summary
AbleGeneticObject()
          construct a genetic object
 
Method Summary
 double binaryToInteger(java.lang.String binCode)
          Convert a binary code into an integer This method is provided as a utility function
 double computeFitness()
          compute the fitness value for this population member Note: this could be an expensive operation
static java.lang.String Copyright()
          Determine the copyright of this class.
 java.lang.Object generateRandomChromosome(int chromosomeLen)
          generate a random chromosome for this object based on the specified chromosomeLength, and vocabulary
 AbleBean getBean()
          return the underlying AbleBean (if any)
 java.lang.Object getChromosome()
          return the chromosome for this object Note: value is usually a String, but could be other array types
 int getChromosomeLength()
          return the length of the chromosome used by these genetic objects
 java.lang.Class getChromosomeType()
          return the chromosome type for this object Note: value is usually a String, but could be other array types
 double getCrossoverRate()
          return the crossover rate
 double getFitness()
          return the fitness value for this member Note: use computeFitness() to do the computation
 double getMutationRate()
          return the mutation rate
 double getNormalizedFitness()
           
 java.util.Hashtable getOperatorFitness()
          Return a hashtable of operator names (keys) and fitness values (Doubles).
 java.lang.Object getRandomChromosome()
          generate a random chromosome for this genetic object use this to initialize the underlying AbleBean (if any)
 java.lang.String getVocabulary()
          return the vocabulary used for the chromosomes Note: this is usually the alphabet "01" or "abc", but could be a more descriptive string "real" or "hybrid" if a non-String chromosome format is used.
 void initBean()
          create and initialize the underlying AbleBean add it to the evaluationAgent
 AbleAgent initEvaluationAgent()
          return the special EvaluationAgent (if any) Note: this should only get called once by the search agent
 java.lang.Object[] mutate(java.lang.Object[] parents)
          Given 2 population members Mutate their chromosomes (subject to mutation rate)
 java.lang.String mutateChromosome(java.lang.String chromosome)
          Mutate a single chromosome Note: this operator does a bitwise test against the mutationRate and then rolls the dice to select a new bit value from the vocabulary
 java.lang.Object[] onePointCrossover(java.lang.Object[] parents)
          Given 2 population members (parents) Do a single point crossover (subject to crossover rate), creating 2 children
 java.lang.Object[] onePointCrossoverAndMutate(java.lang.Object[] parents)
          Given 2 parent chromosomes Do a single point crossover (or not), creating 2 children chromosomes And mutate bits at the specified rate
 void registerOperators(AbleAgent agent)
          register any unique or overridden operators (user-defined functions) with the SearchAgent
 void removeBean()
          remove the underlying AbleBean (if any)
 void setChromosome(java.lang.Object s)
          set the chromosome for this genetic object create and initialize any underlying AbleBean and immediately compute the member's fitness
 void setCrossoverRate(double rate)
          set the crossover rate for use by any crossover operators
 void setEvaluationAgent(AbleAgent evalAgent)
          set the special EvaluationAgent
 void setMutationRate(double rate)
          set the mutation rate for use by any mutation operators
 void setNormalizedFitness(double value)
           
 java.lang.String toString()
          Return a string formatted for display.
 java.lang.Object[] twoPointCrossover(java.lang.Object[] parents)
          Given 2 population members (parents) Do a two point crossover (subject to crossover rate), creating 2 children
 java.lang.Object[] uniformCrossover(java.lang.Object[] parents)
          Given 2 population members (parents) Do a uniform crossover (subject to crossover rate) , creating 2 children
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

protected static final long serialVersionUID

searchAgent

protected AbleAgent searchAgent
The parent genetic search agent

evaluationAgent

protected AbleAgent evaluationAgent
The single evaluationAgent used to compute fitness (optional)

chromosome

protected java.lang.Object chromosome
The population member's chromosome String or array

member

protected AbleBean member
The associated AbleBean used to compute fitness (optional)

vocabulary

protected java.lang.String vocabulary
The vocabulary used by String chromosomes

chromosomeType

protected java.lang.Class chromosomeType
The type (class) of chromosome

chromosomeLength

protected int chromosomeLength
The length of the chromosome String or array

fitness

protected double fitness
The current raw fitness value

fitnessComputed

protected boolean fitnessComputed
A boolean flag that is true if the fitness has already been computed. This is used to avoid needless recomputing of deterministic fitness values

normalizedFitness

protected double normalizedFitness
The normalized fitness value (set by the search agent)

crossoverRate

protected double crossoverRate
The crossoverRate -- probability of doing a crossover once a crossover operator is selected

mutationRate

protected double mutationRate
The mutationRate -- probability of mutating a bit once a mutation operator is selected
Constructor Detail

AbleGeneticObject

public AbleGeneticObject()
construct a genetic object
Method Detail

getBean

public AbleBean getBean()
return the underlying AbleBean (if any)

removeBean

public void removeBean()
                throws AbleException
remove the underlying AbleBean (if any)

initEvaluationAgent

public AbleAgent initEvaluationAgent()
return the special EvaluationAgent (if any) Note: this should only get called once by the search agent

setEvaluationAgent

public void setEvaluationAgent(AbleAgent evalAgent)
set the special EvaluationAgent

getFitness

public double getFitness()
return the fitness value for this member Note: use computeFitness() to do the computation

setNormalizedFitness

public void setNormalizedFitness(double value)

getNormalizedFitness

public double getNormalizedFitness()

computeFitness

public double computeFitness()
compute the fitness value for this population member Note: this could be an expensive operation
Returns:
the fitness value for this population member

getRandomChromosome

public java.lang.Object getRandomChromosome()
generate a random chromosome for this genetic object use this to initialize the underlying AbleBean (if any)

setChromosome

public void setChromosome(java.lang.Object s)
set the chromosome for this genetic object create and initialize any underlying AbleBean and immediately compute the member's fitness

initBean

public void initBean()
create and initialize the underlying AbleBean add it to the evaluationAgent

getChromosome

public java.lang.Object getChromosome()
return the chromosome for this object Note: value is usually a String, but could be other array types

getChromosomeLength

public int getChromosomeLength()
return the length of the chromosome used by these genetic objects

getVocabulary

public java.lang.String getVocabulary()
return the vocabulary used for the chromosomes Note: this is usually the alphabet "01" or "abc", but could be a more descriptive string "real" or "hybrid" if a non-String chromosome format is used.

getChromosomeType

public java.lang.Class getChromosomeType()
return the chromosome type for this object Note: value is usually a String, but could be other array types

setCrossoverRate

public void setCrossoverRate(double rate)
set the crossover rate for use by any crossover operators

getCrossoverRate

public double getCrossoverRate()
return the crossover rate

setMutationRate

public void setMutationRate(double rate)
set the mutation rate for use by any mutation operators

getMutationRate

public double getMutationRate()
return the mutation rate

generateRandomChromosome

public java.lang.Object generateRandomChromosome(int chromosomeLen)
generate a random chromosome for this object based on the specified chromosomeLength, and vocabulary
Returns:
the chromosome string

onePointCrossoverAndMutate

public java.lang.Object[] onePointCrossoverAndMutate(java.lang.Object[] parents)
Given 2 parent chromosomes Do a single point crossover (or not), creating 2 children chromosomes And mutate bits at the specified rate

mutateChromosome

public java.lang.String mutateChromosome(java.lang.String chromosome)
Mutate a single chromosome Note: this operator does a bitwise test against the mutationRate and then rolls the dice to select a new bit value from the vocabulary
Parameters:
the - original chromosome string
Returns:
the (potentially) mutated chromosome string

onePointCrossover

public java.lang.Object[] onePointCrossover(java.lang.Object[] parents)
Given 2 population members (parents) Do a single point crossover (subject to crossover rate), creating 2 children
Parameters:
parents - the parent chromosomes
Returns:
the (potentially) modified children after crossover

twoPointCrossover

public java.lang.Object[] twoPointCrossover(java.lang.Object[] parents)
Given 2 population members (parents) Do a two point crossover (subject to crossover rate), creating 2 children
Parameters:
parents - the parent chromosomes
Returns:
the (potentially) modified children after crossover

uniformCrossover

public java.lang.Object[] uniformCrossover(java.lang.Object[] parents)
Given 2 population members (parents) Do a uniform crossover (subject to crossover rate) , creating 2 children
Parameters:
parents - the parent chromosomes
Returns:
the (potentially) modified children after crossover

mutate

public java.lang.Object[] mutate(java.lang.Object[] parents)
Given 2 population members Mutate their chromosomes (subject to mutation rate)
Parameters:
the - parent chromosomes
Returns:
the (potentially) mutated children

registerOperators

public void registerOperators(AbleAgent agent)
register any unique or overridden operators (user-defined functions) with the SearchAgent
Parameters:
the - search agent

getOperatorFitness

public java.util.Hashtable getOperatorFitness()
                                       throws AbleException
Return a hashtable of operator names (keys) and fitness values (Doubles). Fitness values must sum to 100. Note: this hashtable may be extended to using operator fitness objects vs fixed values so that we can adapt the operators selection during the search process
Returns:
the hashtable with operator fitness values

binaryToInteger

public double binaryToInteger(java.lang.String binCode)
Convert a binary code into an integer This method is provided as a utility function
Parameters:
binCode - a string of 1s and 0s with MSB being char[0] and LSB being char[n-1]
Returns:
the integer value of the string

toString

public java.lang.String toString()
Return a string formatted for display. Default is the chromosome string and fitness. If chromosome is not a string, then just fitness is returned. Subclasses should override if necessary.
Overrides:
toString in class java.lang.Object
Returns:
a string formatted for display purposes

Copyright

public static java.lang.String Copyright()
Determine the copyright of this class.
Returns:
A String containing this class's copyright statement.


ABLE 2.0.0 07/02/2003 10:25:01

(C) Copyright IBM Corporation 1999, 2003