// DTLZ1.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 DTLZ1 */ @SuppressWarnings("serial") public class DTLZ1 extends AbstractDoubleProblem { /** * Creates a default DTLZ1 problem (7 variables and 3 objectives) */ public DTLZ1() { this(7, 3); } /** * Creates a DTLZ1 problem instance * * @param numberOfVariables Number of variables * @param numberOfObjectives Number of objective functions */ public DTLZ1(Integer numberOfVariables, Integer numberOfObjectives) throws JMetalException { setNumberOfVariables(numberOfVariables); setNumberOfObjectives(numberOfObjectives); setName("DTLZ1"); 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[] 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) - Math.cos(20.0 * Math.PI * (x[i] - 0.5)); } g = 100 * (k + g); for (int i = 0; i < numberOfObjectives; i++) { f[i] = (1.0 + g) * 0.5; } for (int i = 0; i < numberOfObjectives; i++) { for (int j = 0; j < numberOfObjectives - (i + 1); j++) { f[i] *= x[j]; } if (i != 0) { int aux = numberOfObjectives - (i + 1); f[i] *= 1 - x[aux]; } } for (int i = 0; i < numberOfObjectives; i++) { solution.setObjective(i, f[i]); } } }