-
Notifications
You must be signed in to change notification settings - Fork 0
/
fitness.h
39 lines (36 loc) · 906 Bytes
/
fitness.h
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
void calFit(Chromo *population, int N, int inicio, int fin)
{
int errores;
int k, i, j;
for (k = inicio; k < fin; k++)
{
errores = 0;
for (i = 0; i < N; i++)
{
for (j = 0; j < N; j++)
{
if (i != j)
{
if ((population[k].config[i] - i) == (population[k].config[j] - j))
{
errores++;
}
if ((population[k].config[i] + i) == (population[k].config[j] + j))
{
errores++;
}
}
}
}
population[k].fitness = errores;
}
}
void copyBest(Chromo *Best, Chromo local, int N)
{
int i;
for (i = 0; i < N; i++)
{
Best->config[i] = local.config[i];
}
Best->fitness = local.fitness;
}