Class ObjectiveComparator<S extends Solution<?>>

java.lang.Object
org.uma.jmetal.util.comparator.ObjectiveComparator<S>
All Implemented Interfaces:
Serializable, Comparator<S>

public class ObjectiveComparator<S extends Solution<?>> extends Object implements Comparator<S>, Serializable
This class implements a comparator based on a given objective
Author:
Antonio J. Nebro <antonio@lcc.uma.es>
See Also:
  • Constructor Details

    • ObjectiveComparator

      public ObjectiveComparator(int objectiveId)
      Constructor.
      Parameters:
      objectiveId - The index of the objective to compare
    • ObjectiveComparator

      public ObjectiveComparator(int objectiveId, ObjectiveComparator.Ordering order)
      Comparator.
      Parameters:
      objectiveId - The index of the objective to compare
      order - Ascending or descending order
  • Method Details

    • compare

      public int compare(S solution1, S solution2)
      Compares two solutions according to a given objective.
      Specified by:
      compare in interface Comparator<S extends Solution<?>>
      Parameters:
      solution1 - The first solution
      solution2 - The second solution
      Returns:
      -1, or 0, or 1 if solution1 is less than, equal, or greater than solution2, respectively, according to the established order