@ Override public int compare ( S solution1 , S solution2 ) { int result ; if ( solution1 == null ) { if ( solution2 == null ) { result = 0 ; } else { result = 1 ; } } else if ( solution2 == null ) { result = - 1 ; } else { int rank1 = Integer . MAX_VALUE ; int rank2 = Integer . MAX_VALUE ; if ( ranking . getAttribute ( solution1 ) != null ) { rank1 = ( int ) ranking . getAttribute ( solution1 ) ; } if ( ranking . getAttribute ( solution2 ) != null ) { rank2 = ( int ) ranking . getAttribute ( solution2 ) ; } if ( rank1 < rank2 ) { result = - 1 ; } else if ( rank1 > rank2 ) { result = 1 ; } else { result = 0 ; } } return result ; }
Compares two solutions according to the ranking attribute . The lower the ranking the better