com.rubecula.darwin.domain.genetics
Class Mortality_

java.lang.Object
  extended by net.sf.tostring0.AToString
      extended by com.rubecula.darwin.domain.genetics.Mortality_
All Implemented Interfaces:
Mortality, net.sf.tostring0.IToString
Direct Known Subclasses:
Mortality_Reaper, Mortality_TS

public abstract class Mortality_
extends net.sf.tostring0.AToString
implements Mortality

Abstract class which defines the base methods and fields needed to implement the Mortality interface.

Author:
Robin Hillyard

Field Summary
protected static org.apache.commons.logging.Log LOG
          The logger for this class.
 
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 Mortality_(org.apache.commons.math.random.RandomGenerator random)
          Protected primary constructor.
 
Method Summary
protected  double calculateAgeViabilityFactor(int age)
          Subclasses where viability depends on age must override this method.
 double calculateMortality(int age, double fitness, double saturation)
          Method to calculate the mortality for an organism as 1 less the simple value of calculateViability(int, double, double), given the age, fitness and saturation.
protected  double calculateViability(int age, double fitness, double saturation)
           
 boolean equals(java.lang.Object obj)
           
protected  double getBias()
           
protected  org.apache.commons.math.random.RandomGenerator getRandom()
           
 int hashCode()
           
 boolean isMarked(double mortality)
           
 void setBias(double bias)
          Set the value of bias.
 
Methods inherited from class net.sf.tostring0.AToString
toString, toString, toStringBrief, toStringId
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

LOG

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

Constructor Detail

Mortality_

protected Mortality_(org.apache.commons.math.random.RandomGenerator random)
Protected primary constructor.

Parameters:
random - a random number generator
Method Detail

calculateMortality

public double calculateMortality(int age,
                                 double fitness,
                                 double saturation)
Method to calculate the mortality for an organism as 1 less the simple value of calculateViability(int, double, double), given the age, fitness and saturation. The viability factor (VF) = (1-IM) if age=0 where IM is the infant mortality (20%, by default) otherwise, VF = (1-AF)^(age+1) where AF is the actuarial factor (10%, by default). The sustainabilityIndex (SI) = 1 if saturation less than 1; else SI = (1 - saturation)^2.

Specified by:
calculateMortality in interface Mortality
Parameters:
age - the age of the organism in generations.
fitness - the fitness of the organism for an environment.
saturation - a measure of the current population saturation (1 corresponds to the ideal population supportable by the environment.
Returns:
the probability of death before the next generation (between 0 and 1). TODO consider inlining this into isMarked (ie. pass in age, fitness, saturation, and return boolean)
See Also:
Mortality.calculateMortality(int,double,double)

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object
See Also:
Object.equals(java.lang.Object)

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object
See Also:
Object.hashCode()

isMarked

public boolean isMarked(double mortality)
Specified by:
isMarked in interface Mortality
Parameters:
mortality - the probability that an organism will die before the next generation (a value between 0 and 1).
Returns:
true if that organism is actually marked for death (i.e. if the mortality value exceeds the current bias, perturbed by a random variation)

setBias

public void setBias(double bias)
Set the value of bias. Typically set by dependency injection.

Parameters:
bias - a value between 0 and 1. If 0 then most organisms will probably die, while if 1 then few organisms are likely to die.

calculateAgeViabilityFactor

protected double calculateAgeViabilityFactor(int age)
Subclasses where viability depends on age must override this method. TEST

Parameters:
age -
Returns:
1.0, that is to say mortality depends only on fitness and saturation -- not age.

calculateViability

protected double calculateViability(int age,
                                    double fitness,
                                    double saturation)
Parameters:
age -
fitness -
saturation -
Returns:
the viability, between 0 and 1

getBias

protected double getBias()

getRandom

protected org.apache.commons.math.random.RandomGenerator getRandom()
Returns:
the random number generator


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