NSGA(非支配排序遗传算法)、NSGA-II(带精英策略的快速非支配排序遗传算法),都是基于遗传算法的多目标优化算法,是基于pareto最优解讨论的多目标优化。
在官网:
http://www.iitk.ac.in/kangal/codes.shtml
可以下载到 NSGA-II 的C语言版源码,下载最新版后打开如下:
其中,nsga2r.c 为主文件,打开后找到核心代码,如下:
1 for (i=2; i<=ngen; i++)2 {3 selection (parent_pop, child_pop);4 mutation_pop (child_pop);5 decode_pop(child_pop);6 evaluate_pop(child_pop);7 merge (parent_pop, child_pop, mixed_pop);8 fill_nondominated_sort (mixed_pop, parent_pop);9 /*Comment following three lines if information for all10 generations is not desired, it will speed up the execution*/
11 fprintf(fpt4,"# gen = %d\n",i);12 report_pop(parent_pop,fpt4);13 fflush(fpt4);14 printf("\n gen = %d