-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
dominance.c
88 lines (83 loc) · 1.96 KB
/
dominance.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/* Domination checking routines */
# include <stdio.h>
# include <stdlib.h>
# include <math.h>
# include "nsga2.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 (NSGA2Type *nsga2Params, 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<nsga2Params->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);
}
}
}
}
}
}