net.sourceforge.cilib.problem
Class MinimisationFitness

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

public class MinimisationFitness
extends Object
implements Fitness

This class implements the Comparable interface for a minimisation problem. That is, smaller fitness values have superior fitness.

Author:
Edwin Peer
See Also:
Serialized Form

Constructor Summary
MinimisationFitness(Double value)
          Constructs a new MinimisationFitness with the given fitness value.
MinimisationFitness(MinimisationFitness copy)
          Create a copy of the given MinimisationFitness.
 
Method Summary
 int compareTo(Fitness other)
          Compare the current fitness instance to the provided instance.
 boolean equals(Object obj)
          Compare the specified object with this type for equality.
 MinimisationFitness getClone()
          Create a cloned copy of the current object and return it.
 Double getValue()
          Returns the underlying fitness value.
 int hashCode()
          Returns the hash code value for this list.
 Fitness newInstance(Double value)
          Creation method that maintains Fitness object immutability by returning a new instance of the current class type.
 String toString()
          Get the textual representation of this Fitness object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MinimisationFitness

public MinimisationFitness(Double value)
Constructs a new MinimisationFitness with the given fitness value.

Parameters:
value - The actual fitness value for the problem.

MinimisationFitness

public MinimisationFitness(MinimisationFitness copy)
Create a copy of the given MinimisationFitness.

Parameters:
copy - The instance to copy.
Method Detail

getClone

public MinimisationFitness 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 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()
Returns the underlying fitness value.

Specified by:
getValue in interface Fitness
Returns:
the actual fitness value.

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)
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>
Specified by:
compareTo in interface Fitness
Parameters:
other - 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

equals

public boolean equals(Object obj)
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:
obj - 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)

toString

public String toString()
Get the textual representation of this Fitness object.

Overrides:
toString in class Object
Returns:
The String representing this object.


Copyright © 2009 CIRG. All Rights Reserved.