code
stringlengths
73
34.1k
label
stringclasses
1 value
public double norm_vector(double[] z) { double sum = 0; for (int i = 0; i < problem.getNumberOfObjectives(); i++) { sum += z[i] * z[i]; } return Math.sqrt(sum); }
java
private double epsilon(Front front, Front referenceFront) throws JMetalException { double eps, epsJ = 0.0, epsK = 0.0, epsTemp; int numberOfObjectives = front.getPointDimensions() ; eps = Double.MIN_VALUE; for (int i = 0; i < referenceFront.getNumberOfPoints(); i++) { for (int j = 0; j < front...
java
protected double evalH(double f, double g) { double h ; h = 1.0 - Math.sqrt(f / g) - (f / g) * Math.sin(10.0 * Math.PI * f); return h; }
java
public boolean prefers(int x, int y, int[] womanPref, int size) { for (int i = 0; i < size; i++) { int pref = womanPref[i]; if (pref == x) { return true; } if (pref == y) { return false; } } // this should never happen. System.out.println("Error in womanPre...
java
@Override public void referenceSetUpdate(DoubleSolution solution) { if (refSet1Test(solution)) { for (DoubleSolution solutionInRefSet2 : referenceSet2) { double aux = SolutionUtils.distanceBetweenSolutionsInObjectiveSpace(solution, solutionInRefSet2); DoubleSolution auxSolution = solutionInRef...
java
public void buildNewReferenceSet1() { DoubleSolution individual; strengthRawFitness.computeDensityEstimator(getPopulation()); Collections.sort(getPopulation(), fitnessComparator); for (int i = 0; i < referenceSet1Size; i++) { individual = getPopulation().get(0); getPopulation().remove(0); ...
java
public void buildNewReferenceSet2() { for (int i = 0; i < getPopulation().size(); i++) { DoubleSolution individual = getPopulation().get(i); double distanceAux = SolutionUtils .distanceToSolutionListInSolutionSpace(individual, referenceSet1); distanceToSolutionListAttribute.setAttribute(...
java
@Override public List<List<DoubleSolution>> subsetGeneration() { List<List<DoubleSolution>> solutionGroupsList ; solutionGroupsList = generatePairsFromSolutionList(referenceSet1) ; solutionGroupsList.addAll(generatePairsFromSolutionList(referenceSet2)); return solutionGroupsList ; }
java
public List<List<DoubleSolution>> generatePairsFromSolutionList(List<DoubleSolution> solutionList) { List<List<DoubleSolution>> subset = new ArrayList<>() ; for (int i = 0; i < solutionList.size(); i++) { DoubleSolution solution1 = solutionList.get(i); for (int j = i + 1; j < solutionList.size(); j+...
java
private void resetIndicatorFiles() { for (GenericIndicator<S> indicator : experiment.getIndicatorList()) { for (ExperimentAlgorithm<?, Result> algorithm : experiment.getAlgorithmList()) { for (ExperimentProblem<?> problem: experiment.getProblemList()) { String algorithmDirectory; a...
java
private void resetFile(String file) { File f = new File(file); if (f.exists()) { JMetalLogger.logger.info("Already existing file " + file); if (f.isDirectory()) { JMetalLogger.logger.info("Deleting directory " + file); if (f.delete()) { JMetalLogger.logger.info("Directory ...
java
public double[][] lines_of_polygon(double[][] p) { double[][] c9 = new double[p.length][3]; for (int i = 0; i < p.length - 1; i++) {// evaluate formula of the straight line l1,...,m-1 c9[i] = line_of_twoP(p[i], p[i + 1]); } // evaluate formula of the straight line lm c9[p.length - 1] = ...
java
public static double generV(double lb, double ub) { double p; p = JMetalRandom.getInstance().nextDouble() * (ub - lb) + lb; return p; }
java
public void doMutation(double probability, DoubleSolution solution) { for (int i = 0; i < solution.getNumberOfVariables(); i++) { if (randomGenenerator.getRandomValue() < probability) { double rand = randomGenenerator.getRandomValue(); double tmp = (rand - 0.5) * perturbation; tmp +=...
java
private double evalG(DoubleSolution solution) { double g = 0.0; for (int i = 2; i < solution.getNumberOfVariables(); i++) { double t = solution.getVariableValue(i) - solution.getVariableValue(0) * solution.getVariableValue(1); g += -0.9 * t * t + Math.pow(Math.abs(t), 0.6); } g = 2 * Math.si...
java
public void add(List<Double> maxs) { List<Double> aux = new ArrayList<>(this.numberOfObjectives); aux.addAll(maxs); this.history.add(aux); if (history.size() > MAX_LENGHT) history.remove(0); }
java
public List<Double> mean() { List<Double> result = new ArrayList<>(this.numberOfObjectives); for (int i = 0; i < this.numberOfObjectives; i++) result.add(0.0); for (List<Double> historyMember : this.history) for (int i = 0; i < this.numberOfObjectives;i++) result.set(i, result.get(i) + ...
java
private static <S extends Solution<?>> void setScalarizationValue(S solution, double scalarizationValue) { solution.setAttribute(new ScalarizationValue<S>().getAttributeIdentifier(), scalarizationValue); }
java
private static double[] toArray(List<Double> list) { double[] values = new double[list.size()]; for (int i = 0; i < values.length; i++) { values[i] = list.get(i); } return values; }
java
private static <S extends Solution<?>> double[] getIdealValues(List<S> solutionsList) { ArrayFront front = new ArrayFront(solutionsList); FrontExtremeValues extremeValues = new FrontExtremeValues(); List<Double> list = extremeValues.findLowestValues(front); return toArray(list); }
java
private static <S extends Solution<?>> double[] getNadirValues(List<S> solutionsList) { ArrayFront front = new ArrayFront(solutionsList); FrontExtremeValues extremeValues = new FrontExtremeValues(); List<Double> list = extremeValues.findHighestValues(front); return toArray(list); }
java
private static <S extends Solution<?>> double[][] getExtremePoints(List<S> solutionsList) { // One extreme point for each objective double[][] extremePoints = new double[solutionsList.get(0).getNumberOfObjectives()][]; for (int i = 0; i < extremePoints.length; i++) { S extreme = Collections.min(...
java
public static <S extends Solution<?>> void sumOfObjectives(List<S> solutionsList) { for (S solution : solutionsList) { double sum = solution.getObjective(0); for (int i = 1; i < solution.getNumberOfObjectives(); i++) { sum += solution.getObjective(i); } setScalarizationValue(so...
java
public static <S extends Solution<?>> void weightedSum(List<S> solutionsList, double[] weights) { for (S solution : solutionsList) { double sum = weights[0] * solution.getObjective(0); for (int i = 1; i < solution.getNumberOfObjectives(); i++) { sum += weights[i] * solution.getObjective(i); ...
java
public static <S extends Solution<?>> void productOfObjectives(List<S> solutionsList) { for (S solution : solutionsList) { double product = solution.getObjective(0); for (int i = 1; i < solution.getNumberOfObjectives(); i++) { product *= solution.getObjective(i); } setScalariza...
java
public static <S extends Solution<?>> void weightedProduct(List<S> solutionsList, double[] weights) { for (S solution : solutionsList) { double product = Math.pow(solution.getObjective(0), weights[0]); for (int i = 1; i < solution.getNumberOfObjectives(); i++) { product *= Math.pow(solution....
java
public static <S extends Solution<?>> void chebyshev(List<S> solutionsList) { chebyshev(solutionsList, getIdealValues(solutionsList)); }
java
public static <S extends Solution<?>> void weightedChebyshev(List<S> solutionsList, double[] weights) { weightedChebyshev(solutionsList, getIdealValues(solutionsList), weights); }
java
public static <S extends Solution<?>> void chebyshev(List<S> solutionsList, double[] idealValues) { for (S solution : solutionsList) { double max = solution.getObjective(0) - idealValues[0]; for (int i = 1; i < solution.getNumberOfObjectives(); i++) { max = Math.max(max, solution.getObjectiv...
java
public static <S extends Solution<?>> void nash(List<S> solutionsList) { nash(solutionsList, getNadirValues(solutionsList)); }
java
public static <S extends Solution<?>> void nash(List<S> solutionsList, double[] nadirValues) { for (S solution : solutionsList) { double nash = nadirValues[0] - solution.getObjective(0); for (int i = 1; i < nadirValues.length; i++) { nash *= (nadirValues[i] - solution.getObjective(i)); ...
java
public static <S extends Solution<?>> void uniform(List<S> solutionsList) { for (S solution : solutionsList) { setScalarizationValue(solution, 1.0); } }
java
public float[] t2(float[] z, int k) { float[] result = new float[z.length]; System.arraycopy(z, 0, result, 0, k); for (int i = k; i < z.length; i++) { result[i] = (new Transformations()).bFlat(z[i], (float) 0.8, (float) 0.75, (float) 0.85); } return result; }
java
public float[] t3(float[] z) throws JMetalException { float[] result = new float[z.length]; for (int i = 0; i < z.length; i++) { result[i] = (new Transformations()).bPoly(z[i], (float) 0.02); } return result; }
java
public float[] t4(float[] z, int k, int M) { float[] result = new float[M]; float[] w = new float[z.length]; for (int i = 0; i < z.length; i++) { w[i] = (float) 2.0 * (i + 1); } for (int i = 1; i <= M - 1; i++) { int head = (i - 1) * k / (M - 1) + 1; int tail = i * k / ...
java
public static boolean validate (double[][] weights, int numberOfComponents) { int i; boolean correct; correct = (weights != null && weights.length > 0); i = 0; while (correct && i < weights.length) { correct = (weights[i].length == numberOfComponents); i++; } return correct; }
java
public static double[][] initializeUniformlyInTwoDimensions(double epsilon, int numberOfWeights) { double[][] weights = new double[numberOfWeights][2]; int indexOfWeight; double w, jump; jump = (1 - (2 * epsilon)) / (numberOfWeights - 1); indexOfWeight = 0; w = epsilon; //while(w <= (1-epsilon...
java
public static double[][] readFromResourcesInJMetal(String filePath) { double[][] weights; Vector<double[]> listOfWeights = new Vector<>(); try { InputStream in = WeightVectors.class.getResourceAsStream("/" + filePath); InputStreamReader isr = new InputStreamReader(in); BufferedReader br = new BufferedR...
java
public static double[][] readFromFile(String filePath) { double[][] weights; Vector<double[]> listOfWeights = new Vector<>(); try { // Open the file FileInputStream fis = new FileInputStream(filePath); InputStreamReader isr = new InputStreamReader(fis); BufferedReader br = new BufferedReader(isr...
java
public static double[][] invert(double[][] weights, boolean normalize) { double[][] result = new double[weights.length][weights[0].length]; for (int indexOfWeight = 0; indexOfWeight < weights.length; indexOfWeight++) { if (normalize) { double sum = 0; for (int indexOfComponent = 0; indexOfCompone...
java
protected double evalG(DoubleSolution solution) { double g = 0.0; for (int i = 1; i < solution.getNumberOfVariables(); i++) { g += solution.getVariableValue(i); } double constant = 9.0 / (solution.getNumberOfVariables() - 1); return constant * g + 1.0; }
java
protected double evalH(double f, double g) { double h ; h = 1.0 - Math.sqrt(f / g); return h; }
java
public double generationalDistance(Front front, Front referenceFront) { double sum = 0.0; for (int i = 0; i < front.getNumberOfPoints(); i++) { sum += Math.pow(FrontUtils.distanceToClosestPoint(front.getPoint(i), referenceFront), pow); } sum = Math.pow(sum, 1.0 / pow); return sum /...
java
public float linear(float[] x, int m) { float result = (float) 1.0; int M = x.length; for (int i = 1; i <= M - m; i++) { result *= x[i - 1]; } if (m != 1) { result *= (1 - x[M - m]); } return result; }
java
public float convex(float[] x, int m) { float result = (float) 1.0; int M = x.length; for (int i = 1; i <= M - m; i++) { result *= (1 - Math.cos(x[i - 1] * Math.PI * 0.5)); } if (m != 1) { result *= (1 - Math.sin(x[M - m] * Math.PI * 0.5)); } return result; }
java
public float mixed(float[] x, int A, float alpha) { float tmp; tmp = (float) Math.cos((float) 2.0 * A * (float) Math.PI * x[0] + (float) Math.PI * (float) 0.5); tmp /= (2.0 * (float) A * Math.PI); return (float) Math.pow(((float) 1.0 - x[0] - tmp), alpha); }
java
public float disc(float[] x, int A, float alpha, float beta) { float tmp; tmp = (float) Math.cos((float) A * Math.pow(x[0], beta) * Math.PI); return (float) 1.0 - (float) Math.pow(x[0], alpha) * (float) Math.pow(tmp, 2.0); }
java
static public double sphere_noise(double[] x) { double sum = 0.0; for (int i = 0; i < x.length; i++) { sum += x[i] * x[i]; } // NOISE // Comment the next line to remove the noise sum *= (1.0 + 0.1 * Math.abs(random.nextGaussian())); return (sum); }
java
static public double schwefel_102(double[] x) { double prev_sum, curr_sum, outer_sum; curr_sum = x[0]; outer_sum = (curr_sum * curr_sum); for (int i = 1; i < x.length; i++) { prev_sum = curr_sum; curr_sum = prev_sum + x[i]; outer_sum += (curr_sum * curr_sum); } return (oute...
java
static public double rosenbrock(double[] x) { double sum = 0.0; for (int i = 0; i < (x.length - 1); i++) { double temp1 = (x[i] * x[i]) - x[i + 1]; double temp2 = x[i] - 1.0; sum += (100.0 * temp1 * temp1) + (temp2 * temp2); } return (sum); }
java
static public double griewank(double[] x) { double sum = 0.0; double product = 1.0; for (int i = 0; i < x.length; i++) { sum += ((x[i] * x[i]) / 4000.0); product *= Math.cos(x[i] / m_iSqrt[i]); } return (sum - product + 1.0); }
java
static public double ackley(double[] x) { double sum1 = 0.0; double sum2 = 0.0; for (int i = 0; i < x.length; i++) { sum1 += (x[i] * x[i]); sum2 += (Math.cos(PIx2 * x[i])); } return (-20.0 * Math.exp(-0.2 * Math.sqrt(sum1 / ((double) x.length))) - Math .exp(sum2 / ((double) x.le...
java
static public double myRound(double x) { return (Math.signum(x) * Math.round(Math.abs(x))); }
java
static public double myXRound(double x, double o) { return ((Math.abs(x - o) < 0.5) ? x : (myRound(2.0 * x) / 2.0)); }
java
static public double rastrigin(double[] x) { double sum = 0.0; for (int i = 0; i < x.length; i++) { sum += (x[i] * x[i]) - (10.0 * Math.cos(PIx2 * x[i])) + 10.0; } return (sum); }
java
static public double rastriginNonCont(double[] x) { double sum = 0.0; double currX; for (int i = 0; i < x.length; i++) { currX = myXRound(x[i]); sum += (currX * currX) - (10.0 * Math.cos(PIx2 * currX)) + 10.0; } return (sum); }
java
static public double ScafferF6(double x, double y) { double temp1 = x * x + y * y; double temp2 = Math.sin(Math.sqrt(temp1)); double temp3 = 1.0 + 0.001 * temp1; return (0.5 + ((temp2 * temp2 - 0.5) / (temp3 * temp3))); }
java
static public double EScafferF6(double[] x) { double sum = 0.0; for (int i = 1; i < x.length; i++) { sum += ScafferF6(x[i - 1], x[i]); } sum += ScafferF6(x[x.length - 1], x[0]); return (sum); }
java
static public double EScafferF6NonCont(double[] x) { double sum = 0.0; double prevX, currX; currX = myXRound(x[0]); for (int i = 1; i < x.length; i++) { prevX = currX; currX = myXRound(x[i]); sum += ScafferF6(prevX, currX); } prevX = currX; currX = myXRound(x[0]); sum...
java
private int hammingDistance(BinarySolution solutionOne, BinarySolution solutionTwo) { int distance = 0; for (int i = 0; i < problem.getNumberOfVariables(); i++) { distance += hammingDistance(solutionOne.getVariableValue(i), solutionTwo.getVariableValue(i)); } return distance; }
java
private double er(Front front, Front referenceFront) throws JMetalException { int numberOfObjectives = referenceFront.getPointDimensions() ; double sum = 0; for (int i = 0; i < front.getNumberOfPoints(); i++) { Point currentPoint = front.getPoint(i); boolean thePointIsInTheParetoFront = f...
java
@Override public int compare(Point pointOne, Point pointTwo) { if (pointOne == null) { throw new JMetalException("PointOne is null") ; } else if (pointTwo == null) { throw new JMetalException("PointTwo is null"); } // Determine the first i such as pointOne[i] != pointTwo[i]; int inde...
java
public double randNormal(double mean, double standardDeviation) { double x1, x2, w, y1; do { x1 = 2.0 * randomGenerator.nextDouble() - 1.0; x2 = 2.0 * randomGenerator.nextDouble() - 1.0; w = x1 * x1 + x2 * x2; } while (w >= 1.0); w = Math.sqrt((-2.0 * Math.log(w)) / w); y1 = x1 *...
java
public double[] randSphere(int dimension, double center, double radius) { int d = dimension; double[] x = new double[dimension]; double length = 0; for (int i = 0; i < dimension; i++) { x[i] = 0.0; } // --------- Step 1. Direction for (int i = 0; i < d; i++) { x[i] = randNorma...
java
public float[] t1(float[] z, int k) { float[] result = new float[z.length]; float[] w = new float[z.length]; for (int i = 0; i < w.length; i++) { w[i] = (float) 1.0; } for (int i = 0; i < z.length - 1; i++) { int head = i + 1; int tail = z.length - 1; float[] sub...
java
public float[] t2(float[] z, int k) { float[] result = new float[z.length]; for (int i = 0; i < k; i++) { result[i] = (new Transformations()).sDecept(z[i], (float) 0.35, (float) 0.001, (float) 0.05); } for (int i = k; i < z.length; i++) { result[i] = (new Transformations()).sMulti(...
java
public float[] t3(float[] z, int k, int M) { float[] result = new float[M]; for (int i = 1; i <= M - 1; i++) { int head = (i - 1) * k / (M - 1) + 1; int tail = i * k / (M - 1); float[] subZ = subVector(z, head - 1, tail - 1); result[i - 1] = (new Transformations()).rNonsep(subZ, ...
java
public double repairSolutionVariableValue(double value, double lowerBound, double upperBound) { if (lowerBound > upperBound) { throw new JMetalException("The lower bound (" + lowerBound + ") is greater than the " + "upper bound (" + upperBound+")") ; } double result = value ; if (value ...
java
public double evalG(DoubleSolution solution) { double g = 0.0; for (int var = 1; var < solution.getNumberOfVariables(); var++) { g += Math.pow(solution.getVariableValue(var), 2.0) + -10.0 * Math.cos(4.0 * Math.PI * solution.getVariableValue(var)); } double constant = 1.0 + 10.0 * (...
java
private void createNeighborhoods() { neighbours = new ArrayList<List<Integer>>(solutionListSize); for (int i = 0; i < solutionListSize; i++) { neighbours.add(new ArrayList<Integer>()); neighbours.get(i).add(i); } }
java
private void addRandomNeighbors() { for (int i = 0; i < solutionListSize; i++) { while(neighbours.get(i).size() <= numberOfRandomNeighbours) { int random = randomGenerator.getRandomValue(0, solutionListSize - 1); neighbours.get(i).add(random) ; } } }
java
protected double evalG(DoubleSolution solution) { double g = 0.0; for (int var = 1; var < solution.getNumberOfVariables(); var++) { g += solution.getVariableValue(var); } g = g / (solution.getNumberOfVariables() - 1); g = Math.pow(g, 0.25); g = 9.0 * g; g = 1.0 + g; return g; }
java
public List<BinarySolution> doCrossover(double probability, BinarySolution parent1, BinarySolution parent2) { List<BinarySolution> offspring = new ArrayList<>(2); offspring.add((BinarySolution) parent1.copy()) ; offspring.add((BinarySolution) parent2.copy()) ; if (crossoverRandomGenerator.getRand...
java
private int getNeighbor(int solution, int [] neighbor) { int row = getRow(solution) ; int col = getColumn((solution)) ; int r ; int c ; r = (row + neighbor[0]) % this.rows ; if (r < 0) r = rows - 1; c = (col + neighbor[1]) % this.columns ; if (c < 0) c = columns - 1 ; ...
java
private List<S> findNeighbors(List<S> solutionSet, int solution, int [][] neighborhood) { List<S> neighbors = new ArrayList<>(neighborhood.length+1); for (int [] neighbor : neighborhood) { int index = getNeighbor(solution, neighbor) ; neighbors.add(solutionSet.get(index)); } return neighbo...
java
double betaFunction(List<Double> x, int type) { double beta; beta = 0; int dim = x.size(); if (dim == 0) { beta = 0; } if (type == 1) { beta = 0; for (int i = 0; i < dim; i++) { beta += x.get(i) * x.get(i); } beta = 2.0 * beta / dim; } if (type ==...
java
double psfunc3(double x, double t1, double t2, int dim, int type) { // type: the type of curve // css: the class of index double beta; beta = 0.0; dim++; if (type == 31) { double xy = 4 * (x - 0.5); double rate = 1.0 * dim / nvar; beta = xy - 4 * (t1 * t1 * rate + t2 * (1...
java
@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 if (solution1.getNumberOfObjectives() <= o...
java
@Override public boolean add(S solution) { boolean solutionInserted = false ; if (solutionList.size() == 0) { solutionList.add(solution) ; solutionInserted = true ; } else { Iterator<S> iterator = solutionList.iterator(); boolean isDominated = false; boolean isContaine...
java
private static boolean checkAboutNormalization(String args[]) { boolean normalize = false ; if (args.length == 4) { if (args[3].equals("TRUE")) { normalize = true; } else if (args[3].equals("FALSE")) { normalize = false; } else { throw new JMetalException("The value for...
java
private static QualityIndicator<List<PointSolution>, Double> getIndicatorFromName( String name, List<QualityIndicator<List<PointSolution>, Double>> list) { QualityIndicator<List<PointSolution>, Double> result = null ; for (QualityIndicator<List<PointSolution>, Double> indicator : list) { if (indica...
java
@Override public double getDistance(S solution, L solutionList) { List<Double> listOfDistances = knnDistances(solution, solutionList) ; listOfDistances.sort(Comparator.naturalOrder()); int limit = Math.min(k, listOfDistances.size()) ; double result ; if (limit == 0) { result = 0.0 ; } ...
java
private List<Double> knnDistances(S solution, L solutionList) { List<Double> listOfDistances = new ArrayList<>() ; for (int i = 0 ; i< solutionList.size(); i++) { double distanceBetweenSolutions = distance.getDistance(solution, solutionList.get(i)) ; if (distanceBetweenSolutions != 0) { list...
java
@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; ...
java
public float[] calculateX(float[] t) { float[] x = new float[m]; for (int i = 0; i < m - 1; i++) { x[i] = Math.max(t[m - 1], a[i]) * (t[i] - (float) 0.5) + (float) 0.5; } x[m - 1] = t[m - 1]; return x; }
java
public static <S> int findIndexOfBestSolution(List<S> solutionList, Comparator<S> comparator) { if (solutionList == null) { throw new NullSolutionListException(); } else if (solutionList.isEmpty()) { throw new EmptySolutionListException(); } else if (comparator == null) { throw new JMetalE...
java
public static List<? extends Solution<?>> normalize(List<? extends Solution<?>> solutions, double[] minValues, double[] maxValues) { List<Solution<?>> normalizedSolutions = new ArrayList<>(solutions.size()); for (Solution<?> solution : solutions) { normalizedSolutions.add(SolutionUtils.normalize(solution...
java
public static <S extends Solution<?>> double[][] distanceMatrix(List<S> solutionSet) { double[][] distance = new double[solutionSet.size()][solutionSet.size()]; for (int i = 0; i < solutionSet.size(); i++) { distance[i][i] = 0.0; for (int j = i + 1; j < solutionSet.size(); j++) { distance[i]...
java
public static <S> boolean solutionListsAreEquals(List<S> solutionList, List<S> newSolutionList) { boolean found; for (int i = 0; i < solutionList.size(); i++) { int j = 0; found = false; while (j < newSolutionList.size()) { if (soluti...
java
public static <S> void restart(List<S> solutionList, Problem<S> problem, int percentageOfSolutionsToRemove) { if (solutionList == null) { throw new NullSolutionListException(); } else if (problem == null) { throw new JMetalException("The problem is null"); } else...
java
public static <S> void removeSolutionsFromList(List<S> solutionList, int numberOfSolutionsToRemove) { if (solutionList.size() < numberOfSolutionsToRemove) { throw new JMetalException("The list size (" + solutionList.size() + ") is lower than " + "the number of solutions to remove (" + numberOfSoluti...
java
public static <S> void fillPopulationWithNewSolutions( List<S> solutionList, Problem<S> problem, int maxListSize) { while (solutionList.size() < maxListSize) { solutionList.add(problem.createSolution()); } }
java
public double repairSolutionVariableValue(double value, double lowerBound, double upperBound) { if (lowerBound > upperBound) { throw new JMetalException("The lower bound (" + lowerBound + ") is greater than the " + "upper bound (" + upperBound+")") ; } double result = value ; if (value <...
java
public static <S extends Solution<?>> S getBestSolution(S solution1, S solution2, Comparator<S> comparator, BinaryOperator<S> equalityPolicy) { S result; int flag = comparator.compare(solution1, solution2); if (flag == -1) { result = solution1; } else if (flag == 1) { result = solution2; ...
java
public static <S extends Solution<?>> double distanceBetweenObjectives(S firstSolution, S secondSolution) { double diff; double distance = 0.0; //euclidean distance for (int nObj = 0; nObj < firstSolution.getNumberOfObjectives(); nObj++) { diff = firstSolution.getObjective(nObj) - secondSolution...
java
public static double distanceBetweenSolutionsInObjectiveSpace(DoubleSolution solutionI, DoubleSolution solutionJ) { double distance = 0.0; double diff; for (int i = 0; i < solutionI.getNumberOfVariables(); i++) { diff = solutionI.getVariableValue(i) - solutionJ.getVariableValue(i); distance += ...
java
public static <S extends Solution<?>> double averageDistanceToSolutionList( S solution, List<S> solutionList) { double sumOfDistances = 0.0; for (S sol : solutionList) { sumOfDistances += distanceBetweenObjectives( solution, sol); } return sumOfDis...
java
public static Solution<?> normalize(Solution<?> solution, double[] minValues, double[] maxValues) { if (solution == null) { throw new JMetalException("The solution should not be null"); } if (minValues == null || maxValues == null) { throw new JMetalException("The minValues and maxValues should not be n...
java
public static void tred2(int n, double v[][], double d[], double e[]) { // This is derived from the Algol procedures tred2 by // Bowdler, Martin, Reinsch, and Wilkinson, Handbook for // Auto. Comp., Vol.ii-Linear Algebra, and the corresponding // Fortran subroutine in EISPACK. System.arraycopy...
java
public static void tql2(int n, double d[], double e[], double v[][]) { // This is derived from the Algol procedures tql2, by // Bowdler, Martin, Reinsch, and Wilkinson, Handbook for // Auto. Comp., Vol.ii-Linear Algebra, and the corresponding // Fortran subroutine in EISPACK. System.arraycopy(...
java