net.sourceforge.cilib.problem.solution.Fitness Maven / Gradle / Ivy
Show all versions of cilib-library Show documentation
/** __ __
* _____ _/ /_/ /_ Computational Intelligence Library (CIlib)
* / ___/ / / / __ \ (c) CIRG @ UP
* / /__/ / / / /_/ / http://cilib.net
* \___/_/_/_/_.___/
*/
package net.sourceforge.cilib.problem.solution;
import net.sourceforge.cilib.type.types.Type;
/**
* This interface is an abstraction for the fitness of a solution to an
* optimisation problem.
*
* The actual fitness value (as determined by the
* {@link net.sourceforge.cilib.problem.Problem} in question) can be obtained by
* calling {@link #getValue()} while fitnesses can be compared using the
* standard Java {@link Comparable} interface.
*
* Example:
*
* Fitness a = ...;
* Fitness b = ...;
*
* int result = a.compareTo(b);
* if (result > 0) {
* // a is a superior fitness to b
* }
* else if (result < 0) {
* // b is a superior fitness to a
* }
* else {
* // a and b are equally fit
* }
*
*
*/
public interface Fitness extends Type, Comparable {
/**
* {@inheritDoc}
*/
@Override
Fitness getClone();
/**
* Returns the underlying fitness value.
* @return the actual fitness value.
*/
Double getValue();
/**
* Creation method that maintains Fitness object immutability by returning
* a new instance of the current class type.
* @param value The desired value of the {@code Fitness} object.
*/
Fitness newInstance(Double value);
}