/** * 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 * @return The inverted front */ public static <S extends Solution<?>> List<S> selectNRandomDifferentSolutions( int numberOfSolutionsToBeReturned, List<S> solutionList) { if (null == solutionList) { throw new JMetalException("The solution list is null"); } else if (solutionList.size() == 0) { throw new JMetalException("The solution list is empty"); } else if (solutionList.size() < numberOfSolutionsToBeReturned) { throw new JMetalException( "The solution list size (" + solutionList.size() + ") is less than " + "the number of requested solutions (" + numberOfSolutionsToBeReturned + ")"); } JMetalRandom randomGenerator = JMetalRandom.getInstance(); 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.nextInt(0, solutionList.size() - 1); if (!positions.contains(nextPosition)) { positions.add(nextPosition); resultList.add(solutionList.get(nextPosition)); } } } return resultList; }
@Before public void setup() { random = JMetalRandom.getInstance(); random.setSeed(2); operator = new ExhaustiveSearchMutationOperator(1.0, random, aminoAcidSequence, 40); proteinBuilder = new ProteinBuilder(); }
int FindNicheReferencePoint() { // find the minimal cluster size int min_size = Integer.MAX_VALUE; for (ReferencePoint<S> referencePoint : this.referencePoints) min_size = Math.min(min_size, referencePoint.MemberSize()); // find the reference points with the minimal cluster size Jmin List<Integer> min_rps = new ArrayList<>(); for (int r = 0; r < this.referencePoints.size(); r += 1) { if (this.referencePoints.get(r).MemberSize() == min_size) { min_rps.add(r); } } // return a random reference point (j-bar) return min_rps.get( min_rps.size() > 1 ? JMetalRandom.getInstance().nextInt(0, min_rps.size() - 1) : 0); }
/** Constructor */ public RepairDoubleSolutionAtRandom() { randomGenerator = JMetalRandom.getInstance(); }