zoukankan      html  css  js  c++  java
  • 多目标遗传算法 ------ NSGA-II (部分源码解析)介绍

    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 all
    10         generations is not desired, it will speed up the execution */
    11         fprintf(fpt4,"# gen = %d
    ",i);
    12         report_pop(parent_pop,fpt4);
    13         fflush(fpt4);
    14         printf("
     gen = %d",i);
    15         fflush(stdout);
    16     }

    由第1行代码可知,初始化生成代码为第一代,其后的操作为第  2  代到设定的迭代次数  ngen 

    由第3行代码可知,selection 函数  (二元锦标赛选择,SBX交叉)等功能的实现包装在一起。

    由第4行代码可知,   mutation_pop 函数 对新种群( child_pop ) 进行变异操作。 

    由第5行代码可知,decode_pop 函数 为对二进制编码的遗传个体进行解码操作。

    由第6行代码可知,evaluate_pop 函数 是对新种群( child_pop ) 进行多目标函数值的计算。

    由第7行代码可知,merge 函数  将 父种群  和   子种群   合并成临时种群(mixed_pop)。

    由第8行代码可知,fill_nondominated_sort 对临时种群(mixed_pop) 非支配排序,拥挤距离判断。

    由第12行代码可知, report_pop  对  父种群(parent_pop)中的个体的多目标函数值,支配层,拥挤距离,个体编码进行打印。

  • 相关阅读:
    Android之MessageQueue、Looper、Handler与消息循环
    Eclipse之相关快捷键
    Android之背景颜色小知识(笔记)
    Android之开发常用颜色
    Android之Handler与AsyncTask的区别
    Android之dip、dp、px、sp和屏幕密度
    the setting of serial port in the SecureCRT
    Raspberry Pi 3 Basic Command and Information
    Raspberry Pi 3 --- identify the version of linux kernal file
    Linux C/C++ ------ “” and <> in the use of head include file(Pending Verification)
  • 原文地址:https://www.cnblogs.com/devilmaycry812839668/p/6232498.html
Copyright © 2011-2022 走看看