-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy patheval.c
43 lines (38 loc) · 1.04 KB
/
eval.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
/* Routine for evaluating population members */
# include <stdio.h>
# include <stdlib.h>
# include <math.h>
# include "nsga2.h"
# include "rand.h"
/* Routine to evaluate objective function values and constraints for a population */
void evaluate_pop (NSGA2Type *nsga2Params, population *pop, void *inp, void *out)
{
int i;
for (i=0; i<nsga2Params->popsize; i++)
{
evaluate_ind (nsga2Params, &(pop->ind[i]), inp, out);
}
return;
}
/* Routine to evaluate objective function values and constraints for an individual */
void evaluate_ind (NSGA2Type *nsga2Params, individual *ind, void *inp, void *out)
{
int j;
test_problem (ind->xreal, ind->xbin, ind->gene, ind->obj, ind->constr);
if (nsga2Params->ncon==0)
{
ind->constr_violation = 0.0;
}
else
{
ind->constr_violation = 0.0;
for (j=0; j<nsga2Params->ncon; j++)
{
if (ind->constr[j]<0.0)
{
ind->constr_violation += ind->constr[j];
}
}
}
return;
}