/** Updates the reference point */ private void updateReferencePoint(SolutionSet solutionSet) { double[] maxObjectives = new double[numberOfObjectives]; for (int i = 0; i < numberOfObjectives; i++) { maxObjectives[i] = 0; } for (int i = 0; i < solutionSet.size(); i++) { for (int j = 0; j < numberOfObjectives; j++) { if (maxObjectives[j] < solutionSet.get(i).getObjective(j)) { maxObjectives[j] = solutionSet.get(i).getObjective(j); } } } for (int i = 0; i < referencePoint.getNumberOfObjectives(); i++) { referencePoint.setObjective(i, maxObjectives[i] + offset); } }
/** * Computes the HV of a solutiontype set. REQUIRES: The problem is bi-objective REQUIRES: The * setArchive is ordered in descending order by the second objective * * @return */ public double get2DHV(SolutionSet solutionSet) { double hv = 0.0; if (solutionSet.size() > 0) { hv = Math.abs( (solutionSet.get(0).getObjective(0) - referencePoint.getObjective(0)) * (solutionSet.get(0).getObjective(1) - referencePoint.getObjective(1))); for (int i = 1; i < solutionSet.size(); i++) { double tmp = Math.abs( (solutionSet.get(i).getObjective(0) - referencePoint.getObjective(0)) * (solutionSet.get(i).getObjective(1) - solutionSet.get(i - 1).getObjective(1))); hv += tmp; } } return hv; }
/** * Evaluates a solution * * @param solution The solution to evaluate * @throws org.uma.jmetal.util.JMetalException */ public final void evaluate(Solution solution) throws JMetalException { float[] variables = new float[getNumberOfVariables()]; XReal sol = new XReal(solution); double[] x = new double[numberOfVariables]; for (int i = 0; i < numberOfVariables; i++) { x[i] = sol.getValue(i); } for (int i = 0; i < getNumberOfVariables(); i++) { variables[i] = (float) x[i]; } float[] f = evaluate(variables); for (int i = 0; i < f.length; i++) { solution.setObjective(i, f[i]); } }