code: @Override
    public int compare(S solution1, S solution2) {
      if (overallConstraintViolation.getAttribute(solution1) == null) {
        return 0 ;
      }
  
      double overall1, overall2;
      overall1 = numberOfViolatedConstraints.getAttribute(solution1) *
          overallConstraintViolation.getAttribute(solution1);
      overall2 = numberOfViolatedConstraints.getAttribute(solution2) *
          overallConstraintViolation.getAttribute(solution2);
  
      if ((overall1 < 0) && (overall2 < 0)) {
        if (overall1 > overall2) {
          return -1;
        } else if (overall2 > overall1) {
          return 1;
        } else {
          return 0;
        }
      } else if ((overall1 == 0) && (overall2 < 0)) {
        return -1;
      } else if ((overall1 < 0) && (overall2 == 0)) {
        return 1;
      } else {
        return 0;
      }
    }
docs: Compares two solutions. If the solutions has no constraints the method return 0
  
  @param solution1 Object representing the first <code>Solution</code>.
  @param solution2 Object representing the second <code>Solution</code>.
  @return -1, or 0, or 1 if o1 is less than, equal, or greater than o2,
  respectively.