net.sourceforge.cilib.problem
Class MaximisationFitness

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

public class MaximisationFitness
extends Object
implements Fitness

Author:
Edwin Peer This class implements the Comparable interface for a maximisation problem. That is, larger fitness values have superior fitness.
See Also:
Serialized Form

Constructor Summary
MaximisationFitness(Double value)
          Constructs a new MaximisationFitness with the given fitness value.
MaximisationFitness(MaximisationFitness copy)
          Copy constructor.
 
Method Summary
 int compareTo(Fitness other)
          Returns superior fitness for larger fitness values.
 boolean equals(Object obj)
          Compare the specified object with this type for equality.
 MaximisationFitness 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.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MaximisationFitness

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

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

MaximisationFitness

public MaximisationFitness(MaximisationFitness copy)
Copy constructor. Create a copy of the provided instance.

Parameters:
copy - The instance to copy.
Method Detail

getClone

public MaximisationFitness 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)
Returns superior fitness for larger fitness values.

Specified by:
compareTo in interface Comparable<Fitness>
Specified by:
compareTo in interface Fitness
Parameters:
other - The fitness to be compared.
Returns:
1 for superior fitness, -1 for inferior fitness and 0 for equivalent fitness.
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)


Copyright © 2009 CIRG. All Rights Reserved.