@Override public void evaluate(DoubleSolution solution) { solution.setObjective(0, (1.0 + g(solution)) * solution.getVariableValue(0)); if (solution.getObjective(0) < 0.05) { solution.setObjective(1, (1.0 + g(solution)) * (1.0 - 19.0 * solution.getVariableValue(0))); } else { solution.setObjective( 1, (1.0 + g(solution)) * (1.0 / 19.0 - solution.getVariableValue(0) / 19.0)); } }
/** Evaluate() method */ @Override public void evaluate(DoubleSolution solution) { double[] fx = new double[getNumberOfObjectives()]; double x1, x2, x3, x4, x5, x6; x1 = solution.getVariableValue(0); x2 = solution.getVariableValue(1); x3 = solution.getVariableValue(2); x4 = solution.getVariableValue(3); x5 = solution.getVariableValue(4); x6 = solution.getVariableValue(5); fx[0] = -(25.0 * (x1 - 2.0) * (x1 - 2.0) + (x2 - 2.0) * (x2 - 2.0) + (x3 - 1.0) * (x3 - 1.0) + (x4 - 4.0) * (x4 - 4.0) + (x5 - 1.0) * (x5 - 1.0)); fx[1] = x1 * x1 + x2 * x2 + x3 * x3 + x4 * x4 + x5 * x5 + x6 * x6; solution.setObjective(0, fx[0]); solution.setObjective(1, fx[1]); }