Go to the source code of this file.
|
static int | gimme_edge (PlannerInfo *root, Gene gene1, Gene gene2, Edge *edge_table) |
|
static void | remove_gene (PlannerInfo *root, Gene gene, Edge edge, Edge *edge_table) |
|
static Gene | gimme_gene (PlannerInfo *root, Edge edge, Edge *edge_table) |
|
static Gene | edge_failure (PlannerInfo *root, Gene *gene, int index, Edge *edge_table, int num_gene) |
|
Edge * | alloc_edge_table (PlannerInfo *root, int num_gene) |
|
void | free_edge_table (PlannerInfo *root, Edge *edge_table) |
|
float | gimme_edge_table (PlannerInfo *root, Gene *tour1, Gene *tour2, int num_gene, Edge *edge_table) |
|
int | gimme_tour (PlannerInfo *root, Edge *edge_table, Gene *new_gene, int num_gene) |
|
◆ alloc_edge_table()
Definition at line 56 of file geqo_erx.c.
57{
59
60
61
62
63
64
66
67 return edge_table;
68}
References palloc().
Referenced by geqo().
◆ edge_failure()
Definition at line 372 of file geqo_erx.c.
373{
376 int remaining_edges = 0;
377 int four_count = 0;
378 int rand_decision;
379
380
381
382
383
384
385
386 for (
i = 1;
i <= num_gene;
i++)
387 {
388 if ((edge_table[
i].unused_edges != -1) && (
i != (
int) fail_gene))
389 {
390 remaining_edges++;
391
392 if (edge_table[
i].total_edges == 4)
393 four_count++;
394 }
395 }
396
397
398
399
400
401
402 if (four_count != 0)
403 {
404
406
407 for (
i = 1;
i <= num_gene;
i++)
408 {
409
410 if ((
Gene)
i != fail_gene &&
411 edge_table[
i].unused_edges != -1 &&
412 edge_table[
i].total_edges == 4)
413 {
414
415 four_count--;
416
417 if (rand_decision == four_count)
419 }
420 }
421
422 elog(
LOG,
"no edge found via random decision and total_edges == 4");
423 }
424 else if (remaining_edges != 0)
425 {
426
428
429 for (
i = 1;
i <= num_gene;
i++)
430 {
431
432 if ((
Gene)
i != fail_gene &&
433 edge_table[
i].unused_edges != -1)
434 {
435
436 remaining_edges--;
437
438 if (rand_decision == remaining_edges)
440 }
441 }
442
443 elog(
LOG,
"no edge found via random decision with remaining edges");
444 }
445
446
447
448
449
450
451
452 else
453 {
454
455
456
457 for (
i = 1;
i <= num_gene;
i++)
458 if (edge_table[
i].unused_edges >= 0)
460
461 elog(
LOG,
"no edge found via looking for the last unused point");
462 }
463
464
465
467 return 0;
468}
int geqo_randint(PlannerInfo *root, int upper, int lower)
References elog, ERROR, geqo_randint(), i, LOG, and root.
Referenced by gimme_tour().
◆ free_edge_table()
◆ gimme_edge()
◆ gimme_edge_table()
Definition at line 95 of file geqo_erx.c.
97{
99 index1,
100 index2;
101 int edge_total;
102
103
104 for (
i = 1;
i <= num_gene;
i++)
105 {
108 }
109
110
111
112 edge_total = 0;
113
114 for (index1 = 0; index1 < num_gene; index1++)
115 {
116
117
118
119
120
121 index2 = (index1 + 1) % num_gene;
122
123
124
125
126
127
128 edge_total +=
gimme_edge(
root, tour1[index1], tour1[index2], edge_table);
130
131 edge_total +=
gimme_edge(
root, tour2[index1], tour2[index2], edge_table);
133 }
134
135
136 return ((float) (edge_total * 2) / (float) num_gene);
137}
static int gimme_edge(PlannerInfo *root, Gene gene1, Gene gene2, Edge *edge_table)
References gimme_edge(), i, root, Edge::total_edges, and Edge::unused_edges.
Referenced by geqo().
◆ gimme_gene()
Definition at line 282 of file geqo_erx.c.
283{
286 int minimum_edges;
287 int minimum_count = -1;
288 int rand_decision;
289
290
291
292
293
294
295 minimum_edges = 5;
296
297
298
300 {
302
303
304
305
306
307
308
309
310
312 return (
Gene) abs(
friend);
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331 if (edge_table[(int) friend].unused_edges < minimum_edges)
332 {
333 minimum_edges = edge_table[(int) friend].unused_edges;
334 minimum_count = 1;
335 }
336 else if (minimum_count == -1)
338 else if (edge_table[(int) friend].unused_edges == minimum_edges)
339 minimum_count++;
340 }
341
342
343
345
346
348 {
350
351
352 if (edge_table[(
int)
friend].unused_edges == minimum_edges)
353 {
354 minimum_count--;
355
356 if (minimum_count == rand_decision)
357 return friend;
358 }
359 }
360
361
362 elog(
ERROR,
"neither shared nor minimum number nor random edge found");
363 return 0;
364}
if(TABLE==NULL||TABLE_index==NULL)
References Edge::edge_list, elog, ERROR, geqo_randint(), i, if(), root, and Edge::unused_edges.
Referenced by gimme_tour().
◆ gimme_tour()
Definition at line 196 of file geqo_erx.c.
197{
199 int edge_failures = 0;
200
201
203
204 for (
i = 1;
i < num_gene;
i++)
205 {
206
207
208
209
210
211 remove_gene(
root, new_gene[
i - 1], edge_table[(
int) new_gene[
i - 1]], edge_table);
212
213
214
215 if (edge_table[new_gene[
i - 1]].unused_edges > 0)
216 new_gene[
i] =
gimme_gene(
root, edge_table[(
int) new_gene[
i - 1]], edge_table);
217
218 else
219 {
220 edge_failures++;
221
223 }
224
225
226 edge_table[(int) new_gene[
i - 1]].unused_edges = -1;
227 }
228
229 return edge_failures;
230}
static Gene gimme_gene(PlannerInfo *root, Edge edge, Edge *edge_table)
static Gene edge_failure(PlannerInfo *root, Gene *gene, int index, Edge *edge_table, int num_gene)
static void remove_gene(PlannerInfo *root, Gene gene, Edge edge, Edge *edge_table)
References edge_failure(), geqo_randint(), gimme_gene(), i, remove_gene(), and root.
Referenced by geqo().
◆ remove_gene()
Definition at line 240 of file geqo_erx.c.
241{
244 int possess_edge;
245 int genes_remaining;
246
247
248
249
250
251
253 {
255 genes_remaining = edge_table[possess_edge].
unused_edges;
256
257
258 for (
j = 0;
j < genes_remaining;
j++)
259 {
260
261 if ((
Gene) abs(edge_table[possess_edge].edge_list[
j]) == gene)
262 {
263
265
267 edge_table[possess_edge].
edge_list[genes_remaining - 1];
268
269 break;
270 }
271 }
272 }
273}
References Edge::edge_list, i, j, and Edge::unused_edges.
Referenced by gimme_tour().