net.sourceforge.cilib.problem
Class InferiorFitness

java.lang.Object
  extended by net.sourceforge.cilib.problem.InferiorFitness
All Implemented Interfaces:
Serializable, Comparable<Fitness>, Fitness, Type, Cloneable

public final class InferiorFitness
extends Object
implements Fitness

This class is used to represent a fitness value that is always inferior.

This class is a singleton.

Author:
Edwin Peer
See Also:
Serialized Form

Method Summary
 int compareTo(Fitness other)
          Returns -1, unless other is also the InferiorFitness instance.
 boolean equals(Object object)
          Compare the specified object with this type for equality.
 InferiorFitness getClone()
          Get the cloned instance of this object.
 Double getValue()
          Always returns null.
 int hashCode()
          Returns the hash code value for this list.
static Fitness instance()
          Obtain a reference to the InferiorFitness instance.
 Fitness newInstance(Double value)
          Creation method that maintains Fitness object immutability by returning a new instance of the current class type.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getClone

public InferiorFitness getClone()
Get the cloned instance of this object. Due to this obect being a Singleton, the same instance is returned and is not cloned.

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

getValue

public Double getValue()
Always returns null. InferiorFitness does not have a value. The most sensible value to return is Double.NaN as it is still a value, however, it represents something that is not a number (effectively null). Returning Double.NaN will ensure that some of the Measurements do get an value, even if the value is Double.NaN

Specified by:
getValue in interface Fitness
Returns:
Double.NaN as the value is always inferior.

newInstance

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

Specified by:
newInstance in interface Fitness
Parameters:
value - The desired value of the Fitness object.

compareTo

public int compareTo(Fitness other)
Returns -1, unless other is also the InferiorFitness instance.

Specified by:
compareTo in interface Comparable<Fitness>
Specified by:
compareTo in interface Fitness
Parameters:
other - The fitness to be compared.
Returns:
0 if other is InferiorFitness instance, -1 otherwise.
See Also:
Comparable

equals

public boolean equals(Object object)
Compare the specified object with this type for equality. Returns true if and only if the specified object is also an instance of the same type.

Specified by:
equals in interface Type
Overrides:
equals in class Object
Parameters:
object - The object to compare.
Returns:
true if equality exists, false otherwise.
See Also:
Object.equals(Object)

hashCode

public int hashCode()
Returns the hash code value for this list. The hash code of a list is defined to be the result of the following calculation:
  int hashCode = 7;
  Iterator<E> i = list.iterator();
  while (i.hasNext()) {
      E obj = i.next();
      hashCode = 31*hashCode + (obj==null ? 0 : obj.hashCode());
  }
 
This ensures that type1.equals(type2) implies that type1.hashCode()==type2.hashCode() for any two types, type1 and type2, as required by the general contract of Object.hashCode().

Specified by:
hashCode in interface Type
Overrides:
hashCode in class Object
Returns:
the hash code value for this list
See Also:
Object.equals(Object), Type.equals(Object)

instance

public static Fitness instance()
Obtain a reference to the InferiorFitness instance.

Returns:
the InferiorFitness instance.


Copyright © 2009 CIRG. All Rights Reserved.