es.udc.gii.common.eaf.algorithm.fitness.comparator
Class MinimizingGeneValueComparator<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.MinimizingGeneValueComparator<T>
All Implemented Interfaces:
java.util.Comparator<T>

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

This class implements a comparator for comparing two instances i1 and i2 of Individual based on their genes values.

Since:
1.0
Author:
Grupo Integrado de IngenierĂ­a (www.gii.udc.es)

Field Summary
private  int geneIndex
           
 
Constructor Summary
MinimizingGeneValueComparator()
          Creates a new instance of MinimizingGeneValueComparator
 
Method Summary
 int compare(T o1, T o2)
          Compares two individuals based on their genes values.
 void setGeneIndex(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

geneIndex

private int geneIndex
Constructor Detail

MinimizingGeneValueComparator

public MinimizingGeneValueComparator()
Creates a new instance of MinimizingGeneValueComparator

Method Detail

compare

public int compare(T o1,
                   T o2)
Compares two individuals based on their genes values.

Specified by:
compare in interface java.util.Comparator<T extends Individual>
Specified by:
compare in class FitnessComparator<T extends Individual>
Parameters:
o1 - First individual to compare.
o2 - Second individual to compare.
Returns:
If the gene value of the individual o1 is lower than the gene value of the individual o2 returns -1. If the gene value of the individual o2 is lower than the gen value of the individual o1 returns 1. If the gene value of the individual o1 is equal to the gene value of the individual o2 returns 0.

setGeneIndex

public void setGeneIndex(int index)

toString

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