dominance.c
来自「多目标遗传算法的程序」· C语言 代码 · 共 89 行
C
89 行
/* 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 + =
减小字号Ctrl + -
显示快捷键?