double fitnessFunction(Solution individual, double[] lambda) { double fitness; fitness = 0.0; if (functionType_.equals("_TCHE1")) { double maxFun = -1.0e+30; for (int n = 0; n < problem_.getNumberOfObjectives(); n++) { double diff = Math.abs(individual.getObjective(n) - z_[n]); double feval; if (lambda[n] == 0) { feval = 0.0001 * diff; } else { feval = diff * lambda[n]; } if (feval > maxFun) { maxFun = feval; } } // for fitness = maxFun; } // if else if (functionType_.equals("_AGG")) { double sum = 0.0; for (int n = 0; n < problem_.getNumberOfObjectives(); n++) { sum += (lambda[n]) * individual.getObjective(n); } fitness = sum; } else if (functionType_.equals("_PBI")) { double d1, d2, nl; double theta = 5.0; d1 = d2 = nl = 0.0; for (int i = 0; i < problem_.getNumberOfObjectives(); i++) { d1 += (individual.getObjective(i) - z_[i]) * lambda[i]; nl += Math.pow(lambda[i], 2.0); } nl = Math.sqrt(nl); d1 = Math.abs(d1) / nl; for (int i = 0; i < problem_.getNumberOfObjectives(); i++) { d2 += Math.pow((individual.getObjective(i) - z_[i]) - d1 * (lambda[i] / nl), 2.0); } d2 = Math.sqrt(d2); fitness = (d1 + theta * d2); } else { System.out.println("MOEAD.fitnessFunction: unknown type " + functionType_); System.exit(-1); } return fitness; } // fitnessEvaluation
/** * 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
/** * Evaluates a solution. * * @param solution The solution to evaluate. * @throws JMException */ public void evaluate(Solution solution) throws JMException { Variable[] decisionVariables = solution.getDecisionVariables(); double[] x = new double[numberOfVariables_]; for (int i = 0; i < numberOfVariables_; i++) x[i] = decisionVariables[i].getValue(); int count1, count2, count3; double sum1, sum2, sum3, yj, hj; sum1 = sum2 = sum3 = 0.0; count1 = count2 = count3 = 0; for (int j = 3; j <= numberOfVariables_; j++) { yj = x[j - 1] - 2.0 * x[1] * Math.sin(2.0 * Math.PI * x[0] + j * Math.PI / numberOfVariables_); hj = 4.0 * yj * yj - Math.cos(8.0 * Math.PI * yj) + 1.0; if (j % 3 == 1) { sum1 += hj; count1++; } else if (j % 3 == 2) { sum2 += hj; count2++; } else { sum3 += hj; count3++; } } solution.setObjective( 0, Math.cos(0.5 * Math.PI * x[0]) * Math.cos(0.5 * Math.PI * x[1]) + 2.0 * sum1 / (double) count1); solution.setObjective( 1, Math.cos(0.5 * Math.PI * x[0]) * Math.sin(0.5 * Math.PI * x[1]) + 2.0 * sum2 / (double) count2); solution.setObjective(2, Math.sin(0.5 * Math.PI * x[0]) + 2.0 * sum3 / (double) count3); } // evaluate