种群解码函数  decode_pop  为包装函数, 核心调用函数为  decode_ind  , 对每个个体进行解码。

 /* Routines to decode the population */

 # include <stdio.h>
# include <stdlib.h>
# include <math.h> # include "global.h"
# include "rand.h" /* Function to decode a population to find out the binary variable values based on its bit pattern */
void decode_pop (population *pop)
{
int i;
if (nbin!=)
{
for (i=; i<popsize; i++)
{
decode_ind (&(pop->ind[i]));
}
}
return;
}

核心解码操作:

 /* Function to decode an individual to find out the binary variable values based on its bit pattern */
void decode_ind (individual *ind)
{
int j, k;
int sum;
if (nbin!=)
{
for (j=; j<nbin; j++)
{
sum=;
for (k=; k<nbits[j]; k++)
{
if (ind->gene[j][k]==)
{
sum += pow(,nbits[j]--k);
}
}
ind->xbin[j] = min_binvar[j] + (double)sum*(max_binvar[j] - min_binvar[j])/(double)(pow(,nbits[j])-);
}
}
return;
}

其中,15行,

sum += pow(,nbits[j]--k);

将个体某变量的比特编码  转换为  实数。

ind->xbin[j] = min_binvar[j] + (double)sum*(max_binvar[j] - min_binvar[j])/(double)(pow(,nbits[j])-);

因为需要考虑精度问题,所以二进制编码的个体长度表示的范围空间(double)(pow(2,nbits[j])-1)在考虑精度的情况下   要大于 该变量的 范围空间 ( max_binvar[j] - min_binvar[j] ) 。

因此, 需要进行空间映射转换,以上代码便是此意。

多目标遗传算法 ------ NSGA-II (部分源码解析) 二进制编码的个体解码操作 decode.c的更多相关文章

  1. 多目标遗传算法 ------ NSGA-II (部分源码解析)辅助变量 双链表操作 list.c

    /* A custom doubly linked list implemenation */ # include <stdio.h> # include <stdlib.h> ...

  2. 多目标遗传算法 ------ NSGA-II (部分源码解析)介绍

    NSGA(非支配排序遗传算法).NSGA-II(带精英策略的快速非支配排序遗传算法),都是基于遗传算法的多目标优化算法,是基于pareto最优解讨论的多目标优化. 在官网: http://www.ii ...

  3. 多目标遗传算法 ------ NSGA-II (部分源码解析) 交叉操作 crossover.c

    遗传算法中的交叉操作是 对NSGA-II  源码分析的  最后一部分, 这一部分也是我 从读该算法源代码和看该算法论文理解偏差最大的  函数模块. 这里,首先提一下,遗传算法的  交叉操作.变异操作都 ...

  4. 多目标遗传算法 ------ NSGA-II (部分源码解析)目标函数 problemdef.c

    /* Test problem definitions */ # include <stdio.h> # include <stdlib.h> # include <ma ...

  5. 多目标遗传算法 ------ NSGA-II (部分源码解析)状态报告 打印 report.c

    /* Routines for storing population data into files */ # include <stdio.h> # include <stdlib ...

  6. 多目标遗传算法 ------ NSGA-II (部分源码解析) 拥挤距离计算 crowddist.c

    /* Crowding distance computation routines */ # include <stdio.h> # include <stdlib.h> # ...

  7. 多目标遗传算法 ------ NSGA-II (部分源码解析)README 算法的部分英文解释

    This is the Readme file for NSGA-II code. About the Algorithm--------------------------------------- ...

  8. 多目标遗传算法 ------ NSGA-II (部分源码解析) 实数、二进制编码的变异操作 mutation.c

    遗传算法的变异操作 /* Mutation routines */ # include <stdio.h> # include <stdlib.h> # include < ...

  9. 多目标遗传算法 ------ NSGA-II (部分源码解析)两个个体支配判断 dominance.c

    /* Domination checking routines */ # include <stdio.h> # include <stdlib.h> # include &l ...

  10. 多目标遗传算法 ------ NSGA-II (部分源码解析)二元锦标赛选择 tourselect.c

    tourselect.c  文件中共有两个函数: selection (population *old_pop, population *new_pop) individual* tournament ...

随机推荐

  1. 在HTML页面布局中,position的值有几种,默然的值是什么

    <!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8&qu ...

  2. seajs的spm使用

    压缩JS文件 只需要执行这个命令即可 spm build xxx.js 这时候你将得到一个压缩过的__build/xxx.js文件 合并JS文件 如果希望将JS文件中require的其他模块都合并到这 ...

  3. bzoj 2631: tree 动态树+常数优化

    2631: tree Time Limit: 30 Sec  Memory Limit: 128 MBSubmit: 1716  Solved: 576[Submit][Status] Descrip ...

  4. 2016 年开发者应该掌握的十个 Postgres 技巧

    [编者按]作为一款开源的对象-关系数据库,Postgres 一直得到许多开发者喜爱.近日,Postgres 正式发布了9.5版本,该版本进行了大量的修复和功能改进.而本文将分享10个 Postgres ...

  5. Android开源项目发现--- 效率开发工具篇(持续更新)

    1.Json2Java 根据JSon数据自动生成对应的Java实体类,还支持Parcel.Gson Annotations对应代码自动生成.期待后续的提取父类以及多url构建整个工程的功能 项目地址: ...

  6. SD卡中FAT32文件格式快速入门(图文详细介绍)

    说明: MBR :Master Boot Record ( 主引导记录) DBR :DOS Boot Record ( 引导扇区) FAT :File Allocation Table ( 文件分配表 ...

  7. HDU 5924 Mr. Frog’s Problem 【模拟】 (2016CCPC东北地区大学生程序设计竞赛)

    Mr. Frog's Problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Other ...

  8. Delphi 用Web App Debugger简单调试ISAPI 转

    用Web App Debugger简单调试ISAPI   以isapi为例: 1.新建一个project,用isapi/nsapi: 2.remove这个project中所有的unit: 3.加进你用 ...

  9. poj 1564 Sum It Up【dfs+去重】

    Sum It Up Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 6682   Accepted: 3475 Descrip ...

  10. 如何高性能的给UIImageView加个圆角?(不准说layer.cornerRadius!)

    豆电雨 搬砖自味精:http://awhisper.github.io/2016/03/12/滚动圆角卡顿刨根问底/ 使用Quartz2D直接绘制图片 步骤:  a.创建目标大小(cropWidth, ...