49 int *failed = (
int *)
palloc((num_gene + 1) *
sizeof(int));
50 int *from = (
int *)
palloc((num_gene + 1) *
sizeof(int));
51 int *indx = (
int *)
palloc((num_gene + 1) *
sizeof(int));
52 int *check_list = (
int *)
palloc((num_gene + 1) *
sizeof(int));
67 for (k = 0; k < num_gene; k++)
71 check_list[k + 1] = 0;
87 for (k = 0; k < num_gene; k++)
89 offspring[k] = tour2[k];
91 check_list[tour2[k]]++;
95 for (k = left; k <= right; k++)
97 check_list[offspring[k]]--;
98 offspring[k] = tour1[k];
100 check_list[tour1[k]]++;
110 for (k = left; k <= right; k++)
113 if (tour1[k] == tour2[k])
121 while (!(found) && (
j < num_gene))
123 if ((offspring[
j] == tour1[k]) && (from[
j] ==
DAD))
126 check_list[offspring[
j]]--;
127 offspring[
j] = tour2[k];
129 check_list[tour2[k]]++;
138 failed[mx_fail] = (int) tour1[k];
152 for (k = 0; k < mx_hold; k++)
157 while (!(found) && (
j < num_gene))
160 if ((failed[k] == (
int) offspring[
j]) && (from[
j] ==
DAD))
162 check_list[offspring[
j]]--;
163 offspring[
j] = tour2[indx[k]];
164 check_list[tour2[indx[k]]]++;
179 for (k = 1; k <= num_gene; k++)
182 if (check_list[k] > 1)
188 if ((offspring[
i] == (
Gene) k) && (from[
i] ==
DAD))
192 while (
j <= num_gene)
194 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)