本文已参与【新人创作礼】活动,一起开启掘金创作之路
Jmetal和PlatEMO中计算IGD时的结果差异
觉得有用的话,欢迎一起讨论相互学习~
- 如果你不知道IGD是如何计算的,欢迎查看原先的博文IGD反转世代距离-多目标优化评价指标概念及实现
最近的实验过程中,发现即使是同样的种群,在PlatEMO和Jmetal上计算有差异,大概Jmetal比PlatEMO上少一个 数量级
Jmetal Code
public double invertedGenerationalDistance(double [][] front,
double [][] trueParetoFront,
int numberOfObjectives) {
/**
* Stores the maximum values of true pareto front.
*/
double [] maximumValue ;
/**
* Stores the minimum values of the true pareto front.
*/
double [] minimumValue ;
/**
* Stores the normalized front.
*/
double [][] normalizedFront ;
/**
* Stores the normalized true Pareto front.
*/
double [][] normalizedParetoFront ;
// STEP 1. Obtain the maximum and minimum values of the Pareto front
maximumValue = utils_.getMaximumValues(trueParetoFront, numberOfObjectives);
minimumValue = utils_.getMinimumValues(trueParetoFront, numberOfObjectives);
// STEP 2. Get the normalized front and true Pareto fronts
normalizedFront = utils_.getNormalizedFront(front,
maximumValue,
minimumValue);
normalizedParetoFront = utils_.getNormalizedFront(trueParetoFront,
maximumValue,
minimumValue);
// STEP 3. Sum the distances between each point of the true Pareto front and
// the nearest point in the true Pareto front
double sum = 0.0;
for (double[] aNormalizedParetoFront : normalizedParetoFront)
sum += Math.pow(utils_.distanceToClosedPoint(aNormalizedParetoFront,
normalizedFront),
pow_);
// STEP 4. Obtain the sqrt of the sum
sum = Math.pow(sum,1.0/pow_);
// STEP 5. Divide the sum by the maximum number of points of the front
double generationalDistance = sum / normalizedParetoFront.length;
return generationalDistance;
} // generationalDistance
PlatEMO Code
function score = IGD(Population,optimum)
% <min>
% Inverted generational distance
%------------------------------- Reference --------------------------------
% C. A. Coello Coello and N. C. Cortes, Solving multiobjective optimization
% problems using an artificial immune system, Genetic Programming and
% Evolvable Machines, 2005, 6(2): 163-190.
%------------------------------- Copyright --------------------------------
% Copyright (c) 2021 BIMK Group. You are free to use the PlatEMO for
% research purposes. All publications which use this platform or any code
% in the platform should acknowledge the use of "PlatEMO" and reference "Ye
% Tian, Ran Cheng, Xingyi Zhang, and Yaochu Jin, PlatEMO: A MATLAB platform
% for evolutionary multi-objective optimization [educational forum], IEEE
% Computational Intelligence Magazine, 2017, 12(4): 73-87".
%--------------------------------------------------------------------------
PopObj = Population.best.objs;
if size(PopObj,2) ~= size(optimum,2)
score = nan;
else
score = mean(min(pdist2(optimum,PopObj),[],2));
end
end
二者区别
- Jmetal 在STEP1中对于True PF和Obtain PF都做了归一化操作 而 PlatEMO中对于PF和obtain PF没有进行归一化操作
- Jmetal在STEP3和STEP4中,IGD的计算是模仿GD的计算,假设用a表示True上的点对Obtain上获得的点的最近距离,则两者的差异在于
- 两者的参考文献不同 Jmetal - Reference: Van Veldhuizen, D.A., Lamont, G.B.: Multiobjective Evolutionary Algorithm Research: A History and Analysis. Technical Report TR-98-03, Dept. Elec. Comput. Eng., Air Force Inst. Technol. (1998) PlatEMO - C. A. Coello Coello and N. C. Cortes, Solving multiobjective optimization problems using an artificial immune system, Genetic Programming and Evolvable Machines, 2005, 6(2): 163-190.
改进Jmetal
- 如果你想要Jmetal和PlatEMO中算的一致,可以使用以下经过调整的代码
public double invertedGenerationalDistance(double[][] front,
double[][] trueParetoFront,
int numberOfObjectives) {
/**
* Stores the maximum values of true pareto front.
*/
double[] maximumValue;
/**
* Stores the minimum values of the true pareto front.
*/
double[] minimumValue;
/**
* Stores the normalized front.
*/
double[][] normalizedFront;
/**
* Stores the normalized true Pareto front.
*/
double[][] normalizedParetoFront;
normalizedFront = front;
normalizedParetoFront = trueParetoFront;
// // STEP 3. Sum the distances between each point of the true Pareto front and
// // the nearest point in the true Pareto front
// double sum = 0.0;
// for (double[] aNormalizedParetoFront : normalizedParetoFront)
// sum += Math.pow(utils_.distanceToClosedPoint(aNormalizedParetoFront,
// normalizedFront),
// pow_);
//
//
// // STEP 4. Obtain the sqrt of the sum
// sum = Math.pow(sum,1.0/pow_);
double sum = 0.0;
for (double[] aNormalizedParetoFront : normalizedParetoFront)
sum += utils_.distanceToClosedPoint(aNormalizedParetoFront,
normalizedFront);
// STEP 5. Divide the sum by the maximum number of points of the front
double generationalDistance = sum / normalizedParetoFront.length;
return generationalDistance;
} // generationalDistance