多目标遗传算法 ------ NSGA-II (部分源码解析) 实数、二进制编码的变异操作 mutation.c
遗传算法的变异操作
/* Mutation routines */ # include <stdio.h>
# include <stdlib.h>
# include <math.h> # include "global.h"
# include "rand.h" /* Function to perform mutation in a population */
void mutation_pop (population *pop)
{
int i;
for (i=; i<popsize; i++)
{
mutation_ind(&(pop->ind[i]));
}
return;
}
一次进化过程中的 变异操作, 需要调用 变异函数 mutation_ind 种群个数popsize 次。
函数包装,判断是实数编码还是二进制编码并调用不同的变异函数。
/* Function to perform mutation of an individual */
void mutation_ind (individual *ind)
{
if (nreal!=)
{
real_mutate_ind(ind);
}
if (nbin!=)
{
bin_mutate_ind(ind);
}
return;
}
二进制编码 的 变异操作:
每个个体 的 每个变量 的 二进制编码段 的 每个比特位, 以变异概率 pmut_bin 进行变异。
(单点变异)
/* Routine for binary mutation of an individual */
void bin_mutate_ind (individual *ind)
{
int j, k;
double prob;
for (j=; j<nbin; j++)
{
for (k=; k<nbits[j]; k++)
{
prob = randomperc();
if (prob <=pmut_bin)
{
if (ind->gene[j][k] == )
{
ind->gene[j][k] = ;
}
else
{
ind->gene[j][k] = ;
}
nbinmut+=;
}
}
}
return;
}
实数编码 情况下的 变异操作:
(多项式变异)
/* Routine for real polynomial mutation of an individual */
void real_mutate_ind (individual *ind)
{
int j;
double rnd, delta1, delta2, mut_pow, deltaq;
double delta;
double y, yl, yu, val, xy;
for (j=; j<nreal; j++)
{
rnd = randomperc();
if (rnd <= pmut_real)
{
y = ind->xreal[j];
yl = min_realvar[j];
yu = max_realvar[j];
delta1 = (y-yl)/(yu-yl);
delta2 = (yu-y)/(yu-yl);
delta = minimum (delta1,delta2);
rnd = randomperc();
mut_pow = 1.0/(eta_m+1.0);
if (rnd <= 0.5)
{
xy = 1.0-delta1;
val = 2.0*rnd+(1.0-2.0*rnd)*(pow(xy,(eta_m+1.0)));
deltaq = pow(val,mut_pow) - 1.0;
}
else
{
xy = 1.0-delta2;
val = 2.0*(1.0-rnd)+2.0*(rnd-0.5)*(pow(xy,(eta_m+1.0)));
deltaq = 1.0 - (pow(val,mut_pow));
}
y = y + deltaq*(yu-yl);
if (y<yl)
{
y = yl;
}
if (y>yu)
{
y = yu;
}
ind->xreal[j] = y;
nrealmut+=;
}
}
return;
}
eta_m 为 实数编码的 多项式变异的 参数, 为全局设定。
(该变异方式是为了模拟二进制编码的单点变异,逻辑比较简单,数学含义不明) 每个个体 的 每个变量 的 实数表示, 以变异概率 pmut_real 进行变异 。
多目标遗传算法 ------ NSGA-II (部分源码解析) 实数、二进制编码的变异操作 mutation.c的更多相关文章
- 多目标遗传算法 ------ NSGA-II (部分源码解析) 二进制编码的个体解码操作 decode.c
种群解码函数 decode_pop 为包装函数, 核心调用函数为 decode_ind , 对每个个体进行解码. /* Routines to decode the population */ ...
- 多目标遗传算法 ------ 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 (部分源码解析)两个个体支配判断 dominance.c
/* Domination checking routines */ # include <stdio.h> # include <stdlib.h> # include &l ...
随机推荐
- Leetcode——66.加一
@author: ZZQ @software: PyCharm @file: leetcode66_加一.py @time: 2018/11/29 16:07 要求:给定一个由整数组成的非空数组所表示 ...
- MySQL 单表优化
一.表字段优化 1.整数类型尽量使用 TINYINT.SMALLINT.MEDIUM_INT 而不是INT,非负数要加上UNSIGNED 2.VARCHAR的长度分配要合理,不要过大 3.时间字段不超 ...
- Laravel - 1
Laravel - 1 Laravel是一个很强大又非常优雅的php框架,但是Laravel的很多组件都是由社区协作的结果,Composer是php开发的一个依赖管理工具,但是墙把绝大多数的开发者堵在 ...
- Spring Boot, Java Config - No mapping found for HTTP request with URI [/…] in DispatcherServlet with name 'dispatcherServlet'
Spring Boot 启用应用: error: No mapping found for HTTP request with URI [/…] in DispatcherServlet with n ...
- [转帖]以Windows服务方式运行ASP.NET Core程序
以Windows服务方式运行ASP.NET Core程序 原作者blog: https://www.cnblogs.com/guogangj/p/9198031.htmlaspnet的blog 需要持 ...
- [转帖] testin 安全测试要点
- sql 表,字段(列),表数据(行)相关命令
随便转载,保留出处:http://www.cnblogs.com/aaron-agu/ 注: 以下所有操作都在登陆数据库后执行 命令use test; test为数据库名 查看表 show tabl ...
- 深度学习网络压缩模型方法总结(model compression)
两派 1. 新的卷机计算方法 这种是直接提出新的卷机计算方式,从而减少参数,达到压缩模型的效果,例如SqueezedNet,mobileNet SqueezeNet: AlexNet-level ac ...
- HTML-XML数据解析
HTML代码 <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> ...
- BZOJ4864[BeiJing 2017 Wc]神秘物质——非旋转treap
题目描述 21ZZ 年,冬. 小诚退休以后, 不知为何重新燃起了对物理学的兴趣. 他从研究所借了些实验仪器,整天研究各种微观粒子.这 一天, 小诚刚从研究所得到了一块奇异的陨石样本, 便迫不及待地开始 ...