/* 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的更多相关文章

  1. 多目标遗传算法 ------ NSGA-II (部分源码解析)介绍

    NSGA(非支配排序遗传算法).NSGA-II(带精英策略的快速非支配排序遗传算法),都是基于遗传算法的多目标优化算法,是基于pareto最优解讨论的多目标优化. 在官网: http://www.ii ...

  2. 多目标遗传算法 ------ NSGA-II (部分源码解析) 交叉操作 crossover.c

    遗传算法中的交叉操作是 对NSGA-II  源码分析的  最后一部分, 这一部分也是我 从读该算法源代码和看该算法论文理解偏差最大的  函数模块. 这里,首先提一下,遗传算法的  交叉操作.变异操作都 ...

  3. 多目标遗传算法 ------ NSGA-II (部分源码解析)目标函数 problemdef.c

    /* Test problem definitions */ # include <stdio.h> # include <stdlib.h> # include <ma ...

  4. 多目标遗传算法 ------ NSGA-II (部分源码解析) 拥挤距离计算 crowddist.c

    /* Crowding distance computation routines */ # include <stdio.h> # include <stdlib.h> # ...

  5. 多目标遗传算法 ------ NSGA-II (部分源码解析)二元锦标赛选择 tourselect.c

    tourselect.c  文件中共有两个函数: selection (population *old_pop, population *new_pop) individual* tournament ...

  6. 多目标遗传算法 ------ NSGA-II (部分源码解析)状态报告 打印 report.c

    /* Routines for storing population data into files */ # include <stdio.h> # include <stdlib ...

  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 (部分源码解析) 临时种群生成新父代种群 fillnds.c

    /* Nond-domination based selection routines */ # include <stdio.h> # include <stdlib.h> ...

随机推荐

  1. Flask-论坛开发-1-基础知识

    对Flask感兴趣的,可以看下这个视频教程:http://study.163.com/course/courseLearn.htm?courseId=1004091002 1. 第一个 flask 程 ...

  2. Kivy 中文教程 实例入门 简易画板 (Simple Paint App):3. 随机颜色及清除按钮

    1. 随机颜色 通过前面的教程,咪博士已经带大家实现了画板的绘图功能.但是,现在画板只能画出黄色的图案,还十分单调,接下来咪博士就教大家,如何使用随机颜色,让画板变得五彩斑斓. 改进后的代码如下: f ...

  3. schema举例一

    schema举例一: <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs=& ...

  4. 睡前小dp-poj1276-多重背包+二进制优化

    http://poj.org/problem?id=1276 简单的多重背包,不过需要优化一下才能过.网上还有暴力的做法. 二进制优化在背包九讲里讲的比较清楚.对于多重背包的每一件物品,使用二进制的形 ...

  5. Sql Server 之 Merge

    转载:http://blog.csdn.net/zmoneyz/article/details/38404111 现在我们来创建了两个表Person和UserLogin Person表如下: User ...

  6. Educational Codeforces Round 26 B,C

    B. Flag of Berland 链接:http://codeforces.com/contest/837/problem/B 思路:题目要求判断三个字母是否是条纹型的,而且宽和高相同,那么先求出 ...

  7. coursera吴恩达 机器学习编程作业原文件 及我的作业

    保存在github上供广大网友下载:点击 8个zip,原文件,没有任何改动. 另外,不定期上传我自己关于这门课的学习过程笔记和心得,有兴趣的盆友可以点击这里查看.

  8. vlc sdl2.0 播放示例

    #include <stdio.h> #include <stdint.h> #include <math.h> #include <stdlib.h> ...

  9. libcurl使用easy模式阻塞卡死等问题的完美解决

    引言: 由于要在android手机测进行DM开发, 其中最重要的就是FUMO和SCOMO下载, 下载使用的是linux开源库libcurl. 于是就把libcurl的使用研究了一遍, 有些心得, 并解 ...

  10. WorkFlow基础实战

    WorkFlow使用笔记---- 状态机工作流的使用: 1.首先,项目的目标框架要选择.Net4.5版本,才有状态机工作流. 2.新建“活动”项,先从工具栏拖出一个StateMachine,然后添加其 ...