es.udc.gii.common.eaf.algorithm.fitness.comparator
Class MinimizingObjectiveComparator<T extends Individual>

java.lang.Object
  extended by es.udc.gii.common.eaf.algorithm.fitness.comparator.FitnessComparator<T>
      extended by es.udc.gii.common.eaf.algorithm.fitness.comparator.MinimizingObjectiveComparator<T>
All Implemented Interfaces:
java.util.Comparator<T>

public class MinimizingObjectiveComparator<T extends Individual>
extends FitnessComparator<T>

This class compares two individuals considering only one of the objective values of each individual. Lesser values are better, i.e. it minimizes a given objective.

Author:
lucia

Field Summary
private  int objectiveIndex
          Objective index of the objective under comparison.
 
Constructor Summary
MinimizingObjectiveComparator()
           
 
Method Summary
 int compare(T o1, T o2)
          Compares one single objective value of two individuals.
 int getObjectiveIndex()
           
 void setObjectiveIndex(int index)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
equals
 

Field Detail

objectiveIndex

private int objectiveIndex
Objective index of the objective under comparison.

Constructor Detail

MinimizingObjectiveComparator

public MinimizingObjectiveComparator()
Method Detail

compare

public int compare(T o1,
                   T o2)
Compares one single objective value of two individuals. Which objective is compared is given by an index returned by #getObjectiveIndex. For example, if this index is 2, then the two individuals are compared against the third objective value (indices start by 0). Lesser values are considered better.

Specified by:
compare in interface java.util.Comparator<T extends Individual>
Specified by:
compare in class FitnessComparator<T extends Individual>
Parameters:
o1 - - First individual.
o2 - - Second individual.
Returns:
-1 if o1 is better than o2, 1 if o2 is better than o1 and 0 if both individual have the same objective value for the given objective index.

setObjectiveIndex

public void setObjectiveIndex(int index)

getObjectiveIndex

public int getObjectiveIndex()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object