All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jeco.core.problems.zdt.ZDT1 Maven / Gradle / Ivy

The newest version!
package jeco.core.problems.zdt;

import java.util.ArrayList;

import jeco.core.operator.comparator.SolutionDominance;
import jeco.core.problem.Solution;
import jeco.core.problem.Solutions;
import jeco.core.problem.Variable;

public class ZDT1 extends ZDT {

    public ZDT1(Integer numberOfVariables) {
        super(numberOfVariables);
        for (int i = 0; i < numberOfVariables; i++) {
            lowerBound[i] = 0.0;
            upperBound[i] = 1.0;
        }
    } // ZDT1

    public ZDT1() {
        this(30);
    }

    public void evaluate(Solution> solution) {
        for (int i = 0; i < numberOfObjectives; i++) {
            solution.getObjectives().set(i, 0.0);
        }
        double f1 = 0, g = 0, h = 0;
        ArrayList> variables = solution.getVariables();
        f1 = variables.get(0).getValue();
        g = 0;
        for (int j = 1; j < numberOfVariables; ++j) {
            g += Math.pow(variables.get(j).getValue(), 2);
        }
        g /= numberOfVariables - 1;
        g *= 9;
        g += 1;
        h = 1 - Math.sqrt(f1 / g);
        solution.getObjectives().set(0, f1);
        solution.getObjectives().set(1, g * h);
    }

    public Solutions> computeParetoOptimalFront(int n) {
        Solutions> result = new Solutions>();

        double temp;
        for (int i = 0; i < n; ++i) {
            Solution> sol = new Solution>(numberOfObjectives);
            temp = 0.0 + (1.0 * i) / (n - 1);
            sol.getVariables().add(new Variable(temp));
            for (int j = 1; j < numberOfVariables; ++j) {
                sol.getVariables().add(new Variable(0.0));
            }

            evaluate(sol);
            result.add(sol);
        }

        result.reduceToNonDominated(new SolutionDominance>());
        return result;
    }

    public ZDT1 clone() {
    	ZDT1 clone = new ZDT1(this.numberOfVariables);
    	for(int i=0; i




© 2015 - 2024 Weber Informatics LLC | Privacy Policy