多目标遗传算法 ------ NSGA-II (部分源码解析)两个个体支配判断 dominance.c
/* Domination checking routines */ # include <stdio.h>
# include <stdlib.h>
# include <math.h> # include "global.h"
# include "rand.h" /* Routine for usual non-domination checking
It will return the following values
1 if a dominates b
-1 if b dominates a
0 if both a and b are non-dominated */ int check_dominance (individual *a, individual *b)
{
int i;
int flag1;
int flag2;
flag1 = ;
flag2 = ;
if (a->constr_violation< && b->constr_violation<)
{
if (a->constr_violation > b->constr_violation)
{
return ();
}
else
{
if (a->constr_violation < b->constr_violation)
{
return (-);
}
else
{
return ();
}
}
}
else
{
if (a->constr_violation < && b->constr_violation == )
{
return (-);
}
else
{
if (a->constr_violation == && b->constr_violation <)
{
return ();
}
else
{
for (i=; i<nobj; i++)
{
if (a->obj[i] < b->obj[i])
{
flag1 = ; }
else
{
if (a->obj[i] > b->obj[i])
{
flag2 = ;
}
}
}
if (flag1== && flag2==)
{
return ();
}
else
{
if (flag1== && flag2==)
{
return (-);
}
else
{
return ();
}
}
}
}
}
}
以上代码是判断两个个体的支配关系的。
基本遵循两个原则,首先是判断两个个体是是否超出限制条件,即判断 constr_violation 的大小。
如果个体 没有超过限制条件 则个体的 constr_violation >= 0,constr_violation 默认值 为 0 。
然后判断两个个体之间的支配关系。
以上代码含义基本为,首先判断两个个体是否 超出限制,即constr_violation<0 , 如果一个个体超出限制,另一个没有超出则直接选择 未超出限制的个体。
如果两个个体都超出限制了则选出 超出限制较小 的个体, 即 constr_violation 较大个体。
如果两个个体都超出限制了 而 constr_violation 相等, 则判断两个个体 支配关系为 互不支配。
如果两个个体 均没有超出限制, 则判断两个个体的支配关系。这里的具体操作是对两个个体的各个目标函数值进行大小判断,
如果 a 个体的目标函数有小于 b 个体的, flag1==1 。如果 b 个体的目标函数有小于 a 个体的, flag2==1 。
如果 flag1==1 flag2==0, 则 a 支配 b 。
如果 flag1==0 flag2==1, 则 b 支配 a 。
如果 flag1==1 flag2==1, 则 a b 互不支配 。
多目标遗传算法 ------ NSGA-II (部分源码解析)两个个体支配判断 dominance.c的更多相关文章
- 多目标遗传算法 ------ 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 (部分源码解析) 拥挤距离计算 crowddist.c
/* Crowding distance computation routines */ # include <stdio.h> # include <stdlib.h> # ...
- 多目标遗传算法 ------ NSGA-II (部分源码解析)二元锦标赛选择 tourselect.c
tourselect.c 文件中共有两个函数: selection (population *old_pop, population *new_pop) individual* tournament ...
- 多目标遗传算法 ------ NSGA-II (部分源码解析)状态报告 打印 report.c
/* Routines for storing population data into files */ # include <stdio.h> # include <stdlib ...
- 多目标遗传算法 ------ 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 (部分源码解析) 临时种群生成新父代种群 fillnds.c
/* Nond-domination based selection routines */ # include <stdio.h> # include <stdlib.h> ...
随机推荐
- HDU 2029 Palindromes _easy version
http://acm.hdu.edu.cn/showproblem.php?pid=2029 Problem Description “回文串”是一个正读和反读都一样的字符串,比如“level”或者“ ...
- JavaScript 字符串与数组互转,并保持数据去重、排序功能
var valueArr = new Array(); if( $("input[name='type']").val() != ""){ valueArr = ...
- vCenter机器查找功能不可用的解决
1. 公司内有多个vCenter机器, 不同的部门 组别 有不通的vCenter来进行管理 最近发现有一个管理比较多的组别的vCenter下载远程登录的情况下总是无法进行高级搜索 造成想找一个虚拟机 ...
- Java之相对路径找不到文件问题解决方法
1.问题: 在程序需要通过相对路径引用文件,使用Junit可以正常执行,但是直接使用main方法找不到对应问题. 2.分析: 因为不同运行方式所使用的环境变量中的用户工作目录不同所致. 3.解决: 修 ...
- 可视化数据matplotlib之安装与简单折线图
matplotlib是一个可视化数据的模块,安装前需要先安装Visual Studio Community:然后去https://pypi.python.org/pypi上查找matplotlib并下 ...
- Goldbach`s Conjecture LightOJ - 1259 (素数打表 哥德巴赫猜想)
题意: 就是哥德巴赫猜想...任意一个偶数 都可以分解成两个(就是一对啦)质数的加和 输入一个偶数求有几对.. 解析: 首先! 素数打表..因为 质数 + 质数 = 偶数 所以 偶数 - 质数 = 质 ...
- 【 Gym - 101124E 】Dance Party (数学)
BUPT2017 wintertraining(15) #4G Gym - 101124 E.Dance Party 题意 有c种颜色,每个颜色最多分配给两个人,有M个男士,F个女士,求至少一对男士同 ...
- 【 Gym - 101138F 】GukiZ Height (数学)
BUPT2017 wintertraining(15) #4 C Gym - 101138F 题意 初始高度0,目标值h,第i天目标值会下降i,当前高度会改变a[i%n],求高度不小于目标值的最早的时 ...
- 精选Spring Boot三十五道必知必会知识点
Spring Boot 是微服务中最好的 Java 框架. 我们建议你能够成为一名 Spring Boot 的专家.本文精选了三十五个常见的Spring Boot知识点,祝你一臂之力! 问题一 Spr ...
- 自学Linux Shell4.2-监测磁盘空间mount umount df du
点击返回 自学Linux命令行与Shell脚本之路 4.2-监测磁盘空间mount umount df du 1. 挂载存储媒体mount 移除存储媒体umount ls命令用于显示文件目录列表, ...