public final class SimpleSolution<T extends java.io.Serializable> extends java.lang.Object implements Solution<T>
Basic implementation of the Solution
interface. Stores any serializable object.
Modifier and Type | Field and Description |
---|---|
private double |
fitness |
private static long |
serialVersionUID |
private T |
value |
Constructor and Description |
---|
SimpleSolution(T value) |
SimpleSolution(T value,
double fitness) |
Modifier and Type | Method and Description |
---|---|
double |
fitnessValue()
Returns the fitness of this solution.
|
java.lang.String |
toString() |
T |
unwrap()
Returns the real value of this solution.
|
SimpleSolution<T> |
withFitness(double newFitness)
Updates the fitness of this solution.
|
private static final long serialVersionUID
private final T extends java.io.Serializable value
private final double fitness
public SimpleSolution(T value, double fitness)
public SimpleSolution(T value)
public double fitnessValue()
Solution
Returns the fitness of this solution. If the fitness was not computed, the returned value will be Double#NaN
.
fitnessValue
in interface Solution<T extends java.io.Serializable>
public SimpleSolution<T> withFitness(double newFitness)
Solution
Updates the fitness of this solution.
This function returns a new instance.
withFitness
in interface Solution<T extends java.io.Serializable>
newFitness
- new fitness valuepublic T unwrap()
Solution
Returns the real value of this solution.
public java.lang.String toString()
toString
in class java.lang.Object