多目标遗传算法 ------ NSGA-II (部分源码解析)父、子种群合并 merge.c
/* Routine for mergeing two populations */ # include <stdio.h>
# include <stdlib.h>
# include <math.h> # include "global.h"
# include "rand.h" /* Routine to merge two populations into one */
void merge(population *pop1, population *pop2, population *pop3)
{
int i, k;
for (i=; i<popsize; i++)
{
copy_ind (&(pop1->ind[i]), &(pop3->ind[i]));
}
for (i=, k=popsize; i<popsize; i++, k++)
{
copy_ind (&(pop2->ind[i]), &(pop3->ind[k]));
}
return;
} /* Routine to copy an individual 'ind1' into another individual 'ind2' */
void copy_ind (individual *ind1, individual *ind2)
{
int i, j;
ind2->rank = ind1->rank;
ind2->constr_violation = ind1->constr_violation;
ind2->crowd_dist = ind1->crowd_dist;
if (nreal!=)
{
for (i=; i<nreal; i++)
{
ind2->xreal[i] = ind1->xreal[i];
}
}
if (nbin!=)
{
for (i=; i<nbin; i++)
{
ind2->xbin[i] = ind1->xbin[i];
for (j=; j<nbits[i]; j++)
{
ind2->gene[i][j] = ind1->gene[i][j];
}
}
}
for (i=; i<nobj; i++)
{
ind2->obj[i] = ind1->obj[i];
}
if (ncon!=)
{
for (i=; i<ncon; i++)
{
ind2->constr[i] = ind1->constr[i];
}
}
return;
}
copy_ind 具体进行两个个体 内容拷贝的函数。
29 ind2->rank = ind1->rank;
30 ind2->constr_violation = ind1->constr_violation;
31 ind2->crowd_dist = ind1->crowd_dist; 复制个体的 支配层 排序值。
复制个体的 限制条件 的超出值, 大于等于0未超出, 小于0为超出限制。
复制个体的 拥挤距离 。
判断个体的编码, 把个体的具体编码值 复制。
复制个体的 各个 目标函数的数值。
复制个体的 各个限制条件的 数值, 所有限制条件的数值之和等于 constr_violation 。
多目标遗传算法 ------ NSGA-II (部分源码解析)父、子种群合并 merge.c的更多相关文章
- 多目标遗传算法 ------ NSGA-II (部分源码解析) 临时种群生成新父代种群 fillnds.c
/* Nond-domination based selection routines */ # 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 ...
随机推荐
- Tools (StExBar vs Cmder)which can switch to command line window on context menu in windows OS
https://tools.stefankueng.com/StExBar.html https://github.com/cmderdev/cmder
- panda迭代
1.注意 - 不要尝试在迭代时修改任何对象.迭代是用于读取,迭代器返回原始对象(视图)的副本,因此更改将不会反映在原始对象上. 2.itertuples()方法将为DataFrame中的每一行返回一个 ...
- pandas设置值、更改值
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2018/5/24 15:03 # @Author : zhang chao # @Fi ...
- Ajax+JSP登陆后带参数跳转
点击提交按钮后使用Ajax将用户名和密码传至后台校验,然后判断返回结果进行跳转或提示错误. <%@ taglib prefix="form" uri="http:/ ...
- bram和dram的区别
http://blog.csdn.net/jbb0523/article/details/6533760
- day9 字符串格式化输出 % .format()
常用的格式化输出方式1 % 方式 print("i am %s my hobby is %s" %("yt","eat")) 打印浮点数,. ...
- LOJ #2718. 「NOI2018」归程(Dijkstra + Kruskal重构树 + 倍增)
题意 给你一个无向图,其中每条边有两个值 \(l, a\) 代表一条边的长度和海拔. 其中有 \(q\) 次询问(强制在线),每次询问给你两个参数 \(v, p\) ,表示在 \(v\) 出发,能开车 ...
- Spring Cloud(三) --- hystrix
Hystrix 说到Hystrix就得先说一下产生的背景等等,那就是雪崩效应. 在微服务中肯定存在多个服务层之间的调用,基础服务的故障可能会导致级联故障,进而造成整个系统不可用的情况,这种现象被称为服 ...
- Android:更好的自定义字体方案
http://ryanhoo.github.io/blog/2014/05/05/android-better-way-to-apply-custom-font/ 情景 解决方案 1)Android默 ...
- 标准C++类std::string的内存共享和Copy-On-Write...
标准C++类std::string的 内存共享和Copy-On-Write技术 陈皓 1. 概念 Scott Meyers在<More Effective C++>中举了个例子,不知你是否 ...