Package org.uma.jmetal.util.comparator
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
- See Also:
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionObjectiveComparator(int objectiveId) Constructor.ObjectiveComparator(int objectiveId, ObjectiveComparator.Ordering order) Comparator. -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Constructor Details
-
ObjectiveComparator
public ObjectiveComparator(int objectiveId) Constructor.- Parameters:
objectiveId- The index of the objective to compare
-
ObjectiveComparator
Comparator.- Parameters:
objectiveId- The index of the objective to compareorder- Ascending or descending order
-
-
Method Details
-
compare
Compares two solutions according to a given objective.- Specified by:
comparein interfaceComparator<S extends Solution<?>>- Parameters:
solution1- The first solutionsolution2- 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
-