com.rubecula.darwin.domain.world
Class Function_Desirable

java.lang.Object
  extended by com.rubecula.darwin.foundation.Function_
      extended by com.rubecula.darwin.domain.world.Function_Desirable
All Implemented Interfaces:
Desirable, Function, HasExpressions, com.rubecula.jexpression.EvalExpression, com.rubecula.jexpression.EvalExpressionMutable, com.rubecula.jexpression.Valuable, net.sf.tostring0.Identifiable

public class Function_Desirable
extends Function_
implements Desirable, HasExpressions

Concrete implementation of Desirable which extends Function_ and implements HasExpressions (thus it can be updated graphically at runtime).

Author:
Robin Hillyard

Field Summary
 
Fields inherited from class com.rubecula.darwin.foundation.Function_
evaluator, LOG
 
Constructor Summary
Function_Desirable()
           
Function_Desirable(com.rubecula.jexpression.Evaluator evaluator)
           
 
Method Summary
 double getDesirability(boolean viability, double random, int age)
           
 ExpressionMap getExpressions()
           
 java.lang.String getIdentifier()
           
protected  double standardFunction(java.lang.Object... arguments)
           
protected  java.lang.CharSequence[] standardFunctionTokens(com.rubecula.jexpression.Notation notation)
           
 
Methods inherited from class com.rubecula.darwin.foundation.Function_
addListener, addSymbol, equals, evaluate, getErrorInfo, getEvaluator, getExpression, getExpressionMap, getExpressionTerms, getValue, hashCode, isDifferent, isMutable, normalDistributionDensityFunction, normalDistributionDensityFunctionScaled, onFunctionChange, removeVariable, reset, setEvaluator, setExpression, setExpression
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.rubecula.jexpression.EvalExpressionMutable
isMutable, setExpression, setExpression
 
Methods inherited from interface com.rubecula.jexpression.EvalExpression
getExpression, getExpressionTerms
 

Constructor Detail

Function_Desirable

public Function_Desirable()

Function_Desirable

public Function_Desirable(com.rubecula.jexpression.Evaluator evaluator)
Parameters:
evaluator -
Method Detail

getDesirability

public double getDesirability(boolean viability,
                              double random,
                              int age)
Specified by:
getDesirability in interface Desirable
Parameters:
viability - true if the male is viable
random - a random number between 0 and 1
age - the age of the male
Returns:
the desirability either hard-coded or based on the current customized formula
See Also:
Desirable.getDesirability(boolean, double, int)

getExpressions

public ExpressionMap getExpressions()
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(), HasExpressions.getExpressions()

getIdentifier

public java.lang.String getIdentifier()
Specified by:
getIdentifier in interface net.sf.tostring0.Identifiable
Returns:
(typically) "Desirability"
See Also:
Identifiable.getIdentifier()

standardFunction

protected double standardFunction(java.lang.Object... arguments)
                           throws FunctionException
Specified by:
standardFunction in class Function_
Parameters:
arguments - these arguments must be, in order,
  1. Integer: viabilityFactor (10 for viable, 1 for non-viable)
  2. Number: random
  3. Integer: age

Note that the arguments are auto-boxed for passing into evaluateFixedExpression(int, double, int). Note also that we do not protect against cast exceptions.
Returns:
the result of invoking evaluateFixedExpression(int, double, int).
Throws:
FunctionException - XXX
See Also:
com.rubecula.darwin.foundation.Function_#standardFunction(double[])

standardFunctionTokens

protected java.lang.CharSequence[] standardFunctionTokens(com.rubecula.jexpression.Notation notation)
Specified by:
standardFunctionTokens in class Function_
Parameters:
notation - the notation type used by the evaluator.
Returns:
the sequence of tokens that corresponds to the Function_.standardFunction(Object...). This is called by Function_.reset().
See Also:
Function_.standardFunctionTokens(Notation)


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