/** * Evaluates a solution * * @param solution The solution to evaluate * @throws JMException */ public void evaluate(Solution solution) throws JMException { DecisionVariables gen = solution.getDecisionVariables(); double[] x = new double[numberOfVariables_]; double[] f = new double[numberOfObjectives_]; double[] theta = new double[numberOfObjectives_ - 1]; int k = numberOfVariables_ - numberOfObjectives_ + 1; for (int i = 0; i < numberOfVariables_; i++) x[i] = gen.variables_[i].getValue(); double g = 0.0; for (int i = numberOfVariables_ - k; i < numberOfVariables_; i++) g += java.lang.Math.pow(x[i], 0.1); double t = java.lang.Math.PI / (4.0 * (1.0 + g)); theta[0] = x[0] * java.lang.Math.PI / 2; for (int i = 1; i < (numberOfObjectives_ - 1); i++) theta[i] = t * (1.0 + 2.0 * g * x[i]); for (int i = 0; i < numberOfObjectives_; i++) f[i] = 1.0 + g; for (int i = 0; i < numberOfObjectives_; i++) { for (int j = 0; j < numberOfObjectives_ - (i + 1); j++) f[i] *= java.lang.Math.cos(theta[j]); if (i != 0) { int aux = numberOfObjectives_ - (i + 1); f[i] *= java.lang.Math.sin(theta[aux]); } // if } // for for (int i = 0; i < numberOfObjectives_; i++) solution.setObjective(i, f[i]); } // evaluate
/** * Evaluates a solution * * @param solution The solution to evaluate * @throws JMException */ public void evaluate(Solution solution) throws JMException { DecisionVariables decisionVariables = solution.getDecisionVariables(); double[] x = new double[numberOfVariables_]; double[] fx = new double[numberOfVariables_]; double g; double h; double sum; for (int i = 0; i < numberOfVariables_; i++) x[i] = decisionVariables.variables_[i].getValue(); fx[0] = x[0]; sum = 0.0; for (int i = 1; i < numberOfVariables_; i++) sum += (x[i] * x[i] - x[0]) * (x[i] * x[i] - x[0]); g = 1.0 + 9.0 * sum / (numberOfVariables_ - 1.0); h = 1.0 - Math.sqrt(x[0] / g); fx[1] = g * h; solution.setObjective(0, fx[0]); solution.setObjective(1, fx[1]); } // evaluate