com.ibm.able.examples.genetic
Class TstGeneticFunction2a
java.lang.Object
|
+--com.ibm.able.beans.AbleGeneticObject
|
+--com.ibm.able.examples.genetic.TstGeneticFunction2a
- public class TstGeneticFunction2a
- extends AbleGeneticObject
This class implements the F6 function described in the first chapter
of The Handbook of Genetic Algorithms (Davis)
Is used a hybrid (numeric) chromosome representation
- See Also:
- Serialized Form
Field Summary |
static double |
factor
|
Fields inherited from class com.ibm.able.beans.AbleGeneticObject |
chromosome,
chromosomeLength,
chromosomeType,
crossoverRate,
evaluationAgent,
fitness,
fitnessComputed,
member,
mutationRate,
normalizedFitness,
searchAgent,
vocabulary |
Method Summary |
java.lang.Object[] |
average(java.lang.Object[] parents)
Given 2 parent chromosomes
Average their values , creating 2 children chromosomes |
double |
computeFitness()
just add up the number of ones in the chromosome |
protected double |
f6(double x,
double y)
|
double |
getFitness()
|
java.util.Hashtable |
getOperatorFitness()
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 |
java.lang.Object |
getRandomChromosome()
generate a random chromosome for this genetic object |
double[] |
mutateChromosome(double[] chromosome)
Mutate a single chromosome
Note: this operator does a bitwise test against the mutationRate
and then rolls the dice to select a delta to the current value |
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 (sensors) with the SearchAgent |
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 |
Methods inherited from class com.ibm.able.beans.AbleGeneticObject |
binaryToInteger,
generateRandomChromosome,
getBean,
getChromosome,
getChromosomeLength,
getChromosomeType,
getCrossoverRate,
getMutationRate,
getNormalizedFitness,
getVocabulary,
initBean,
initEvaluationAgent,
mutate,
mutateChromosome,
onePointCrossover,
removeBean,
setChromosome,
setCrossoverRate,
setEvaluationAgent,
setMutationRate,
setNormalizedFitness,
twoPointCrossover,
uniformCrossover |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
factor
public static final double factor
TstGeneticFunction2a
public TstGeneticFunction2a()
getFitness
public double getFitness()
- Overrides:
- getFitness in class AbleGeneticObject
getRandomChromosome
public java.lang.Object getRandomChromosome()
- generate a random chromosome for this genetic object
- Overrides:
- getRandomChromosome in class AbleGeneticObject
computeFitness
public double computeFitness()
- just add up the number of ones in the chromosome
- Overrides:
- computeFitness in class AbleGeneticObject
f6
protected double f6(double x,
double y)
mutateChromosome
public double[] mutateChromosome(double[] chromosome)
- Mutate a single chromosome
Note: this operator does a bitwise test against the mutationRate
and then rolls the dice to select a delta to the current value
- Parameters:
the
- original chromosome array- Returns:
- the (potentially) mutated chromosome array
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
- Overrides:
- onePointCrossoverAndMutate in class AbleGeneticObject
average
public java.lang.Object[] average(java.lang.Object[] parents)
- Given 2 parent chromosomes
Average their values , creating 2 children chromosomes
getOperatorFitness
public java.util.Hashtable getOperatorFitness()
- 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
- Overrides:
- getOperatorFitness in class AbleGeneticObject
registerOperators
public void registerOperators(AbleAgent agent)
- register any unique or overridden operators (sensors) with the SearchAgent
- Parameters:
the
- search agent- Overrides:
- registerOperators in class AbleGeneticObject
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
- Returns:
- a string formatted for display purposes
- Overrides:
- toString in class AbleGeneticObject
ABLE: Produced by Joe, Don, and Jeff who say, 'Thanks for your support.'