com.rubecula.darwin.core
Class Darwinian_Abstract

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.Vector
              extended by com.rubecula.util.AuditableVector
                  extended by com.rubecula.darwin.core.Darwinian_Abstract
All Implemented Interfaces:
Darwinian, Generatable, Auditable, Identifiable, Serializable, Cloneable, Iterable, Collection, List, RandomAccess
Direct Known Subclasses:
Darwinian_Default

public abstract class Darwinian_Abstract
extends AuditableVector
implements Darwinian

Abstract class implementing Darwinian interface.

Author:
Robin
See Also:
Serialized Form

Field Summary
protected  Census _CensusTaker
          The census taker which imlements the Census in order to make a census of this Darwinian system.
protected  Genome _Genome
          The Genome of this Darwinian system (fixed).
protected  Mortality _Mortality
          The "Grim Reaper" which implements the Mortality to determine when organisms in this system will die.
protected  Phenome _Phenome
          The Phenome of this Darwinian system (fixed).
protected static org.apache.commons.logging.Log log
          The logger for this class.
 
Fields inherited from class java.util.Vector
capacityIncrement, elementCount, elementData
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
protected Darwinian_Abstract(String identifier, Genome genome, Phenome phenome, Census censusTaker, Mortality mortality, MateChoice chooser, Fecundity fecundity)
          Constructor to create a Darwinian system with no populations.
 
Method Summary
 boolean add(Object arg0)
           
 boolean add(Population arg0)
          Mutating method to add a population to the system.
 void census(PrintWriter out)
          Method to enumerate this population for census purposes.
 Census getCensusTaker()
           
 MateChoice getChooser()
           
 Factory getFactory()
           
 Fecundity getFecundity()
           
 int getGeneration()
           
 Genome getGenome()
           
 Mortality getMortality()
           
 Phenome getPhenome()
          Method to get the phenome for this system, i.e.
 Population getPopulation(int index)
           
 void midGenerationProcessing()
          A (callback) method which will be invoked at the midpoint of each generation.
 boolean nextGeneration()
          For each population in this system, call nextGeneration().
 void postGenerationCleanup()
          A (callback) method which will be invoked at the termination of each generation.
 void preGenerationPreparation()
          A (callback) method which will be invoked at the start of each generation.
 void seedGeneration(int organisms)
          Method to seed the system by seeding a certain number of new organisms in each of the system's populations.
 void setChooser(MateChoice chooser)
          MUTATING method to explicitly set the implementer of MateChoice.
 void setFecundity(Fecundity fecundity)
          MUTATING method to explicitly set the implementer of Fecundity.
 void setMortality(Mortality mortality)
          MUTATING method to explicitly set the implementer of Mortality.
 void setupListeners(EnvironmentListener listener)
          Set up environment listeners.
 void setupListeners(PopulationListener listener)
          Mutating method to add, for each of this system's populations, a listener, i.e.
 String toString()
           
 
Methods inherited from class com.rubecula.util.AuditableVector
audit, audit, audit, getIdentifier
 
Methods inherited from class java.util.Vector
add, addAll, addAll, addElement, capacity, clear, clone, contains, containsAll, copyInto, elementAt, elements, ensureCapacity, equals, firstElement, get, hashCode, indexOf, indexOf, insertElementAt, isEmpty, lastElement, lastIndexOf, lastIndexOf, remove, remove, removeAll, removeAllElements, removeElement, removeElementAt, removeRange, retainAll, set, setElementAt, setSize, size, subList, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
iterator, listIterator, listIterator
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.rubecula.darwin.core.Darwinian
size
 
Methods inherited from interface com.rubecula.util.Identifiable
getIdentifier
 
Methods inherited from interface java.util.List
iterator, listIterator, listIterator
 

Field Detail

log

protected static final org.apache.commons.logging.Log log
The logger for this class.


_CensusTaker

protected final Census _CensusTaker
The census taker which imlements the Census in order to make a census of this Darwinian system.


_Genome

protected final Genome _Genome
The Genome of this Darwinian system (fixed).


_Mortality

protected Mortality _Mortality
The "Grim Reaper" which implements the Mortality to determine when organisms in this system will die.


_Phenome

protected final Phenome _Phenome
The Phenome of this Darwinian system (fixed).

Constructor Detail

Darwinian_Abstract

protected Darwinian_Abstract(String identifier,
                             Genome genome,
                             Phenome phenome,
                             Census censusTaker,
                             Mortality mortality,
                             MateChoice chooser,
                             Fecundity fecundity)
Constructor to create a Darwinian system with no populations.

