|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.tostring0.AToString com.rubecula.darwin.foundation.Evolvable_ com.rubecula.darwin.domain.world.Population_ com.rubecula.darwin.domain.world.Population_Managed
public abstract class Population_Managed
This abstract class is designed to be a base class for populations whose evolution is "managed". That's to say that we, the programmer, like to play God. For an example of a managed evolution in the real world, see the Lenski experiment. Such managed populations tend to have the following properties:
Nested Class Summary | |
---|---|
protected class |
Population_Managed.ProcessBestInEnvironment
Type which provides a callback method which is called whenever a new best organism in the environment is found. |
Field Summary | |
---|---|
protected int |
convergentGenerations
|
Fields inherited from class com.rubecula.darwin.domain.world.Population_ |
---|
_colonies, _index, LOG, S_COLON |
Fields inherited from interface net.sf.tostring0.IToString |
---|
ANGBR_OPEN, ANGBRA_CLSE, BRA_CLSE, BRA_OPEN, BRCE_OPEN, BRCS_CLSE, COLON, LIST_SEPARATOR, MAX_ELEMENTS_DEFAULT, S_MT, S_PERCENT, SEPARATOR, SPACE |
Constructor Summary | |
---|---|
protected |
Population_Managed(java.lang.String identifier,
java.lang.String updateSourceProperty)
|
Method Summary | |
---|---|
protected boolean |
findAndProcessBestFit()
Generally speaking, we invoke processBestFit(ProcessBest) with
an appropriate processor. |
protected Best_Organism |
getBestInEnvironment()
|
protected int |
getConvergentGenerations()
|
protected int |
getMaxColonies()
|
protected abstract boolean |
isEnvironmentStable(Environment env)
|
protected abstract void |
logBestFitness(Organism organism,
Phenotype phenotype)
|
protected abstract void |
logBestOrganism(Colony colony)
|
protected abstract int |
makeDaughterColonies(Colony founderColony,
Environment founderEnvironment)
|
protected int |
makeDaughterColonies(Colony founderColony,
int size,
java.lang.Object addition)
|
protected abstract Colony |
makeDaughterColony(Colony founderColony,
java.lang.Object addition,
int pos)
clone the founderColony to create a new colony with the newClient appropriately positioned in the new colony's environment. |
void |
midGenerationProcessing()
XXX check that we really still want this stuff with pardons. |
protected void |
normalizeGenomes()
This method processes each of the Organism s in the population by
normalizing its genome in reference to the "best" genome. |
void |
postGenerationCleanup()
First, we invoke the super-method, i.e. |
void |
preGenerationPreparation()
First, we invoke the super-method, i.e. |
protected boolean |
processBestFit(ProcessBest<Organism> bestOfGenerationProcessor)
TODO this needs to be rewritten. |
protected abstract boolean |
processExtendedPhenotypes(java.util.Collection<ExPhen> exphens,
java.lang.Object criterion)
Typical behavior for this method is to loop through the extended phenotypes provided and for each invoke ExPhen.applyToEnvironment(Object) , passing in the
criterion . |
void |
seedMembers()
First we get the seed population property from the Taxon system
to which we belong by invoking Taxon.getSeedPopulation() and
recording the result as number . |
protected abstract Organism |
seedOrganism(Colony colony,
int i)
|
void |
setConvergentGenerations(int convergentGenerations)
|
void |
setMaxColonies(int maxColonies)
|
protected abstract java.lang.String |
showEnvironment1(Environment environment)
|
protected abstract java.lang.String |
showEnvironment2(Environment environment)
|
protected void |
thinColonies(int thinFactor)
Reduce the population of each colony of this population by the thinFactor. |
boolean |
updateEnvironmentAndColonies(Colony founderColony,
java.lang.Object source)
This is a critical part of the evolutionary process for a Population_Managed and is called by the
Population_Managed.ProcessBestInEnvironment.onUpdate(Organism) , which in turn is
invoked when there is a new best organism by
Best_Organism#update(Organism, boolean) . |
void |
wrapUp(java.lang.String cause)
Do some logging regarding this population. |
Methods inherited from class com.rubecula.darwin.domain.world.Population_ |
---|
addColony, censusMe, cullMembers, determineResult, equals, getCensusibleChildren, getColonies, getColony, getCount, getGeneration, getIndividuals, getRealm, getSequence, getSink, getTaxon, getTotal, hashCode, isFinished, nextGeneration, setIndex, setTaxon, toString |
Methods inherited from class com.rubecula.darwin.foundation.Evolvable_ |
---|
getIdentifier, getMaxGenerations, getResult, setMaxGenerations, setResult |
Methods inherited from class net.sf.tostring0.AToString |
---|
toString, toStringBrief, toStringId |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface net.sf.tostring0.IToString |
---|
toStringBrief, toStringId |
Methods inherited from interface net.sf.tostring0.Identifiable |
---|
getIdentifier |
Field Detail |
---|
protected transient int convergentGenerations
Constructor Detail |
---|
protected Population_Managed(java.lang.String identifier, java.lang.String updateSourceProperty)
identifier
- updateSourceProperty
- the name of the property in this population's Taxon
that will provide the data for updating the environment when
necessary.Method Detail |
---|
public void midGenerationProcessing()
midGenerationProcessing
in class Population_
Population_.midGenerationProcessing()
public void postGenerationCleanup()
Population_.postGenerationCleanup()
and then we invoke
findAndProcessBestFit()
. If the result of this call is false, we
log a warning.
postGenerationCleanup
in class Population_
Population_.postGenerationCleanup()
public void preGenerationPreparation()
Population_.preGenerationPreparation()
and then we invoke
Phenome.setData(Object)
with a zero value.
TODO check that this setData mechanism is still needed.
preGenerationPreparation
in class Population_
Population_.preGenerationPreparation()
public void seedMembers()
Taxon
system
to which we belong by invoking Taxon.getSeedPopulation()
and
recording the result as number
. Then we call
seedOrganism(Colony, int)
number
times. If the
population has changed (it should have), we invoke
Colony.populationChanged(Object)
with "seed members".
seedMembers
in interface Theological
seedMembers
in class Population_
TODO need to do more work here - perhaps seed all colonies (but
normally there will be exactly one colony when we are seeding a
{@link Population_Managed}).
TODO also, we use a different mechanism for seeding here than in the
Colony#seedMembers() method (which is what the super-method uses)
public void setConvergentGenerations(int convergentGenerations)
convergentGenerations
- public void setMaxColonies(int maxColonies)
maxColonies
- the maxColonies to set. Note that this is not a hard maximum
but an approximate maximum.public boolean updateEnvironmentAndColonies(Colony founderColony, java.lang.Object source)
Population_Managed
and is called by the
Population_Managed.ProcessBestInEnvironment.onUpdate(Organism)
, which in turn is
invoked when there is a new best organism by
Best_Organism#update(Organism, boolean)
.
First, we determine the Colony to which the given organism
belongs and name this founderColony
. Next, we invoke the
euphemistically titled decimatePoorerColonies(Colony)
for
founderColony
(i.e. we get rid of all the other colonies). A
kind of ethnic cleansing. Next, we invoke
Susceptible.updateFromSource(Best, Object)
on the
founderColony
's environment, and assuming that all is OK, we
invoke makeDaughterColonies(Colony, Environment)
which creates a
set of (new) daughter colonies, which have environments which are
variations of the founderColony
's environment.
updateEnvironmentAndColonies
in interface Managed
founderColony
- the "best" colony which is the only colony to remain and which
will be the founder of the new daughter colonies.source
- the source from which the environment will be updated when
appropriate.
Managed.updateEnvironmentAndColonies(Colony,
java.lang.Object)
public void wrapUp(java.lang.String cause)
Population_.wrapUp(String)
.
wrapUp
in interface Population
wrapUp
in class Population_
cause
- XXXPopulation_.wrapUp(String)
protected boolean findAndProcessBestFit()
processBestFit(ProcessBest)
with
an appropriate processor.
See, for example, processBestFit(ProcessBest) method in the class
Population_TS.
protected Best_Organism getBestInEnvironment()
protected int getConvergentGenerations()
protected int getMaxColonies()
protected abstract boolean isEnvironmentStable(Environment env)
env
- XXX
protected abstract void logBestFitness(Organism organism, Phenotype phenotype) throws ValueException
organism
- phenotype
-
ValueException
- an exception that could be thrown when getting the value.
However, in practice, this exception should never be thrown
once an organism as been crowned as best.protected abstract void logBestOrganism(Colony colony)
protected abstract int makeDaughterColonies(Colony founderColony, Environment founderEnvironment)
founderColony
- founderEnvironment
-
protected int makeDaughterColonies(Colony founderColony, int size, java.lang.Object addition)
founderColony
- size
- the number of possible variations of environment from which to
make new colonies.addition
- the object which is newly added and has to be moved into
different positions for each new colony.
protected abstract Colony makeDaughterColony(Colony founderColony, java.lang.Object addition, int pos) throws java.lang.CloneNotSupportedException
founderColony
- addition
- pos
-
java.lang.CloneNotSupportedException
protected void normalizeGenomes()
Organism
s in the population by
normalizing its genome in reference to the "best" genome. The actual work
is performed by
Organism_.normalizeGenome(Genome, Map, Environment)
where the
parameters are the bestGenome, a cache, and the environment for this
population.
TODO this is slow
protected boolean processBestFit(ProcessBest<Organism> bestOfGenerationProcessor) throws ValueException
findAndProcessBestFit()
which in turn
is called by postGenerationCleanup()
. Here is the sequence:
findBestOrganism(ProcessBest)
with
bestOfGenerationProcessor
as the parameter;Best.update(net.sf.tostring0.Identifiable, boolean)
on the object
returned from getBestInEnvironment()
, along with
Taxon.isLastGeneration()
.
bestOfGenerationProcessor
- the object that will process organisms as they replace the
current best organism for this generation.
ValueException
protected abstract boolean processExtendedPhenotypes(java.util.Collection<ExPhen> exphens, java.lang.Object criterion)
ExPhen.applyToEnvironment(Object)
, passing in the
criterion
. If the result is true for any extended phenotype,
the returned result will be true.
exphens
- criterion
-
protected abstract Organism seedOrganism(Colony colony, int i)
colony
- XXXi
- application-specific parameter
protected abstract java.lang.String showEnvironment1(Environment environment)
environment
- XXX
protected abstract java.lang.String showEnvironment2(Environment environment)
environment
- XXX
protected void thinColonies(int thinFactor) throws FitnessException
thinFactor
- the factor by which each colony's population will be thinned.
FitnessException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |