jeco.core.problems.dtlz.DTLZ6 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 DTLZ6 extends DTLZ {
public DTLZ6(Integer numberOfVariables) {
super(numberOfVariables);
for (int i = 0; i < numberOfVariables; i++) {
lowerBound[i] = 0.0;
upperBound[i] = 1.0;
}
}
public DTLZ6() {
this(12);
}
public void evaluate(Solution> solution) {
ArrayList> variables = solution.getVariables();
double[] x = new double[numberOfVariables];
double[] f = new double[numberOfObjectives];
double[] theta = new double[numberOfObjectives - 1];
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 += java.lang.Math.pow(x[i], 0.1);
}
double t = java.lang.Math.PI / (4.0 * (1.0 + g));
theta[0] = x[0] * java.lang.Math.PI / 2;
for (int i = 1; i < (numberOfObjectives - 1); i++) {
theta[i] = t * (1.0 + 2.0 * g * x[i]);
}
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(theta[j]);
}
if (i != 0) {
int aux = numberOfObjectives - (i + 1);
f[i] *= java.lang.Math.sin(theta[aux]);
} //if
} // for
for (int i = 0; i < numberOfObjectives; i++) {
solution.getObjectives().set(i, f[i]);
}
}
public DTLZ6 clone() {
DTLZ6 clone = new DTLZ6(this.numberOfVariables);
for(int i=0; i