51 int *failed = (
int *)
palloc((num_gene + 1) *
sizeof(int));
52 int *from = (
int *)
palloc((num_gene + 1) *
sizeof(int));
53 int *indx = (
int *)
palloc((num_gene + 1) *
sizeof(int));
54 int *check_list = (
int *)
palloc((num_gene + 1) *
sizeof(int));
69 for (k = 0; k < num_gene; k++)
73 check_list[k + 1] = 0;
89 for (k = 0; k < num_gene; k++)
91 offspring[k] = tour2[k];
93 check_list[tour2[k]]++;
97 for (k = left; k <= right; k++)
99 check_list[offspring[k]]--;
100 offspring[k] = tour1[k];
102 check_list[tour1[k]]++;
112 for (k = left; k <= right; k++)
115 if (tour1[k] == tour2[k])
123 while (!(found) && (
j < num_gene))
125 if ((offspring[
j] == tour1[k]) && (from[
j] ==
DAD))
128 check_list[offspring[
j]]--;
129 offspring[
j] = tour2[k];
131 check_list[tour2[k]]++;
140 failed[mx_fail] = (int) tour1[k];
154 for (k = 0; k < mx_hold; k++)
159 while (!(found) && (
j < num_gene))
162 if ((failed[k] == (
int) offspring[
j]) && (from[
j] ==
DAD))
164 check_list[offspring[
j]]--;
165 offspring[
j] = tour2[indx[k]];
166 check_list[tour2[indx[k]]]++;
181 for (k = 1; k <= num_gene; k++)
184 if (check_list[k] > 1)
190 if ((offspring[
i] == (
Gene) k) && (from[
i] ==
DAD))
194 while (
j <= num_gene)
196 if (check_list[
j] == 0)
int geqo_randint(PlannerInfo *root, int upper, int lower)
void pmx(PlannerInfo *root, Gene *tour1, Gene *tour2, Gene *offspring, int num_gene)
void pfree(void *pointer)