Parameters:
identifier - the identifier for this new system.
genome - the genome on which all organisms in all populations of this new system will be based.
phenome - the phenome which all organisms of all populations of this new system will exhibit.
censusTaker - an implementer of Census for the purpose of censusing populations of the new system.
mortality - an implementer of Mortality for the purpose of calculating mortalities of organims in populations of this new system.
chooser - the mate chooser.
fecundity - the fecundity determiner.
Method Detail

add

public boolean add(Object arg0)
Specified by:
add in interface Collection
Specified by:
add in interface List
Overrides:
add in class Vector

add

public boolean add(Population arg0)
Description copied from interface: Darwinian
Mutating method to add a population to the system.

Specified by:
add in interface Darwinian
Parameters:
arg0 - an implementer of Population.
Returns:
true if the population was added successfully.

census

public void census(PrintWriter out)
Description copied from interface: Darwinian
Method to enumerate this population for census purposes.

Specified by:
census in interface Darwinian
Parameters:
out - the print writer to which census results will be sent.
See Also:
CensusUtils.DefaultEnumeration(java.util.Iterator, com.rubecula.darwin.core.Census, java.io.PrintWriter)

getCensusTaker

public Census getCensusTaker()
Specified by:
getCensusTaker in interface Darwinian
Returns:
the application-specific implementer of Census.

getChooser

public MateChoice getChooser()
Specified by:
getChooser in interface Darwinian
Returns:
the application-specific implementer of MateChoice.

getFactory

public Factory getFactory()
Specified by:
getFactory in interface Darwinian
Returns:
the factory

getFecundity

public Fecundity getFecundity()
Specified by:
getFecundity in interface Darwinian
Returns:
the application-specific implementer of Fecundity.

getGeneration

public int getGeneration()
Specified by:
getGeneration in interface Generatable
Returns:
the sequence number of the current generation.

getGenome

public Genome getGenome()
Specified by:
getGenome in interface Darwinian
Returns:
the Genome for this Darwinian System.

getMortality

public Mortality getMortality()
Specified by:
getMortality in interface Darwinian
Returns:
the application-specific implementer of Mortality.

getPhenome

public Phenome getPhenome()
Description copied from interface: Darwinian
Method to get the phenome for this system, i.e. the implementer of Phenome.

Specified by:
getPhenome in interface Darwinian
Returns:
value of (private) field _Phenome.

getPopulation

public Population getPopulation(int index)
Specified by:
getPopulation in interface Darwinian

nextGeneration

public boolean nextGeneration()
For each population in this system, call nextGeneration().

Specified by:
nextGeneration in interface Generatable
Returns:
true if all the populations in this system are healthy.
See Also:
Generatable.nextGeneration()

seedGeneration

public void seedGeneration(int organisms)
Description copied from interface: Darwinian
Method to seed the system by seeding a certain number of new organisms in each of the system's populations.

Specified by:
seedGeneration in interface Darwinian
Parameters:
organisms - the number of new organisms to create in each population.

setChooser

public void setChooser(MateChoice chooser)
Description copied from interface: Darwinian
MUTATING method to explicitly set the implementer of MateChoice.

Specified by:
setChooser in interface Darwinian
Parameters:
chooser - an application-specific implementation of MateChoice.

setFecundity

public void setFecundity(Fecundity fecundity)
Description copied from interface: Darwinian
MUTATING method to explicitly set the implementer of Fecundity.

Specified by:
setFecundity in interface Darwinian
Parameters:
fecundity - an application-specific implementation of Fecundity.

setMortality

public void setMortality(Mortality mortality)
Description copied from interface: Darwinian
MUTATING method to explicitly set the implementer of Mortality.

Specified by:
setMortality in interface Darwinian
Parameters:
mortality - an application-specific implementation of Mortality.

setupListeners

public void setupListeners(EnvironmentListener listener)
Description copied from interface: Darwinian
Set up environment listeners.

Specified by:
setupListeners in interface Darwinian

setupListeners

public void setupListeners(PopulationListener listener)
Description copied from interface: Darwinian
Mutating method to add, for each of this system's populations, a listener, i.e. an implementer of PopulationListener.

Specified by:
setupListeners in interface Darwinian
Parameters:
listener - the listener of population change events.

midGenerationProcessing

public void midGenerationProcessing()
Description copied from interface: Generatable
A (callback) method which will be invoked at the midpoint of each generation. That is to say, after dead organisms have been marked, new organisms have been born, but before dead organisms have been removed.

Specified by:
midGenerationProcessing in interface Generatable

postGenerationCleanup

public void postGenerationCleanup()
Description copied from interface: Generatable
A (callback) method which will be invoked at the termination of each generation.

Specified by:
postGenerationCleanup in interface Generatable

preGenerationPreparation

public void preGenerationPreparation()
Description copied from interface: Generatable
A (callback) method which will be invoked at the start of each generation.

Specified by:
preGenerationPreparation in interface Generatable

toString

public String toString()
Overrides:
toString in class Vector