Class NumberOfViolatedConstraintsComparator<S extends Solution<?>>

java.lang.Object
org.uma.jmetal.util.comparator.constraintcomparator.impl.NumberOfViolatedConstraintsComparator<S>
All Implemented Interfaces:
Comparator<S>, ConstraintComparator<S>

public class NumberOfViolatedConstraintsComparator<S extends Solution<?>> extends Object implements ConstraintComparator<S>
This class implements a Comparator for Solution objects based on the number of violated constraints of solutions.
Author:
Antonio J. Nebro invalid input: '<'antonio@lcc.uma.es>
  • Constructor Details

    • NumberOfViolatedConstraintsComparator

      public NumberOfViolatedConstraintsComparator()
  • Method Details

    • compare

      public int compare(S solution1, S solution2)
      Compares two solutions. If the solutions has no constraints the method return 0
      Specified by:
      compare in interface Comparator<S extends Solution<?>>
      Parameters:
      solution1 - Object representing the first Solution.
      solution2 - Object representing the second Solution.
      Returns:
      -1 if the number of violated constraints 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).