⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dominance.c

📁 nsga2具体算法代码,用来多目标遗传算法的学习和研究
💻 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 = 0;    flag2 = 0;    if (a->constr_violation<0 && b->constr_violation<0)    {        if (a->constr_violation > b->constr_violation)        {            return (1);        }        else        {            if (a->constr_violation < b->constr_violation)            {                return (-1);            }            else            {                return (0);            }        }    }    else    {        if (a->constr_violation < 0 && b->constr_violation == 0)        {            return (-1);        }        else        {            if (a->constr_violation == 0 && b->constr_violation <0)            {                return (1);            }            else            {                for (i=0; i<nobj; i++)                {                    if (a->obj[i] < b->obj[i])                    {                        flag1 = 1;                    }                    else                    {                        if (a->obj[i] > b->obj[i])                        {                            flag2 = 1;                        }                    }                }                if (flag1==1 && flag2==0)                {                    return (1);                }                else                {                    if (flag1==0 && flag2==1)                    {                        return (-1);                    }                    else                    {                        return (0);                    }                }            }        }    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -