// DTLZ4.java // // Author: // Antonio J. Nebro <antonio@lcc.uma.es> // Juan J. Durillo <durillo@lcc.uma.es> // // Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. package org.uma.jmetal.problem.multiobjective.dtlz; import org.uma.jmetal.problem.impl.AbstractDoubleProblem; import org.uma.jmetal.solution.DoubleSolution; import org.uma.jmetal.util.JMetalException; import java.util.ArrayList; import java.util.List; /** * Class representing problem DTLZ4 */ @SuppressWarnings("serial") public class DTLZ4 extends AbstractDoubleProblem { /** * Creates a default DTLZ4 problem (12 variables and 3 objectives) */ public DTLZ4() { this(12, 3); } /** * Creates a DTLZ4 problem instance * * @param numberOfVariables Number of variables * @param numberOfObjectives Number of objective functions */ public DTLZ4(Integer numberOfVariables, Integer numberOfObjectives) throws JMetalException { setNumberOfVariables(numberOfVariables); setNumberOfObjectives(numberOfObjectives); setName("DTLZ4"); List<Double> lowerLimit = new ArrayList<>(getNumberOfVariables()) ; List<Double> upperLimit = new ArrayList<>(getNumberOfVariables()) ; for (int i = 0; i < getNumberOfVariables(); i++) { lowerLimit.add(0.0); upperLimit.add(1.0); } setLowerLimit(lowerLimit); setUpperLimit(upperLimit); } /** Evaluate() method */ public void evaluate(DoubleSolution solution) { int numberOfVariables = getNumberOfVariables(); int numberOfObjectives = getNumberOfObjectives() ; double alpha = 100.0; double[] f = new double[numberOfObjectives]; double[] x = new double[numberOfVariables] ; int k = getNumberOfVariables() - getNumberOfObjectives() + 1; for (int i = 0; i < numberOfVariables; i++) { x[i] = solution.getVariableValue(i) ; } double g = 0.0; for (int i = numberOfVariables - k; i < numberOfVariables; i++) { g += (x[i] - 0.5) * (x[i] - 0.5); } 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(java.lang.Math.pow(x[j], alpha) * (java.lang.Math.PI / 2.0)); } if (i != 0) { int aux = numberOfObjectives - (i + 1); f[i] *= java.lang.Math.sin(java.lang.Math.pow(x[aux], alpha) * (java.lang.Math.PI / 2.0)); } } for (int i = 0; i < numberOfObjectives; i++) { solution.setObjective(i, f[i]); } } }