PostgreSQL Source Code
git master
Toggle main menu visibility
Main Page
Related Pages
Namespaces
Namespace List
Namespace Members
All
a
c
d
g
h
i
k
l
m
p
r
s
t
Functions
Variables
Data Structures
Data Structures
Data Structure Index
Class Hierarchy
Data Fields
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
_
a
c
d
f
h
i
n
o
p
r
s
t
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Enumerations
Files
File List
Globals
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Enumerations
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
Enumerator
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Macros
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
•
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Pages
geqo_misc.c
Go to the documentation of this file.
1
/*------------------------------------------------------------------------
2
*
3
* geqo_misc.c
4
* misc. printout and debug stuff
5
*
6
* Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
7
* Portions Copyright (c) 1994, Regents of the University of California
8
*
9
* src/backend/optimizer/geqo/geqo_misc.c
10
*
11
*-------------------------------------------------------------------------
12
*/
13
14
/* contributed by:
15
=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
16
* Martin Utesch * Institute of Automatic Control *
17
= = University of Mining and Technology =
18
* utesch@aut.tu-freiberg.de * Freiberg, Germany *
19
=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
20
*/
21
22
#include "
postgres.h
"
23
24
#include "
optimizer/geqo_misc.h
"
25
26
27
#ifdef GEQO_DEBUG
28
29
30
/*
31
* avg_pool
32
*/
33
static
double
34
avg_pool(
Pool
*pool)
35
{
36
int
i
;
37
double
cumulative = 0.0;
38
39
if
(pool->
size
<= 0)
40
elog
(
ERROR
,
"pool_size is zero"
);
41
42
/*
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.
47
*/
48
for
(
i
= 0;
i
< pool->
size
;
i
++)
49
cumulative += pool->
data
[
i
].
worth
/ pool->
size
;
50
51
return
cumulative;
52
}
53
54
/* print_pool
55
*/
56
void
57
print_pool(FILE *fp,
Pool
*pool,
int
start
,
int
stop)
58
{
59
int
i
,
60
j
;
61
62
/* be extra careful that start and stop are valid inputs */
63
64
if
(
start
< 0)
65
start
= 0;
66
if
(stop > pool->
size
)
67
stop = pool->
size
;
68
69
if
(
start
+ stop > pool->
size
)
70
{
71
start
= 0;
72
stop = pool->
size
;
73
}
74
75
for
(
i
=
start
;
i
< stop;
i
++)
76
{
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
);
81
}
82
83
fflush(fp);
84
}
85
86
/* print_gen
87
*
88
* printout for chromosome: best, worst, mean, average
89
*/
90
void
91
print_gen(FILE *fp,
Pool
*pool,
int
generation)
92
{
93
int
lowest;
94
95
/* Get index to lowest ranking gene in population. */
96
/* Use 2nd to last since last is buffer. */
97
lowest = pool->
size
> 1 ? pool->
size
- 2 : 0;
98
99
fprintf
(fp,
100
"%5d | Best: %g Worst: %g Mean: %g Avg: %g\n"
,
101
generation,
102
pool->
data
[0].
worth
,
103
pool->
data
[lowest].
worth
,
104
pool->
data
[pool->
size
/ 2].
worth
,
105
avg_pool(pool));
106
107
fflush(fp);
108
}
109
110
111
void
112
print_edge_table(FILE *fp,
Edge
*edge_table,
int
num_gene)
113
{
114
int
i
,
115
j
;
116
117
fprintf
(fp,
"\nEDGE TABLE\n"
);
118
119
for
(
i
= 1;
i
<= num_gene;
i
++)
120
{
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
]);
124
fprintf
(fp,
"\n"
);
125
}
126
127
fprintf
(fp,
"\n"
);
128
129
fflush(fp);
130
}
131
132
#endif
/* GEQO_DEBUG */
fprintf
#define fprintf(file, fmt, msg)
Definition:
cubescan.l:21
ERROR
#define ERROR
Definition:
elog.h:39
elog
#define elog(elevel,...)
Definition:
elog.h:225
geqo_misc.h
start
return str start
Definition:
hashfn_unstable.h:282
j
int j
Definition:
isn.c:78
i
int i
Definition:
isn.c:77
postgres.h
Chromosome::worth
Cost worth
Definition:
geqo_gene.h:35
Chromosome::string
Gene * string
Definition:
geqo_gene.h:34
Edge
Definition:
geqo_recombination.h:36
Edge::unused_edges
int unused_edges
Definition:
geqo_recombination.h:39
Pool
Definition:
geqo_gene.h:39
Pool::string_length
int string_length
Definition:
geqo_gene.h:42
Pool::size
int size
Definition:
geqo_gene.h:41
Pool::data
Chromosome * data
Definition:
geqo_gene.h:40
src
backend
optimizer
geqo
geqo_misc.c
Generated on Thu Mar 27 2025 06:13:18 for PostgreSQL Source Code by
1.9.4