jeco.core.problems.dtlz.DTLZ1 Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jeco-core Show documentation
Show all versions of jeco-core Show documentation
Java Evolutionary COmputation library
The newest version!
package jeco.core.problems.dtlz;
import java.util.ArrayList;
import jeco.core.problem.Solution;
import jeco.core.problem.Variable;
public class DTLZ1 extends DTLZ {
public DTLZ1(Integer numberOfVariables) {
super(numberOfVariables);
for (int i = 0; i < numberOfVariables; i++) {
lowerBound[i] = 0.0;
upperBound[i] = 1.0;
}
}
public DTLZ1() {
this(7);
}
public void evaluate(Solution> solution) {
ArrayList> variables = solution.getVariables();
double[] x = new double[numberOfVariables];
double[] f = new double[numberOfObjectives];
int k = numberOfVariables - numberOfObjectives + 1;
for (int i = 0; i < numberOfVariables; i++) {
x[i] = variables.get(i).getValue();
}
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];
} //if
}//for
for (int i = 0; i < numberOfObjectives; i++) {
solution.getObjectives().set(i, f[i]);
}
}
public DTLZ1 clone() {
DTLZ1 clone = new DTLZ1(this.numberOfVariables);
for(int i=0; i