1 /*------------------------------------------------------------------------
4 * misc. printout and debug stuff
6 * Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
7 * Portions Copyright (c) 1994, Regents of the University of California
9 * $PostgreSQL: pgsql/src/backend/optimizer/geqo/geqo_misc.c,v 1.41 2004/08/29 04:12:33 momjian Exp $
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"
25 #include "nodes/print.h"
38 double cumulative = 0.0;
41 elog(ERROR, "pool_size is zero");
44 * Since the pool may contain multiple occurrences of DBL_MAX, divide
45 * by pool->size before summing, not after, to avoid overflow. This
46 * loses a little in speed and accuracy, but this routine is only used
47 * for debug printouts, so we don't care that much.
49 for (i = 0; i < pool->size; i++)
50 cumulative += pool->data[i].worth / pool->size;
58 print_pool(FILE *fp, Pool *pool, int start, int stop)
63 /* be extra careful that start and stop are valid inputs */
67 if (stop > pool->size)
70 if (start + stop > pool->size)
76 for (i = start; i < stop; i++)
78 fprintf(fp, "%d)\t", i);
79 for (j = 0; j < pool->string_length; j++)
80 fprintf(fp, "%d ", pool->data[i].string[j]);
81 fprintf(fp, "%g\n", pool->data[i].worth);
89 * printout for chromosome: best, worst, mean, average
92 print_gen(FILE *fp, Pool *pool, int generation)
96 /* Get index to lowest ranking gene in poplulation. */
97 /* Use 2nd to last since last is buffer. */
98 lowest = pool->size > 1 ? pool->size - 2 : 0;
101 "%5d | Best: %g Worst: %g Mean: %g Avg: %g\n",
104 pool->data[lowest].worth,
105 pool->data[pool->size / 2].worth,
113 print_edge_table(FILE *fp, Edge *edge_table, int num_gene)
118 fprintf(fp, "\nEDGE TABLE\n");
120 for (i = 1; i <= num_gene; i++)
122 fprintf(fp, "%d :", i);
123 for (j = 0; j < edge_table[i].unused_edges; j++)
124 fprintf(fp, " %d", edge_table[i].edge_list[j]);
133 #endif /* GEQO_DEBUG */