多目标遗传算法 ------ 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 ...
随机推荐
- matlab提速技巧(自matlab帮助文件)
matlab提速技巧(自matlab帮助文件) 1.首先要学会用profiler.1.1. 打开profiler.To open the Profiler, select View -> Pro ...
- Life Forms
poj3294:http://poj.org/problem?id=3294 题意:就是求n个串的中一个最大的子串,这个子串在超过n/2的串中出现. 题解:这是一道好题.首先一种解法就是用后缀数组来搞 ...
- js页面传参数时,参数值包含特殊字符的处理
js页面传参数时,参数值包含特殊字符应该怎么处理,解决方法就是利用js的escape函数,这个函数在解决中文乱码等方面应用的比较广泛.推荐使用. 工作中遇到的小问题,一个页面中通过window.sho ...
- Linux Shell编程(16)——循环
循环就是重复一些命令的代码块,如果条件不满足就退出循环. for loops for arg in [list] 这是一个基本的循环结构.它与C的for结构有很大不同. for arg in [lis ...
- 对于利用pca 和 cca 进行fmri激活区识别的理解
1.pca 抛开fmri研究这个范畴,我们有一个超长向量,这个超长向量在fmri研究中,就是体素数据.向量中的每个数值,都代表在相应坐标轴下的坐标值.这些坐标轴所组成的坐标系,其实是标准单位坐标系.向 ...
- Delphi安装/卸载OCX控件的方法
delphi 安装卸载ocx 请参见 如下 http://blog.csdn.net/xt_chaoji/article/details/7027298 打开Delphi,关闭所有项目. 1. ...
- Unity5 的新旧延迟渲染Deferred Lighting Rendering Path
unity5 的render path ,比4的区别就是使用的新的deferred rendering,之前的4的deferred rendering(其实是light prepass)也被保留了下来 ...
- HDOJ/HDU 2547 无剑无我(两点间的距离)
Problem Description 北宋末年,奸臣当道,宦官掌权,外侮日亟,辽军再犯.时下战火连连,烽烟四起,哀鸿遍野,民不聊生,又有众多能人异士群起而反,天下志士云集响应,景粮影从. 值此危急存 ...
- 解放程序猿宝贵的右手(或者是左手) ——Android自动化测试技巧
解放双手--Android自动化测试 - eclipse_xu - 博客频道 - CSDN.NET 解放程序猿宝贵的右手(或者是左手) --Android自动化测试技巧
- grunt个人理解
最近在学习grunt的内容,也希望能将grunt使用在新的项目中,本文是对grunt的相关概念的个人理解,仅供与道友们交流和学习,如有疑义,欢迎道友们指点. 首先,grunt是基于nodejs的,那就 ...