|
ABLE 2.0.0 07/02/2003 10:25:01 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.ibm.able.AbleObject | +--com.ibm.able.AbleDefaultAgent | +--com.ibm.able.agents.AbleGeneticSearchAgent
This class implements an AbleAgent for conducting genetic search over a population of AbleBeans. An intermediate class, derived from AbleGeneticObject is used as an interface between this agent and the original AbleBeans.
Field Summary | |
---|---|
protected boolean |
autoEvolve
|
protected double |
avgFitness
|
protected int |
chromosomeLength
|
protected java.util.Hashtable |
chromosomeList
|
protected double |
crossoverRate
|
static java.lang.String |
defaultName
Value assigned to name by default. |
protected boolean |
evolving
|
protected double |
fitnessThreshold
|
protected java.lang.Class |
geneticObjectClass
|
protected java.lang.String |
geneticObjectClassName
|
protected double |
maxFitness
|
protected int |
maxNumPasses
|
protected double |
minFitness
|
protected double |
mutationRate
|
protected boolean |
noDuplicatesAllowed
|
protected int |
numPasses
|
protected java.util.Hashtable |
operatorFitness
|
protected java.util.Vector |
population
|
protected int |
populationSize
|
static int |
REPLACE_ALL
|
static int |
REPLACE_SOME
|
protected int |
replacementSize
|
protected int |
reproductionTechnique
|
protected java.lang.String |
sourceFileName
The genetic search algorithm is as follows: initialize the population evaluate each chromosome and insert into the population create new chromosomes using crossover/mutation operators delete members of the old population to make room for new members go to step 2 until time is up or other stopping condition is reached Note: a Chromosome is an Object, usually a String, but could be String[] or double[] |
protected double[] |
summedFitness
|
protected double |
totalFitness
|
protected double |
totalNormalizedFitness
|
protected boolean |
useNormalizedFitness
|
protected java.lang.String |
vocabulary
|
Fields inherited from class com.ibm.able.AbleDefaultAgent |
---|
activeDataSource, eventConnections, myBeans, numEpochs, processList, processListOK, userDefinedFunctions |
Fields inherited from class com.ibm.able.AbleObject |
---|
changed, chgSupport, comment, dataFlowEnabled, destBufferConnections, eventQueue, fileName, inputBuffer, listeners, logger, name, outputBuffer, parent, propertyConnectionMgr, sourceBufferConnections, state, stateChgSupport, trace |
Constructor Summary | |
---|---|
AbleGeneticSearchAgent()
construct a genetic search agent |
|
AbleGeneticSearchAgent(java.lang.String aName)
construct a genetic search agent with specified name |
Method Summary | |
---|---|
static java.lang.String |
Copyright()
Determine the copyright of this class. |
AbleGeneticObject |
createChild(java.lang.Object chromosome)
Given a prospective chromosome a) see if dups are allowed and if it is unique b) if ok, create a child genetic object from the chromsome and initialize the associated bean (if any) |
AbleGeneticObject[] |
createChildren(java.lang.Object[] chromosome)
given a newly derived chromosome(s), create a new population member(s) and initialize it/them Note: could be zero, one or two (depending on operators and if no dups allowed) |
protected java.util.Vector |
createNewMembers()
Generate replacementSize population members through application of genetic operators. |
protected void |
evaluatePopulation()
evaluate each population member based on fitness first process the AbleBeans contained in this SearchAgent if an evaluationAgent bean exists, process() it compute min, max, avg, and total fitness if normalization is specified, then normalize the raw fitness values |
void |
evolve()
automatically evolve the population by turning the evolving boolean on create and start the async thread if it is not already running |
boolean |
getAutoEvolve()
|
double |
getAvgFitness()
Get the average raw fitness value for the current population |
int |
getChromosomeLength()
Get the length of the chromsome used by the current genetic objects |
double |
getCrossoverRate()
Get the crossover rate |
double |
getFitnessThreshold()
Get the raw fitness threshold value |
java.lang.String |
getGeneticObjectClassName()
Return the name of the genetic object class |
double |
getMaxFitness()
Get the maximum raw fitness value for the current population |
int |
getMaxNumPasses()
Get the maximum number of passes to search |
double |
getMinFitness()
Get the minimum raw fitness value for the current population |
double |
getMutationRate()
Get the current mutation rate |
int |
getNumPasses()
Get the number of generations we have searched |
java.util.Hashtable |
getOperatorFitness()
Get the supported operators and their fitness (selection probability) values |
java.util.Vector |
getPopulation()
|
int |
getPopulationSize()
Get the population size |
int |
getReplacementSize()
Get the replacement size |
java.lang.String |
getSourceFileName()
not sure if we need this |
java.lang.String |
getVocabulary()
Get the chromosome vocabulary (default is "01") |
void |
init()
generate a complete genetic search agent |
protected void |
insertIntoPopulation(AbleGeneticObject newMember,
java.util.Vector list)
Insert a member into the population vector sorted by raw fitness update the min and max fitness values |
protected void |
integratePopulation(java.util.Vector newPopulation)
add the new members to the population reduce the population by removing lowest fitness members of current population |
boolean |
isEvolving()
Check to see if the agent is in the process of evolving. |
boolean |
isNoDuplicatesAllowed()
Get the boolean flag indicating whether duplicate members are allowed or not |
boolean |
isUseNormalizedFitness()
Get the boolean flag indicating whether raw or normalized fitness is used. |
protected void |
normalizeFitness()
perform linear normalization of the raw fitness values also pre-compute the summed fitness values for roulette wheel selection where the normalizedFitness of the best population member is equal to 2 times the average fitness |
void |
process()
This method performs the following steps: initialize the population (first time only) evaluate each chromosome and insert into the population create new chromosomes and members using crossover/mutation operators delete members of the old population to make room for new members |
void |
processTimerEvent()
This method is called from the asynch thread It is only used for automated evolution the population |
protected void |
removeLastNFromPopulation(int n)
remove the last N members (with lowest fitness) from the population |
void |
reset()
Reset each contained bean with dataflow on. |
AbleGeneticObject |
rouletteWheelSelection()
Select a member of the population using the roulette wheel algorithm |
java.lang.String |
selectOperator()
randomly select an operator to be applied to the parents using a roulette wheel selection technique Note: total operator fitness must be equal to 100 |
AbleGeneticObject[] |
selectParents()
choose two population members to reproduce using rouletteWheel selection technique |
void |
setAutoEvolve(boolean state)
|
void |
setCrossoverRate(double rate)
Set the crossoverRate , used when a crossover operator is selected to determine whether a crossover will actually be performed |
void |
setFitnessThreshold(double thresh)
Set the raw fitness threshold This is used to halt the search if the raw fitness value exceeds this threshold |
void |
setGeneticObjectClassName(java.lang.String aClassName)
Set the name of the class of genetic objects we are searching |
void |
setMaxNumPasses(int num)
Set the maximum number of generations to search |
void |
setMode(int mode)
set the internal config for either 0 = training from an external file or 1 = running (with network locked) from data placed in the input buffer |
void |
setMutationRate(double rate)
Set the mutationRate, used when a mutate operator is selected this value is used to determine whether each bit is mutated or not mutation can be to any other value in the vocabulary |
void |
setNoDuplicatesAllowed(boolean state)
Set a boolean flag indicating whether members with duplicate chromosomes are allowed in the population or not. |
void |
setOperatorFitness(java.util.Hashtable opFitness)
Set a hashtable of operators and their fitness values These values are used to select operators for application during reproduction Fitness values should sum to 100 |
void |
setPopulationSize(int size)
Set the population size |
void |
setReplacementSize(int size)
Set the number of population members to replace each generation |
void |
setSourceFileName(java.lang.String aFileName)
not sure if we need this |
void |
setUseNormalizedFitness(boolean state)
Set the boolean flag indicating whether raw or normalized fitness values should be used for selecting members for reproduction. |
void |
startEvolving()
start automatically evolving from the external data |
void |
stopEvolving()
stop automatically training the model from the external data |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.ibm.able.AbleBean |
---|
getComment, getLogger, getName, getParent, getState, getTraceLogger, init, isChanged, process, setChanged, setComment, setLogger, setName, setParent, setState, setTraceLogger |
Methods inherited from interface com.ibm.able.AbleEventListenerManager |
---|
addAbleEventListener, dataChanged, getAbleEventListeners, notifyAbleEventListeners, removeAbleEventListener |
Methods inherited from interface com.ibm.able.AbleEventQueueProcessor |
---|
processAbleEvent, processNoEventProcessingEnabledSituation |
Methods inherited from interface com.ibm.able.AblePropertyChangeManager |
---|
addPropertyChangeListener, addPropertyConnection, getPropertyConnectionManager, removeAllPropertyConnections, removePropertyChangeListener, removePropertyConnection |
Methods inherited from interface com.ibm.able.AbleSerializable |
---|
getFileName, restoreFromFile, restoreFromFile, saveToFile, saveToFile, setFileName |
Methods inherited from interface com.ibm.able.AbleBeanContainer |
---|
getName |
Field Detail |
public static final java.lang.String defaultName
public static final int REPLACE_ALL
public static final int REPLACE_SOME
protected java.lang.String sourceFileName
protected int reproductionTechnique
protected java.lang.Class geneticObjectClass
protected java.util.Vector population
protected java.util.Hashtable chromosomeList
protected java.util.Hashtable operatorFitness
protected int chromosomeLength
protected java.lang.String vocabulary
protected java.lang.String geneticObjectClassName
protected int maxNumPasses
protected double fitnessThreshold
protected int populationSize
protected int replacementSize
protected double crossoverRate
protected double mutationRate
protected boolean noDuplicatesAllowed
protected boolean useNormalizedFitness
protected boolean autoEvolve
protected double maxFitness
protected double minFitness
protected double avgFitness
protected double totalFitness
protected double totalNormalizedFitness
protected double[] summedFitness
protected int numPasses
protected boolean evolving
Constructor Detail |
public AbleGeneticSearchAgent() throws AbleException
public AbleGeneticSearchAgent(java.lang.String aName) throws AbleException
Method Detail |
public void reset() throws AbleException
reset
in class AbleDefaultAgent
com.ibm.able.AbleDefaultAgent
AbleException
- If an error occurs when resetting
a contained bean. All errors are
collected and insert into the exception
so that one bean's error does not
prevent another from being reset.public void init() throws AbleException
init
in class AbleObject
com.ibm.able.AbleBean
AbleException
- If an error occurs.public void process() throws AbleException
process
in class AbleDefaultAgent
com.ibm.able.AbleDefaultAgent
AbleException
- If an error occurs. Errors from each contained
bean are accumulated.public void processTimerEvent() throws AbleException
processTimerEvent
in class AbleObject
com.ibm.able.AbleEventQueueProcessor
AbleException
- If an error occurs.public void setSourceFileName(java.lang.String aFileName)
public java.lang.String getSourceFileName()
public void setGeneticObjectClassName(java.lang.String aClassName)
aClassName
- fully specified (package prefixed) class namepublic java.lang.String getGeneticObjectClassName()
public void setPopulationSize(int size)
size
- the population sizepublic int getPopulationSize()
public java.util.Vector getPopulation()
public void setReplacementSize(int size)
size
- the number of members to be replacedpublic int getReplacementSize()
public java.lang.String getVocabulary()
public int getNumPasses()
public void setMaxNumPasses(int num)
num
- the maximum number of generations to createpublic int getMaxNumPasses()
public void setFitnessThreshold(double thresh)
thresh
- the fitness thresholdpublic double getFitnessThreshold()
public void setCrossoverRate(double rate)
public double getCrossoverRate()
public void setMutationRate(double rate)
public double getMutationRate()
public double getAvgFitness()
public double getMinFitness()
public double getMaxFitness()
public int getChromosomeLength()
public void setAutoEvolve(boolean state)
public boolean getAutoEvolve()
public void setNoDuplicatesAllowed(boolean state)
state
- whether duplicates should be allowed (false) or not (true)public boolean isNoDuplicatesAllowed()
public void setUseNormalizedFitness(boolean state)
public boolean isUseNormalizedFitness()
public void setOperatorFitness(java.util.Hashtable opFitness)
public java.util.Hashtable getOperatorFitness()
public void setMode(int mode)
public AbleGeneticObject[] createChildren(java.lang.Object[] chromosome)
one
- or two chromosome objectspublic AbleGeneticObject createChild(java.lang.Object chromosome)
chromosome
- - the chromosome defining the childprotected void evaluatePopulation()
protected void normalizeFitness()
protected java.util.Vector createNewMembers()
protected void integratePopulation(java.util.Vector newPopulation) throws AbleException
a
- vector of new genetic objects to add to the populationprotected void insertIntoPopulation(AbleGeneticObject newMember, java.util.Vector list)
newMember
- -- the genetic object to insert into the populationlist
- -- the population vectorprotected void removeLastNFromPopulation(int n) throws AbleException
n
- the number of population members to removepublic AbleGeneticObject[] selectParents()
public java.lang.String selectOperator()
public AbleGeneticObject rouletteWheelSelection()
public boolean isEvolving() throws AbleException
public void evolve()
public void startEvolving() throws AbleException
public void stopEvolving() throws AbleException
public static java.lang.String Copyright()
|
ABLE 2.0.0 07/02/2003 10:25:01 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |