jeco.core.problems.zdt.ZDT3 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.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 ZDT3 extends ZDT {
public ZDT3(Integer numberOfVariables) {
super(numberOfVariables);
for (int i = 0; i < numberOfVariables; i++) {
lowerBound[i] = 0.0;
upperBound[i] = 1.0;
}
} // ZDT1
public ZDT3() {
this(30);
}
public void evaluate(Solution> solution) {
ArrayList> variables = solution.getVariables();
double f1 = variables.get(0).getValue();
double g = 0;
for (int j = 1; j < numberOfVariables; ++j) {
g += variables.get(j).getValue();
}
g *= 9.0;
g /= numberOfVariables - 1;
g += 1.0;
double h = 1 - Math.sqrt(f1 / g) - (f1 / g) * Math.sin(10.0 * Math.PI * f1);
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 ZDT3 clone() {
ZDT3 clone = new ZDT3(this.numberOfVariables);
for(int i=0; i