com.rubecula.darwin.domain.world
Class MateChoice_Evaluator

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

public class MateChoice_Evaluator
extends MateChoice_
implements HasExpressions

Author:
Robin Hillyard TODO this class has some refactoring to do in terms of the public methods - add them to the interface or what?

Field Summary
protected  Desirable _desirabilityEvaluator
           
protected  Choosy _desirabilityMinEvaluator
           
 
Fields inherited from class com.rubecula.darwin.domain.world.MateChoice_
_attraction, LOG
 
Constructor Summary
MateChoice_Evaluator(org.apache.commons.math.random.RandomGenerator random)
          Public secondary constructor -- with no evaluator.
MateChoice_Evaluator(org.apache.commons.math.random.RandomGenerator random, Desirable desirability, Choosy undesirability, Attraction attraction)
           
MateChoice_Evaluator(org.apache.commons.math.random.RandomGenerator random, com.rubecula.jexpression.Evaluator evaluatorDesirable, com.rubecula.jexpression.Evaluator evaluatorChoosy)
          Public constructor.
MateChoice_Evaluator(org.apache.commons.math.random.RandomGenerator random, Function_Desirable functionDesirable, Function_Choosy functionChoosy)
          Public constructor with uniform attraction.
 
Method Summary
 void enableMateChoiceChanges()
          TEST TODO consider eliminating this method.
protected  double getDesirability(Organism male)
          This implementation returns a value which is: d * g * h where d is the value of the desirability index defined by the superclass (see MateChoice_.getDesirabilityIndex(Organism, Organism) ; and g is one more than the age of the candidate male; TODO consider a different mechanism here: instead of passing in a random number to the desirability formula, we should divide the random space into several bands (or tranches), using Randomizer, and then cache the various desirability values for age/viability/tranche.
protected  Desirable getDesirabilityEvaluator()
           
protected  Choosy getDesirabilityMinEvaluator()
           
 ExpressionMap getExpressions()
          XXX Need explanation.
 double getMinimumDesirability()
          By default, this implementation returns a value E^(3.8 * r) where r is a random number between 0 and 1.
 void setEvaluator(int index, java.lang.String expression)
           
 void setExpression(int index, java.lang.String expression)
           
 void setSeed(long seed)
          TODO this should have package visibility (but need to fix a test class first).
 
Methods inherited from class com.rubecula.darwin.domain.world.MateChoice_
chooseMate, createPairBond, equals, findPairs, getAttraction, getAttractionEvaluator, getDesirabilityIndex, getLek, getRandom, getSampleFraction, hashCode, pairUp, setRandom, setSampleFraction
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_desirabilityEvaluator

protected final Desirable _desirabilityEvaluator

_desirabilityMinEvaluator

protected final Choosy _desirabilityMinEvaluator
Constructor Detail

MateChoice_Evaluator

public MateChoice_Evaluator(org.apache.commons.math.random.RandomGenerator random)
Public secondary constructor -- with no evaluator.

Parameters:
random - a random number generator

MateChoice_Evaluator

public MateChoice_Evaluator(org.apache.commons.math.random.RandomGenerator random,
                            Desirable desirability,
                            Choosy undesirability,
                            Attraction attraction)
Parameters:
random -
desirability -
undesirability -
attraction - the implementer of sexual selection.

MateChoice_Evaluator

public MateChoice_Evaluator(org.apache.commons.math.random.RandomGenerator random,
                            com.rubecula.jexpression.Evaluator evaluatorDesirable,
                            com.rubecula.jexpression.Evaluator evaluatorChoosy)
Public constructor.

Parameters:
random - a random number generator
evaluatorDesirable - the expression evaluator to be used for the desirability formula (or null)
evaluatorChoosy - the expression evaluator to be used for the minimum-desirability formula (or null)

MateChoice_Evaluator

public MateChoice_Evaluator(org.apache.commons.math.random.RandomGenerator random,
                            Function_Desirable functionDesirable,
                            Function_Choosy functionChoosy)
Public constructor with uniform attraction.

Parameters:
random - a random number generator
functionDesirable - the expression evaluator to be used for the desirability formula (or null)
functionChoosy - the expression evaluator to be used for the minimum-desirability formula (or null)
Method Detail

enableMateChoiceChanges

public void enableMateChoiceChanges()
TEST TODO consider eliminating this method.


getExpressions

public ExpressionMap getExpressions()
XXX Need explanation.

Specified by:
getExpressions in interface HasExpressions
Returns:
a map of String / EvalExpressionMutable pairs. The String key for each EvalExpressionMutable is the name by which that expression will be known in the user interface.
See Also:
HasExpressions.getExpressions()

getMinimumDesirability

public double getMinimumDesirability()
By default, this implementation returns a value E^(3.8 * r) where r is a random number between 0 and 1. The higher the value returned, the more likely a female will find no mate (and hence look outside the population)

Specified by:
getMinimumDesirability in interface MateChoice
Returns:
a value for the desirability threshold for choosing a mate (same scale as the desirability index, see MateChoice.getDesirabilityIndex(Organism, Organism)
See Also:
MateChoice.getMinimumDesirability()

setEvaluator

public void setEvaluator(int index,
                         java.lang.String expression)
Parameters:
index -
expression - TEST TODO this should have package visibility (but need to fix a test class first).

setExpression

public void setExpression(int index,
                          java.lang.String expression)
                   throws FunctionException
Parameters:
index -
expression - TODO this should have package visibility (but need to fix a test class first).
Throws:
FunctionException

setSeed

public void setSeed(long seed)
TODO this should have package visibility (but need to fix a test class first). ??

Parameters:
seed -
See Also:
MateChoice_.getRandom()

getDesirability

protected double getDesirability(Organism male)
This implementation returns a value which is: d * g * h where d is the value of the desirability index defined by the superclass (see MateChoice_.getDesirabilityIndex(Organism, Organism) ; and g is one more than the age of the candidate male; TODO consider a different mechanism here: instead of passing in a random number to the desirability formula, we should divide the random space into several bands (or tranches), using Randomizer, and then cache the various desirability values for age/viability/tranche.

Overrides:
getDesirability in class MateChoice_
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.
See Also:
MateChoice.getDesirabilityIndex(Organism, Organism), MateChoice_.getDesirabilityIndex(com.rubecula.darwin.domain.helper.Organism, com.rubecula.darwin.domain.helper.Organism), MateChoice_.getDesirability(com.rubecula.darwin.domain.helper.Organism)

getDesirabilityEvaluator

protected Desirable getDesirabilityEvaluator()
Returns:
the value of the field _desirabilityEvaluator

getDesirabilityMinEvaluator

protected Choosy getDesirabilityMinEvaluator()
Returns:
the value of field _desirabilityMinEvaluator


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