public static <S> List<S> selectNRandomDifferentSolutions(
      int numberOfSolutionsToBeReturned, List<S> solutionList, BoundedRandomGenerator<Integer> randomGenerator) {
    if (null == solutionList) {
      throw new NullSolutionListException();
    } else if (solutionList.size() == 0) {
      throw new EmptySolutionListException();
    } else if (solutionList.size() < numberOfSolutionsToBeReturned) {
      throw new JMetalException("The solution list size (" + solutionList.size() + ") is less than "
          + "the number of requested solutions (" + numberOfSolutionsToBeReturned + ")");
    }

    List<S> resultList = new ArrayList<>(numberOfSolutionsToBeReturned);

    if (solutionList.size() == 1) {
      resultList.add(solutionList.get(0));
    } else {
      Collection<Integer> positions = new HashSet<>(numberOfSolutionsToBeReturned);
      while (positions.size() < numberOfSolutionsToBeReturned) {
        int nextPosition = randomGenerator.getRandomValue(0, solutionList.size() - 1);
        if (!positions.contains(nextPosition)) {
          positions.add(nextPosition);
          resultList.add(solutionList.get(nextPosition));
        }
      }
    }

    return resultList;
  }
public static < S > List < S > selectNRandomDifferentSolutions ( int numberOfSolutionsToBeReturned , List < S > solutionList , BoundedRandomGenerator < Integer > randomGenerator ) { if ( null == solutionList ) { throw new NullSolutionListException ( ) ; } else if ( solutionList . size ( ) == 0 ) { throw new EmptySolutionListException ( ) ; } else if ( solutionList . size ( ) < numberOfSolutionsToBeReturned ) { throw new JMetalException ( "The solution list size (" + solutionList . size ( ) + ") is less than " + "the number of requested solutions (" + numberOfSolutionsToBeReturned + ")" ) ; } List < S > resultList = new ArrayList < > ( numberOfSolutionsToBeReturned ) ; if ( solutionList . size ( ) == 1 ) { resultList . add ( solutionList . get ( 0 ) ) ; } else { Collection < Integer > positions = new HashSet < > ( numberOfSolutionsToBeReturned ) ; while ( positions . size ( ) < numberOfSolutionsToBeReturned ) { int nextPosition = randomGenerator . getRandomValue ( 0 , solutionList . size ( ) - 1 ) ; if ( ! positions . contains ( nextPosition ) ) { positions . add ( nextPosition ) ; resultList . add ( solutionList . get ( nextPosition ) ) ; } } } return resultList ; }
This method receives a normalized list of non-dominated solutions and return the inverted one.
This operation is needed for minimization problem

@param solutionList    The front to invert
@param randomGenerator The random generator to use
@return The inverted front