Package de.sfuhrm.genetic
Class AbstractHypothesis<T extends AbstractHypothesis>
java.lang.Object
de.sfuhrm.genetic.AbstractHypothesis<T>
- Type Parameters:
T- the parameter needs to have the concrete type of the hypothesis class for the methods to return the correct subtype.
public abstract class AbstractHypothesis<T extends AbstractHypothesis>
extends java.lang.Object
Hypothesis base class.
- Author:
- Stephan Fuhrmann
-
Constructor Summary
Constructors Constructor Description AbstractHypothesis() -
Method Summary
Modifier and Type Method Description protected abstract doublecalculateFitness()Calculates the fitness of this hypothesis.protected abstract java.util.List<T>crossOver(T other)Returns a two-element crossover offspring of this and the other hypothesis.protected abstract voidmutate()Implements the mutation operator.protected abstract TrandomInit()Randomly initialize the hypothesis.
-
Constructor Details
-
AbstractHypothesis
public AbstractHypothesis()
-
-
Method Details
-
randomInit
Randomly initialize the hypothesis.- Returns:
- returns
thishypothesis after a random initialization.
-
crossOver
Returns a two-element crossover offspring of this and the other hypothesis.- Parameters:
other- the other hypothesis to cross-over with.- Returns:
- a two-element List of the offsprings.
-
calculateFitness
protected abstract double calculateFitness()Calculates the fitness of this hypothesis.- Returns:
- a fitness where a bigger number means more fitness. Please be advised that negative numbers will be problematic for the algorithm.
-
mutate
protected abstract void mutate()Implements the mutation operator. The mutation operator flips one bit of the genome of the hypothesis.
-