@Override
  public int compare(S solution1, S solution2) {
    if (solution1 == null) {
      throw new JMetalException("Solution1 is null") ;
    } else if (solution2 == null) {
      throw new JMetalException("Solution2 is null") ;
    } else if (solution1.getNumberOfObjectives() != solution2.getNumberOfObjectives()) {
      throw new JMetalException("Cannot compare because solution1 has " +
          solution1.getNumberOfObjectives()+ " objectives and solution2 has " +
          solution2.getNumberOfObjectives()) ;
    }
    int result ;
    result = constraintViolationComparator.compare(solution1, solution2) ;
    if (result == 0) {
      result = dominanceTest(solution1, solution2) ;
    }

    return result ;
  }
@ Override public int compare ( S solution1 , S solution2 ) { if ( solution1 == null ) { throw new JMetalException ( "Solution1 is null" ) ; } else if ( solution2 == null ) { throw new JMetalException ( "Solution2 is null" ) ; } else if ( solution1 . getNumberOfObjectives ( ) != solution2 . getNumberOfObjectives ( ) ) { throw new JMetalException ( "Cannot compare because solution1 has " + solution1 . getNumberOfObjectives ( ) + " objectives and solution2 has " + solution2 . getNumberOfObjectives ( ) ) ; } int result ; result = constraintViolationComparator . compare ( solution1 , solution2 ) ; if ( result == 0 ) { result = dominanceTest ( solution1 , solution2 ) ; } return result ; }
Compares two solutions.

@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 solution1 dominates solution2, both are
non-dominated, or solution1  is dominated by solution2, respectively.