haris989 / NSGA-II

This is a python implementation of NSGA-II algorithm. NSGA is a popular non-domination based genetic algorithm for multi-objective optimization. It is a very effective algorithm but has been generally criticized for its computational complexity, lack of elitism and for choosing the optimal parameter value for sharing parameter σshare. A modified version, NSGA II was developed, which has a better sorting algorithm , incorporates elitism and no sharing parameter needs to be chosen a priori.
MIT License
380 stars 158 forks source link

Result differ from R #6

Open MikeChenfu opened 5 years ago

MikeChenfu commented 5 years ago

Hello, I test the code and compare the results with R. Why is the number of result values different from R's result? I am a beginner to the NSGA. I appreciate if anyone has idea about it. Many thanks.

Mirror-HHf commented 4 years ago

您好,我测试了代码并将结果与​​R比较。为什么结果值的数量与R的结果不同?我是NSGA的初学者。如果有人对此有想法,我将不胜感激。非常感谢。

我在学习nsga2的时候,也发现这里可能有个错误,可否给个联系方式一起交流一下?

antonkravtsevich commented 4 years ago

Hello, I test the code and compare the results with R. Why is the number of result values different from R's result? I am a beginner to the NSGA. I appreciate if anyone has idea about it. Many thanks.

It seems like there is an issue in crowding_distance function - values for different axis is mixed together. There should be

    for k in range(1,len(front)-1):
        distance[k] = distance[k]+ (values1[sorted1[k+1]] - values1[sorted1[k-1]])/(max(values1)-min(values1))
    for k in range(1,len(front)-1):
        distance[k] = distance[k]+ (values2[sorted2[k+1]] - values2[sorted2[k-1]])/(max(values2)-min(values2))

instead of

    for k in range(1,len(front)-1):
        distance[k] = distance[k]+ (values1[sorted1[k+1]] - values2[sorted1[k-1]])/(max(values1)-min(values1))
    for k in range(1,len(front)-1):
        distance[k] = distance[k]+ (values1[sorted2[k+1]] - values2[sorted2[k-1]])/(max(values2)-min(values2))

I'm not for 100% sure that this is accurate fix, but it based on original paper (http://www.dmi.unict.it/mpavone/nc-cs/materiale/NSGA-II.pdf, p. 185, bottom of the page).

Hope it will help!

UPD: Just found out that there is already a pull request for this issue.