net.sourceforge.cilib.problem
Interface Fitness

All Superinterfaces:
Cloneable, Comparable<Fitness>, Serializable, Type
All Known Subinterfaces:
NNError
All Known Implementing Classes:
ClassificationErrorReal, InferiorFitness, MaximisationFitness, MinimisationFitness, MOFitness, MSEErrorFunction

public interface Fitness
extends Type, Comparable<Fitness>, Serializable

This interface is an abstraction for the fitness of a solution to an optimisation problem. The actual fitness value (as determined by the OptimisationProblem in question) can be obtained by calling getValue() while fitnesses can be compared using the standard Java 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
}

Author:
Edwin Peer

Method Summary
 int compareTo(Fitness o)
          Compare the current fitness instance to the provided instance.
 Fitness getClone()
          Create a cloned copy of the current object and return it.
 Double getValue()
          Returns the underlying fitness value.
 Fitness newInstance(Double value)
          Creation method that maintains Fitness object immutability by returning a new instance of the current class type.
 
Methods inherited from interface net.sourceforge.cilib.type.types.Type
equals, hashCode
 

Method Detail

getClone

Fitness getClone()
Create a cloned copy of the current object and return it. In general the created copy will be a deep copy of the provided instance. As a result this operation an be quite expensive if used incorrectly.

Specified by:
getClone in interface Cloneable
Specified by:
getClone in interface Type
Returns:
An exact clone of the current object instance.
See Also:
Object.clone()

getValue

Double getValue()
Returns the underlying fitness value.

Returns:
the actual fitness value.

compareTo

int compareTo(Fitness o)
Compare the current fitness instance to the provided instance. Returns a negative integer, zero and a positive integer as this object is less than, equal to or greater than the specified object.

Specified by:
compareTo in interface Comparable<Fitness>
Parameters:
o - The fitness to be compared.
Returns:
a negative integer, zero or a positive integer if this object is less than, equal to or greater than the specified object.
See Also:
Comparable

newInstance

Fitness newInstance(Double value)
Creation method that maintains Fitness object immutability by returning a new instance of the current class type.

Parameters:
value - The desired value of the Fitness object.


Copyright © 2009 CIRG. All Rights Reserved.