com.rubecula.darwin.domain.world
Class MateChoice_

java.lang.Object
  extended by com.rubecula.darwin.domain.world.MateChoice_
All Implemented Interfaces:
MateChoice
Direct Known Subclasses:
MateChoice_Evaluator, MateChoice_Wrightian

public abstract class MateChoice_
extends java.lang.Object
implements MateChoice

Abstract class defining the base methods of MateChoice.

Author:
Robin Hillyard

Field Summary
protected  Attraction _attraction
           
protected static org.apache.commons.logging.Log LOG
          The logger for this class.
 
Constructor Summary
protected MateChoice_(org.apache.commons.math.random.RandomGenerator random, Attraction attraction)
          protected constructor.
 
Method Summary
 Organism chooseMate(Organism female, Lek lek)
          Choose the best (male) mate for the given female, from among all of the organisms at the lek.
 Mating createPairBond(Organism female, Lek lek, Lek alternativeLek)
          First, we call MateChoice.pairUp(Organism, Lek) for the female, lek and the appropriate genomic.
 boolean equals(java.lang.Object obj)
           
 java.util.Collection<Mating> findPairs(java.util.Collection<Organism> organisms, Lek lek, Lek alternativeLek)
          Method to enumerate a set of mating pairs: females from the given set of organisms and males from either the lek or the alternativeLek .
protected  double getAttraction(Organism female, Organism male)
           
protected  Attraction getAttractionEvaluator()
           
protected  double getDesirability(Organism male)
           
 double getDesirabilityIndex(Organism female, Organism male)
          Method to determine the desirability of a given male in the eyes, etc.
 Lek getLek(Colony colony)
          Method to get a "lek", that is to say a population of breeding males.
 org.apache.commons.math.random.RandomGenerator getRandom()
          Getter/setter typically called by reflection, but also called via this interface.
protected  double getSampleFraction()
           
 int hashCode()
           
 Mating pairUp(Organism female, Lek lek)
          Method to create a Mating object based on the female given and a male chosen from the lek.
 void setRandom(org.apache.commons.math.random.RandomGenerator random)
          Reset the current random number generator.
 void setSampleFraction(double sampleFraction)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.rubecula.darwin.domain.helper.MateChoice
getMinimumDesirability
 

Field Detail

_attraction

protected final Attraction _attraction

LOG

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

Constructor Detail

MateChoice_

protected MateChoice_(org.apache.commons.math.random.RandomGenerator random,
                      Attraction attraction)
protected constructor.

Parameters:
random - random number source.
attraction - sexual selection evaluator (if null then Attraction_Uniform is employed).
Method Detail

chooseMate

public Organism chooseMate(Organism female,
                           Lek lek)
Choose the best (male) mate for the given female, from among all of the organisms at the lek. Typically, the lek is only a sample of available breeding males. If no mate can be found amongst the sample, we look at the remainder, in case we can find a mate among those. This is primarily an optimization.

Specified by:
chooseMate in interface MateChoice
Parameters:
female -
lek - a collection of organisms from which to choose a (male) mate for the given female, (note that, currently, not all of the organisms are male, some are competing females).
Returns:
an appropriate male (or null if none live up to expectations).

createPairBond

public Mating createPairBond(Organism female,
                             Lek lek,
                             Lek alternativeLek)
First, we call MateChoice.pairUp(Organism, Lek) for the female, lek and the appropriate genomic. If this is not-null, we return it. Otherwise, we invoke Insular.isIsolated() and IF the result is false, AND if the alternative lek is not null and its colony is not the same as this colony, THEN we invoke MateChoice.pairUp(Organism, Lek) for the female, alternativeLek and the appropriate genomic. We return the result. This method should only be called if the female organism is in fact female.

Specified by:
createPairBond in interface MateChoice
Parameters:
female - the organism for whom we require a mate.
lek - the primary lek from which the female chooses a mate
alternativeLek - the alternative lek from which the female chooses a mate (may be null)
Returns:
a newly constructed Mating object, or null.
See Also:
MateChoice.createPairBond(com.rubecula.darwin.domain.helper.Organism, com.rubecula.darwin.domain.world.Lek, com.rubecula.darwin.domain.world.Lek)

equals

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

findPairs

public java.util.Collection<Mating> findPairs(java.util.Collection<Organism> organisms,
                                              Lek lek,
                                              Lek alternativeLek)
Method to enumerate a set of mating pairs: females from the given set of organisms and males from either the lek or the alternativeLek . Unlike the rest of the Darwin package, there IS an asymmetry here between the sexes. Every female organism is involved in exactly one mating per generation. However, males are chosen randomly and can therefore be involved in any number of matings in a given generation.

Specified by:
findPairs in interface MateChoice
Parameters:
organisms - a collection of organisms from which we will take females and pair them up.
lek -
alternativeLek -
Returns:
a Vector of Mating objects.

getDesirabilityIndex

public double getDesirabilityIndex(Organism female,
                                   Organism male)
Method to determine the desirability of a given male in the eyes, etc. of a given female.

Specified by:
getDesirabilityIndex in interface MateChoice
Parameters:
female - the choosy female.
male - the poor schmuck male.
Returns:
((maleViability*9)+1) * 2^(2*random-1)
See Also:
MateChoice.getDesirabilityIndex(com.rubecula.darwin.domain.helper.Organism, com.rubecula.darwin.domain.helper.Organism)

getLek

public Lek getLek(Colony colony)
Description copied from interface: MateChoice
Method to get a "lek", that is to say a population of breeding males.

Specified by:
getLek in interface MateChoice
Parameters:
colony - the colony from which we choose a lek (may be null).
Returns:
a restartable Iterator with an appropriate number of individuals chosen from the population, based on the sampleFraction for this MateChoice. Note that this method will return null if colony is null.
See Also:
MateChoice.getLek(Colony)

getRandom

public org.apache.commons.math.random.RandomGenerator getRandom()
Description copied from interface: MateChoice
Getter/setter typically called by reflection, but also called via this interface.

Specified by:
getRandom in interface MateChoice
Returns:
the random

hashCode

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

pairUp

public Mating pairUp(Organism female,
                     Lek lek)
Description copied from interface: MateChoice
Method to create a Mating object based on the female given and a male chosen from the lek.

Specified by:
pairUp in interface MateChoice
Parameters:
female -
lek - a collection of organisms from which to choose a (male) mate for the given female, (note that not all of the organisms are male, some are competing females).
Returns:
a newly constructed Mating_Haldanian if a suitable male was found, else null.
See Also:
MateChoice.pairUp(com.rubecula.darwin.domain.helper.Organism, Lek)

setRandom

public void setRandom(org.apache.commons.math.random.RandomGenerator random)
Reset the current random number generator. TEST

Specified by:
setRandom in interface MateChoice
Parameters:
random - random number generator.
See Also:
MateChoice.setRandom(org.apache.commons.math.random.RandomGenerator)

setSampleFraction

public void setSampleFraction(double sampleFraction)
Parameters:
sampleFraction - the sampleFraction to set

getAttraction

protected double getAttraction(Organism female,
                               Organism male)
Parameters:
female -
male -
Returns:

getAttractionEvaluator

protected Attraction getAttractionEvaluator()

getDesirability

protected double getDesirability(Organism male)
Parameters:
male -
Returns:
the desirability of this male based on viability, and a random number r: d = v * 2^(2r-1) where v is 10 if viable, 1 otherwise.

getSampleFraction

protected double getSampleFraction()
Returns:
the sampleFraction


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