com.rubecula.darwin.domain.fitness
Class Fitness_Hamiltonian
java.lang.Object
com.rubecula.darwin.domain.fitness.Fitness_
com.rubecula.darwin.domain.fitness.Fitness_Hamiltonian
- All Implemented Interfaces:
- Fitness, com.rubecula.jexpression.EvalExpression
public final class Fitness_Hamiltonian
- extends Fitness_
This is a standard implementation of Fitness
well suited to
configuration via XML and dependency injection.
It is however very basic and is not normally used where a fitness function is
complex, for example in the peppered moth application.
In order for this implementation to work properly, the weights must be set by
calling the method putWeighting(String, EcoFactor)
with the
appropriate pair of values: a String which corresponds to the key
(identifier) of a phenotypic character; and an EcoFactor against which traits
of the character will be measured for fitness.
This concrete class is named in honor of W. D. Hamilton,
although I don't claim that the specifics of the class's behavior have
anything to do with inclusive fitness.
- Author:
- Robin Hillyard
Fields inherited from class com.rubecula.darwin.domain.fitness.Fitness_ |
LOG |
Methods inherited from class com.rubecula.darwin.domain.fitness.Fitness_ |
calculateFitness, compare, equals, getEnvironmentFactor, getExpression, getExpressionTerms, getFitnessFunction, getTolerance, hashCode, resetAdjustment, resetEnvironmentFactor, scaleFactor, scaleTrait, setTolerance, toString |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Fitness_Hamiltonian
public Fitness_Hamiltonian()
Fitness_Hamiltonian
public Fitness_Hamiltonian(FitnessFunction fitnessFunction,
FunctionListener functionListener)
- Parameters:
fitnessFunction
- functionListener
-
getFitness
public double getFitness(Trait trait,
EcoFactor factor)
throws FitnessException
- 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)
- 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)
putWeighting
public EcoFactor putWeighting(java.lang.String character,
EcoFactor factor)
- Parameters:
character
- the key (identifier) for the character whose traits will be
measured for fitness against factor.factor
-
- Returns:
- the previous value corresponding to this key.
- See Also:
HashMap.put(java.lang.Object, java.lang.Object)
setBandwidth
public void setBandwidth(double bandwidth)
- Parameters:
bandwidth
- the bandwidth to set
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:
- the value of
bandwidth
. - See Also:
Fitness_.bandwidth(java.lang.String)
Copyright © 2010 Rubecula Software, LLC. All Rights Reserved.