在多目标优化中,需要比较两个解的支配关系。
下面是JMetal中的代码,非常简洁方便。
思想 :只需注意判断解中某个目标不相等的情况
private int dominanceTest(S solution1, S solution2) {
int bestIsOne = 0 ;
int bestIsTwo = 0 ;
int result ;
for (int i = 0; i < solution1.getNumberOfObjectives(); i++) {
double value1 = solution1.getObjective(i);
double value2 = solution2.getObjective(i);
if (value1 != value2) {
if (value1 < value2) {
bestIsOne = 1;
}
if (value2 < value1) {
bestIsTwo = 1;
}
}
}
if (bestIsOne > bestIsTwo) {
result = -1;
} else if (bestIsTwo > bestIsOne) {
result = 1;
} else {
result = 0;
}
return result ;
}
// -1代表 solution1支配solution2,0代表互不支配,1代表solution2支配solution1