public static ProblemSet getProblem() throws IOException {
int taskNumber=50;
ProblemSet problemSet = new ProblemSet(taskNumber);
for(int i=1;i<=taskNumber;i++)
problemSet.add(getT(i).get(0));
return problemSet;
}
public static ProblemSet getT(int taskID) throws IOException {
ProblemSet problemSet = new ProblemSet(1);
MMZDT prob = new MMZDT(50, 1, -100,100);
prob.setGType("mean");
prob.setHType("concave");
double[][] matrix = IO.readMatrixFromFile("MData/M2/M2_"+taskID+".txt");
double shiftValues[] = IO.readShiftValuesFromFile("SVData/S2/S2_"+taskID+".txt");
prob.setRotationMatrix(matrix);
prob.setShiftValues(shiftValues);
((Problem)prob).setName("MATP2-"+taskID);
problemSet.add(prob);
return problemSet;
}
public class MMZDT extends Problem {
Integer k_;
String gType_;
String f1Type_;
public MMZDT(int numberOfVariables, int k, double lg, double ug) {
numberOfObjectives_ = 2;
numberOfVariables_ = numberOfVariables;
k_ = k;
gType_ = "sphere";
f1Type_ = "linear";
hType_ = "convex";
upperLimit_ = new double[numberOfVariables_];
lowerLimit_ = new double[numberOfVariables_];
for (int var = 0; var < k_; var++) {
lowerLimit_[var] = 0.0;
upperLimit_[var] = 1.0;
} // for
for (int var = k_; var < numberOfVariables; var++) {
lowerLimit_[var] = lg;
upperLimit_[var] = ug;
}
shiftValues_ = new double[numberOfVariables_ - k_];
for (int i = 0; i < shiftValues_.length; i++)
shiftValues_[i] = 0;
rotationMatrix_ = new double[numberOfVariables_ - k_][numberOfVariables_ - k_];
for (int i = 0; i < rotationMatrix_.length; i++) {
for (int j = 0; j < rotationMatrix_.length; j++) {
if (i != j)
rotationMatrix_[i][j] = 0;
else
rotationMatrix_[i][j] = 1;
}
}
}
xII = transformVariables(xII);
double f1 = evalF1(xI);
double evalF1(double[] xI) {
if (f1Type_.equalsIgnoreCase("linear"))
return F1_linear(xI);
else if (f1Type_.equalsIgnoreCase("nonlinear"))
return F1_nonlinear(xI);
else {
System.out.println("Error: f1 function type " + f1Type_ + " invalid");
return Double.NaN;
}
}
double F1_linear(double xI[]) {
double sum = 0;
for (int i = 0; i < xI.length; i++)
sum += xI[i];
return sum / xI.length;
}
double F1_nonlinear(double xI[]) {
double r = 0;
for (int i = 0; i < xI.length; i++)
r += (xI[i] * xI[i]);
r = Math.sqrt(r);
return 1 - Math.exp(-4 * r) * Math.pow(Math.sin(5 * Math.PI * r), 4);
}
double g = evalG(xII) + 1;
double evalG(double[] xII) throws JMException {
if (gType_.equalsIgnoreCase("sphere"))
return GFunctions.getSphere(xII);
else if (gType_.equalsIgnoreCase("rosenbrock"))
return GFunctions.getRosenbrock(xII);
else if (gType_.equalsIgnoreCase("ackley"))
return GFunctions.getAckley(xII);
else if (gType_.equalsIgnoreCase("griewank"))
return GFunctions.getGriewank(xII);
else if (gType_.equalsIgnoreCase("rastrigin"))
return GFunctions.getRastrigin(xII);
else if (gType_.equalsIgnoreCase("mean"))
return GFunctions.getMean(xII);
else {
System.out.println("Error: g function type " + gType_ + " invalid");
return Double.NaN;
}
}
double evalH(double f1, double g) {
if (hType_.equalsIgnoreCase("convex"))//凸的
return H_convex(f1, g);
else if (hType_.equalsIgnoreCase("concave"))//凹的
return H_nonconvex(f1, g);
else {
System.out.println("Error: f1 function type " + f1Type_ + " invalid");
return Double.NaN;
}
}
double H_convex(double f1, double g) {
return 1 - Math.pow(f1 / g, 0.5);
}
double H_nonconvex(double f1, double g) {
return 1 - Math.pow(f1 / g, 2);
}
double f1 = evalF1(xI);
double g = evalG(xII) + 1;
double f2 = g * evalH(f1, g);
solution.setGFunValue(g);
// System.out.println("g: " + g);
solution.setObjective(startObjPos_, f1);
solution.setObjective(startObjPos_ + 1, f2);
[1]地址可以下载: http://www.bdsc.site/websites/MTO/MO-ManyTask-Benchmarks.rar
[2]反向解析_1 Manytasking optimization MATP: https://blog.csdn.net/u013555719/article/details/103569252
[3]旋转矩阵: https://www.cnblogs.com/zhoug2020/p/7842808.html
[4]Jmetal Problem和Problem Set的变量范围: https://blog.csdn.net/u013555719/article/details/103595998
[5]MATP ManyTask Multitask Problem和Solution的变量范围: https://blog.csdn.net/u013555719/article/details/103599862
[6]MATP1生成测试SolutionSet: https://blog.csdn.net/u013555719/article/details/103603894
[7]Manytasking MATP MOOMFO 中G函数: https://blog.csdn.net/u013555719/article/details/103615605
[8]Manytasking Optimization MMDTLZ: https://blog.csdn.net/u013555719/article/details/103617911
[9]MATP ManyTask Multitask Problem和Solution的变量范围: https://blog.csdn.net/u013555719/article/details/103599862
[10]Manytasking Optimization MMDTLZ: https://blog.csdn.net/u013555719/article/details/103617911
[11]Manytasking Optimization MMDTLZ: https://blog.csdn.net/u013555719/article/details/103617911
[12]Manytasking MATP MOOMFO 中G函数: https://blog.csdn.net/u013555719/article/details/103615605