Class EvaluatedCandidate<T>
- java.lang.Object
-
- org.uncommons.watchmaker.framework.EvaluatedCandidate<T>
-
- Type Parameters:
T
- The candidate type.
- All Implemented Interfaces:
Comparable<EvaluatedCandidate<T>>
public final class EvaluatedCandidate<T> extends Object implements Comparable<EvaluatedCandidate<T>>
Immutable wrapper class for associating a candidate solution with its fitness score.
-
-
Constructor Summary
Constructors Constructor Description EvaluatedCandidate(T candidate, double fitness)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(EvaluatedCandidate<T> evaluatedCandidate)
Compares this candidate's fitness score with that of the specified candidate.boolean
equals(Object o)
Over-ridden to be consistent withcompareTo(EvaluatedCandidate)
.T
getCandidate()
double
getFitness()
int
hashCode()
Over-ridden to be consistent withequals(Object)
.
-
-
-
Constructor Detail
-
EvaluatedCandidate
public EvaluatedCandidate(T candidate, double fitness)
- Parameters:
candidate
- The evolved candidate.fitness
- The candidates fitness score.
-
-
Method Detail
-
getCandidate
public T getCandidate()
- Returns:
- The evolved candidate solution.
-
getFitness
public double getFitness()
- Returns:
- The fitness score for the associated candidate.
-
compareTo
public int compareTo(EvaluatedCandidate<T> evaluatedCandidate)
Compares this candidate's fitness score with that of the specified candidate.- Specified by:
compareTo
in interfaceComparable<T>
- Parameters:
evaluatedCandidate
- The candidate to compare scores with.- Returns:
- -1, 0 or 1 if this candidate's score is less than, equal to, or greater than that of the specified candidate. The comparison applies to the raw numerical score and does not consider whether that score is a natural fitness score or not.
-
equals
public boolean equals(Object o)
Over-ridden to be consistent withcompareTo(EvaluatedCandidate)
.
-
hashCode
public int hashCode()
Over-ridden to be consistent withequals(Object)
.
-
-