com.rubecula.darwin.examples.pepperedmoth
Class WcSdFitness

java.lang.Object
  extended by com.rubecula.darwin.domain.fitness.Fitness_
      extended by com.rubecula.darwin.examples.pepperedmoth.WcSdFitness
All Implemented Interfaces:
Fitness, HasExpressions, com.rubecula.jexpression.EvalExpression

public class WcSdFitness
extends Fitness_
implements HasExpressions

Application-specific Fitness implementation. I'm a bit disappointed because I thought I was going to be able to do this without any instanceof constructs. Maybe I can, but for now I'm going to let it be.

Author:
Robin Hillyard

Field Summary
 
Fields inherited from class com.rubecula.darwin.domain.fitness.Fitness_
LOG
 
Constructor Summary
WcSdFitness()
           
WcSdFitness(com.rubecula.jexpression.Evaluator evaluator, FunctionListener functionListener)
           
 
Method Summary
protected  double bandwidth(java.lang.String key)
          Concrete sub-classes must implement this method to indicate how sharp the fitness curve should be with respect to the possible values of the variate.
 ExpressionMap getExpressions()
           
 double getFitness(Trait trait, EcoFactor factor)
           
 int getWeight(java.lang.String character, EcoFactor factor)
           
protected  double scaleFactor(java.lang.String key)
          Scale down the eco factor by a factor of 10 before comparing with the soot equivalent.
 
Methods inherited from class com.rubecula.darwin.domain.fitness.Fitness_
calculateFitness, compare, equals, getEnvironmentFactor, getExpression, getExpressionTerms, getFitnessFunction, getTolerance, hashCode, resetAdjustment, resetEnvironmentFactor, scaleTrait, setTolerance, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WcSdFitness

public WcSdFitness()

WcSdFitness

public WcSdFitness(com.rubecula.jexpression.Evaluator evaluator,
                   FunctionListener functionListener)
Parameters:
evaluator -
functionListener - the function listener (may be null)
Method Detail

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()

getFitness

public double getFitness(Trait trait,
                         EcoFactor factor)
                  throws FitnessException
Specified by:
getFitness in interface Fitness
Returns:
the fitness between 0 (unfit) and 1 (perfect fit).
Throws:
FitnessException
See Also:
Fitness.getFitness(com.rubecula.darwin.domain.helper.Trait, com.rubecula.darwin.domain.helper.EcoFactor)

getWeight

public int getWeight(java.lang.String character,
                     EcoFactor factor)
Specified by:
getWeight in interface Fitness
Parameters:
character - the identifier (or key) of the phenotypic character whose traits/variants will be measured for fitness against the given factor.
Returns:
the relative weighting for this fitness (0: not a significant fitness match)
See Also:
Fitness.getWeight(String, com.rubecula.darwin.domain.helper.EcoFactor)

bandwidth

protected double bandwidth(java.lang.String key)
Description copied from class: Fitness_
Concrete sub-classes must implement this method to indicate how sharp the fitness curve should be with respect to the possible values of the variate.

Specified by:
bandwidth in class Fitness_
Parameters:
key - the key which determines which bandwidth to get (trait or ecofactor).
Returns:
0.25.
See Also:
Fitness_.bandwidth(String)

scaleFactor

protected double scaleFactor(java.lang.String key)
Scale down the eco factor by a factor of 10 before comparing with the soot equivalent.

Overrides:
scaleFactor in class Fitness_
Parameters:
key - the key (identifier) of the ecoFactor
Returns:
a scale factor to be applied (to the eco factor value) before the difference is calculated between the trait as a value and the eco factor as a value. By value returned by this base method is 1.0. Specific fitness implementations must override if the value is to be different.
See Also:
Fitness_.scaleFactor(String)


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