com.rubecula.darwin.examples.travelingsalesman
Class Population_TS

java.lang.Object
  extended by net.sf.tostring0.AToString
      extended by com.rubecula.darwin.foundation.Evolvable_
          extended by com.rubecula.darwin.domain.world.Population_
              extended by com.rubecula.darwin.domain.world.Population_Managed
                  extended by com.rubecula.darwin.examples.travelingsalesman.Population_TS
All Implemented Interfaces:
Censusible, Population, PopulationExposed, Managed, Countable, Evolvable, Generational, Terminal, Theological, Visualizable, net.sf.tostring0.Identifiable, net.sf.tostring0.IToString

public class Population_TS
extends Population_Managed

Population model for the Traveling Salesman

Author:
Robin Hillyard

Nested Class Summary
 
Nested classes/interfaces inherited from class com.rubecula.darwin.domain.world.Population_Managed
Population_Managed.ProcessBestInEnvironment
 
Field Summary
static java.lang.String ALL_CLIENTS
           
 
Fields inherited from class com.rubecula.darwin.domain.world.Population_Managed
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
Population_TS(java.lang.String identifier)
           
 
Method Summary
protected  java.lang.Object determineResult()
           
protected  boolean findAndProcessBestFit()
          First we determine the criterion (to be used later) which is the travel time of the current environment.
protected  boolean isEnvironmentStable(Environment environment)
           
protected  void logBestFitness(Organism organism, Phenotype phenotype)
           
protected  void logBestOrganism(Colony colony)
           
protected  int makeDaughterColonies(Colony founderColony, Environment founderEnvironment)
          In this implementation, we get the client map from the founderEnvironment eco factor called EcoFactor_Clients.FACTOR_CLIENTS.
protected  Colony makeDaughterColony(Colony founderColony, java.lang.Object newClient, int pos)
          clone the founderColony to create a new colony with the newClient appropriately positioned in the new colony's environment.
protected  boolean processExtendedPhenotypes(java.util.Collection<ExPhen> exphens, java.lang.Object criterion)
          This method loops through the extended phenotypes provided and for each invoke ExPhen.applyToEnvironment(Object), passing in the criterion.
protected  Organism seedOrganism(Colony colony, int i)
           
protected  java.lang.String showEnvironment1(Environment environment)
           
protected  java.lang.String showEnvironment2(Environment environment)
           
 
Methods inherited from class com.rubecula.darwin.domain.world.Population_Managed
getBestInEnvironment, getConvergentGenerations, getMaxColonies, makeDaughterColonies, midGenerationProcessing, normalizeGenomes, postGenerationCleanup, preGenerationPreparation, processBestFit, seedMembers, setConvergentGenerations, setMaxColonies, thinColonies, updateEnvironmentAndColonies, wrapUp
 
Methods inherited from class com.rubecula.darwin.domain.world.Population_
addColony, censusMe, cullMembers, 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

ALL_CLIENTS

public static final java.lang.String ALL_CLIENTS
See Also:
Constant Field Values
Constructor Detail

Population_TS

public Population_TS(java.lang.String identifier)
Parameters:
identifier -
Method Detail

determineResult

protected java.lang.Object determineResult()
Specified by:
determineResult in class Population_
Returns:
XXX

findAndProcessBestFit

protected boolean findAndProcessBestFit()
First we determine the criterion (to be used later) which is the travel time of the current environment. This is passed into the setCriterion method of the processor for processing the best in environment. Then we invoke Population_Managed.processBestFit(ProcessBest) with a newly created instance of NoteTravelTime as its processor. NOTE there are two casts in this method, both of which must work by definition of the application. This implementation gets the travel time for the current environment and passes that as the criterion parameter into Population_Managed.processBestFit(ProcessBest). TODO this should be merged with findAndProcessBestFit() and perhaps Colony.setupGeneration().

Overrides:
findAndProcessBestFit in class Population_Managed
Returns:
true if all is well

isEnvironmentStable

protected boolean isEnvironmentStable(Environment environment)
Specified by:
isEnvironmentStable in class Population_Managed
Parameters:
environment - XXX
Returns:
true if the environment has stabilized -- there will be no further changes
See Also:
Population_Managed.isEnvironmentStable(com.rubecula.darwin.domain.helper.Environment)

logBestFitness

protected void logBestFitness(Organism organism,
                              Phenotype phenotype)
                       throws ValueException
Specified by:
logBestFitness in class Population_Managed
Throws:
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.

logBestOrganism

protected void logBestOrganism(Colony colony)
Specified by:
logBestOrganism in class Population_Managed

makeDaughterColonies

protected int makeDaughterColonies(Colony founderColony,
                                   Environment founderEnvironment)
In this implementation, we get the client map from the founderEnvironment eco factor called EcoFactor_Clients.FACTOR_CLIENTS. Then we pass that along with its size and the founderColony and the newest client into Population_Managed.makeDaughterColonies(Colony, int, Object).

Specified by:
makeDaughterColonies in class Population_Managed
Returns:
the number of daughter colonies created.
See Also:
Population_Managed.makeDaughterColonies(com.rubecula.darwin.domain.helper.Colony, com.rubecula.darwin.domain.helper.Environment)

makeDaughterColony

protected Colony makeDaughterColony(Colony founderColony,
                                    java.lang.Object newClient,
                                    int pos)
                             throws java.lang.CloneNotSupportedException
Description copied from class: Population_Managed
clone the founderColony to create a new colony with the newClient appropriately positioned in the new colony's environment.

Specified by:
makeDaughterColony in class Population_Managed
Parameters:
founderColony -
newClient -
pos -
Returns:
the new daughter colony
Throws:
java.lang.CloneNotSupportedException

processExtendedPhenotypes

protected boolean processExtendedPhenotypes(java.util.Collection<ExPhen> exphens,
                                            java.lang.Object criterion)
This method loops through the extended phenotypes provided and for each invoke ExPhen.applyToEnvironment(Object), passing in the criterion. If the result is true for any extended phenotype, the returned result will be true.

Specified by:
processExtendedPhenotypes in class Population_Managed
Parameters:
exphens -
criterion - the criterion which will be used by the method ExPhen.applyToEnvironment(Object). Generally speaking, the higher this value, the more likely the environment (in particular, the eco factor(s) specified by an extended phenotype) will be updated.
Returns:
true if the environment of an extended phenotype has been updated

seedOrganism

protected Organism seedOrganism(Colony colony,
                                int i)
Specified by:
seedOrganism in class Population_Managed
Parameters:
i - application-specific parameter
colony - XXX
Returns:
a newly created organism based on the integer i

showEnvironment1

protected java.lang.String showEnvironment1(Environment environment)
Specified by:
showEnvironment1 in class Population_Managed
Parameters:
environment - XXX
Returns:
a String for the first descriptive message about the environment

showEnvironment2

protected java.lang.String showEnvironment2(Environment environment)
Specified by:
showEnvironment2 in class Population_Managed
Parameters:
environment - XXX
Returns:
a String for the second descriptive message about the environment


Copyright © 2010 Rubecula Software, LLC. All Rights Reserved.