1 /*------------------------------------------------------------------------
4 * misc. printout and debug stuff
6 * Portions Copyright (c) 1996-2013, PostgreSQL Global Development Group
7 * Portions Copyright (c) 1994, Regents of the University of California
9 * src/backend/optimizer/geqo/geqo_misc.c
11 *-------------------------------------------------------------------------
15 =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
16 * Martin Utesch * Institute of Automatic Control *
17 = = University of Mining and Technology =
18 * utesch@aut.tu-freiberg.de * Freiberg, Germany *
19 =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
24 #include "optimizer/geqo_misc.h"
37 double cumulative = 0.0;
40 elog(ERROR, "pool_size is zero");
43 * Since the pool may contain multiple occurrences of DBL_MAX, divide by
44 * pool->size before summing, not after, to avoid overflow. This loses a
45 * little in speed and accuracy, but this routine is only used for debug
46 * printouts, so we don't care that much.
48 for (i = 0; i < pool->size; i++)
49 cumulative += pool->data[i].worth / pool->size;
57 print_pool(FILE *fp, Pool *pool, int start, int stop)
62 /* be extra careful that start and stop are valid inputs */
66 if (stop > pool->size)
69 if (start + stop > pool->size)
75 for (i = start; i < stop; i++)
77 fprintf(fp, "%d)\t", i);
78 for (j = 0; j < pool->string_length; j++)
79 fprintf(fp, "%d ", pool->data[i].string[j]);
80 fprintf(fp, "%g\n", pool->data[i].worth);
88 * printout for chromosome: best, worst, mean, average
91 print_gen(FILE *fp, Pool *pool, int generation)
95 /* Get index to lowest ranking gene in poplulation. */
96 /* Use 2nd to last since last is buffer. */
97 lowest = pool->size > 1 ? pool->size - 2 : 0;
100 "%5d | Best: %g Worst: %g Mean: %g Avg: %g\n",
103 pool->data[lowest].worth,
104 pool->data[pool->size / 2].worth,
112 print_edge_table(FILE *fp, Edge *edge_table, int num_gene)
117 fprintf(fp, "\nEDGE TABLE\n");
119 for (i = 1; i <= num_gene; i++)
121 fprintf(fp, "%d :", i);
122 for (j = 0; j < edge_table[i].unused_edges; j++)
123 fprintf(fp, " %d", edge_table[i].edge_list[j]);
132 #endif /* GEQO_DEBUG */