多目标遗传算法 ------ NSGA-II (部分源码解析) 二进制编码的个体解码操作 decode.c
种群解码函数 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的更多相关文章
- 多目标遗传算法 ------ NSGA-II (部分源码解析)辅助变量 双链表操作 list.c
/* A custom doubly linked list implemenation */ # include <stdio.h> # include <stdlib.h> ...
- 多目标遗传算法 ------ NSGA-II (部分源码解析)介绍
NSGA(非支配排序遗传算法).NSGA-II(带精英策略的快速非支配排序遗传算法),都是基于遗传算法的多目标优化算法,是基于pareto最优解讨论的多目标优化. 在官网: http://www.ii ...
- 多目标遗传算法 ------ NSGA-II (部分源码解析) 交叉操作 crossover.c
遗传算法中的交叉操作是 对NSGA-II 源码分析的 最后一部分, 这一部分也是我 从读该算法源代码和看该算法论文理解偏差最大的 函数模块. 这里,首先提一下,遗传算法的 交叉操作.变异操作都 ...
- 多目标遗传算法 ------ NSGA-II (部分源码解析)目标函数 problemdef.c
/* Test problem definitions */ # include <stdio.h> # include <stdlib.h> # include <ma ...
- 多目标遗传算法 ------ NSGA-II (部分源码解析)状态报告 打印 report.c
/* Routines for storing population data into files */ # include <stdio.h> # include <stdlib ...
- 多目标遗传算法 ------ NSGA-II (部分源码解析) 拥挤距离计算 crowddist.c
/* Crowding distance computation routines */ # include <stdio.h> # include <stdlib.h> # ...
- 多目标遗传算法 ------ NSGA-II (部分源码解析)README 算法的部分英文解释
This is the Readme file for NSGA-II code. About the Algorithm--------------------------------------- ...
- 多目标遗传算法 ------ NSGA-II (部分源码解析) 实数、二进制编码的变异操作 mutation.c
遗传算法的变异操作 /* Mutation routines */ # include <stdio.h> # include <stdlib.h> # include < ...
- 多目标遗传算法 ------ NSGA-II (部分源码解析)两个个体支配判断 dominance.c
/* Domination checking routines */ # include <stdio.h> # include <stdlib.h> # include &l ...
- 多目标遗传算法 ------ NSGA-II (部分源码解析)二元锦标赛选择 tourselect.c
tourselect.c 文件中共有两个函数: selection (population *old_pop, population *new_pop) individual* tournament ...
随机推荐
- 第一个deeplearning4jproject跑起
deeplearning4j是基于java的深度学习库,当然,它有许多特点,但暂时还没学那么深入,所以就不做介绍了 需要学习dl4j,无从下手,就想着先看看官网的examples,于是,下载了exam ...
- ExtJS中动态设置TextField的readOnly属性
第一种方式: textField, 如果知道textField的id = 'textField' 话,就可以利用如下的方法: 则代码如下:Ext.getCmp("textField" ...
- [CF Round #294 div2] E. A and B and Lecture Rooms 【树上倍增】
题目链接:E. A and B and Lecture Rooms 题目大意 给定一颗节点数10^5的树,有10^5个询问,每次询问树上到xi, yi这两个点距离相等的点有多少个. 题目分析 若 x= ...
- Codeforces Round #206 (Div. 2)
只会做三个题: A:简单题,不解释: #include<cstdio> using namespace std; int k,d; int main() { scanf("%d% ...
- windows驱动开发推荐书籍
[作者] 猪头三 个人网站 :http://www.x86asm.com/ [序言] 很多人都对驱动开发有兴趣,但往往找不到正确的学习方式.当然这跟驱动开发的本土化资料少有关系.大多学的驱动开发资料都 ...
- bzoj3166
首先不难想到穷举次大数然后我们只要找到满足这个数是次大数的最大区间即可显然答案只可能是这两种[LL[i]+1,R[i]-1]和[L[i]+1,RR[i]-1]L[i]表示这个数ai左侧第一个比它大的数 ...
- WordPress特制字符串URL重定向限制绕过漏洞
漏洞版本: WordPress 3.6 漏洞描述: Bugtraq ID:62344 CVE ID:CVE-2013-4339 WordPress是一种使用PHP语言开发的博客平台,用户可以在支持PH ...
- WordPress Simple Login Registration插件’username‘参数跨站脚本漏洞
漏洞名称: WordPress Simple Login Registration插件’username‘参数跨站脚本漏洞 CNNVD编号: CNNVD-201308-519 发布时间: 2013-0 ...
- bootstrap真是个好东西
之前就知道有bootstrap这么个东东,但是因为本身不做web,也就没有仔细了解.这次一个项目合作方使用django和bootstrap做的,有机会接触了一些,感觉确实非常好! 今天下午利用一个下午 ...
- Leetcode那点事儿
1 .Two Sum 2.Add Two Numbers 3.Longest Substring Without Repeating Characters 7.Reverse Integer 26. ...