Package org.uma.jmetal.util.comparator
Class ConstraintViolationComparator<S extends Solution<?>>
java.lang.Object
org.uma.jmetal.util.comparator.ConstraintViolationComparator<S>
- All Implemented Interfaces:
java.util.Comparator<S>
public class ConstraintViolationComparator<S extends Solution<?>>
extends java.lang.Object
implements java.util.Comparator<S>
This class implements a
Comparator (a method for comparing Solution objects)
based on the overall constraint violation of the solutions, as done in NSGA-II.- Author:
- Antonio J. Nebro
-
Constructor Summary
Constructors Constructor Description ConstraintViolationComparator() -
Method Summary
-
Constructor Details
-
ConstraintViolationComparator
public ConstraintViolationComparator()
-
-
Method Details
-
compare
Compares two solutions. If the solutions has no constraints the method return 0- Specified by:
comparein interfacejava.util.Comparator<S extends Solution<?>>- Parameters:
solution1- Object representing the firstSolution.solution2- Object representing the secondSolution.- Returns:
- -1 if the overall constraint violation degree of solution1 is higher than the one of solution2, 1 in the opposite case, and 0 if they have the same value (this case applies when the two compared solutions have no constraints). Note that the violation degree is a negative number, so when comparing to two solutions, the higher the value the better.
-