jeco.core.problems.dtlz.DTLZ4 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 DTLZ4 extends DTLZ {
public DTLZ4(Integer numberOfVariables) {
super(numberOfVariables);
for (int i = 0; i < numberOfVariables; i++) {
lowerBound[i] = 0.0;
upperBound[i] = 1.0;
}
}
public DTLZ4() {
this(12);
}
public void evaluate(Solution> solution) {
ArrayList> variables = solution.getVariables();
double[] x = new double[numberOfVariables];
double[] f = new double[numberOfObjectives];
double alpha = 100.0;
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);
}
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));
} //if
} // for
for (int i = 0; i < numberOfObjectives; i++) {
solution.getObjectives().set(i, f[i]);
}
}
public DTLZ4 clone() {
DTLZ4 clone = new DTLZ4(this.numberOfVariables);
for(int i=0; i