种群解码函数  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. GBin1插件推荐之马可波罗(Marco Polo),jQuery的自动补齐插件 - Autocomplete Plugin

    让我们Google一下"jQuery autocomplete plugin"(jquery自动补齐插件).在过去的4年中,我已经Google了很多次这个组合了.然而结果并没有变化 ...

  2. 如何为企业选择最理想的Linux服务器系统?

    [2013年10月12日 51CTO外电头条]什么样的Linux服务器最合适您的企业?简言之,它需要为员工带来工作所需的理想支持效果. 相对于成百上千种Linux桌面系统,Linux服务器系统的数量其 ...

  3. Palindrome

    poj3974:http://poj.org/problem?id=3974 题意:求给定长度最长回文串的长度. 题解:直接套manacher,搞定. #include<iostream> ...

  4. 利用merge优化

    create table a1(TP_END_DATE NUMBER,WK_END_DATE NUMBER, MTH_START_DATE NUMBER, MTH_END_DATE NUMBER, T ...

  5. lingo运筹学上机实验指导

    <运筹学上机实验指导>分为两个部分,第一部分12学时,是与运筹学理论课上机同步配套的4个实验(线性规划.灵敏度分析.运输问题与指派问题.最短路问题和背包问题)的Excel.LONGO和LI ...

  6. error: /lib64/libc.so.6: symbol _dl_starting_up, version GLIBC_PRIVATE not defined in file ld-linux-x86-64.so.2 with link time reference

    ]$ sudo yum install libnotify*Loaded plugins: fastestmirror, refresh-packagekit, securitySetting up ...

  7. TCP/IP 邮件的原理

    邮件通过SMTP协议来实现,有它的服务器SMTP服务器. 它是怎么在万维网中运行的呢? 我们来看看两个案例,下面的两个图来展示. 案例一: Alice通过传统的邮件服务器发送给Bob,Bob通过HTT ...

  8. 【转】android官方侧滑菜单DrawerLayout详解

    原文网址:http://www.jcodecraeer.com/a/anzhuokaifa/androidkaifa/2014/0925/1713.html drawerLayout是Support ...

  9. 【转】实现展开列ExpandableListView的三种方式之SimpleExpandableListAdapter实例

    原文网址:http://blog.csdn.net/x605940745/article/details/12099709 实现可扩展展开列ExpandableListView的三种方式 欢迎加入QQ ...

  10. mkfs 的使用

    使用方法: [root@localhost beinan]# mkfs -t 文件系统  存储设备 注:这里的文件系统是要指定的,比如 ext3 :reiserfs :ext2 :fat32 :msd ...