/src/postgres/src/include/optimizer/geqo_gene.h
Line | Count | Source |
1 | | /*------------------------------------------------------------------------- |
2 | | * |
3 | | * geqo_gene.h |
4 | | * genome representation in optimizer/geqo |
5 | | * |
6 | | * Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group |
7 | | * Portions Copyright (c) 1994, Regents of the University of California |
8 | | * |
9 | | * src/include/optimizer/geqo_gene.h |
10 | | * |
11 | | *------------------------------------------------------------------------- |
12 | | */ |
13 | | |
14 | | /* |
15 | | * contributed by: |
16 | | * =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*= |
17 | | * * Martin Utesch * Institute of Automatic Control * |
18 | | * = = University of Mining and Technology = |
19 | | * * utesch@aut.tu-freiberg.de * Freiberg, Germany * |
20 | | * =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*= |
21 | | */ |
22 | | |
23 | | |
24 | | #ifndef GEQO_GENE_H |
25 | | #define GEQO_GENE_H |
26 | | |
27 | | #include <float.h> |
28 | | #include <limits.h> |
29 | | |
30 | | #include "nodes/nodes.h" |
31 | | |
32 | | /* |
33 | | * we presume that int instead of Relid |
34 | | * is o.k. for Gene; so don't change it! |
35 | | */ |
36 | | typedef int Gene; |
37 | | |
38 | | /* |
39 | | * Fitness of a candidate join order. |
40 | | * |
41 | | * A tour for which no valid plan could be constructed is represented by |
42 | | * disabled_nodes = INT_MAX and cost = DBL_MAX. |
43 | | */ |
44 | | typedef struct Fitness |
45 | | { |
46 | | int disabled_nodes; |
47 | | Cost cost; |
48 | | } Fitness; |
49 | | |
50 | | /* |
51 | | * Is this a valid tour? |
52 | | */ |
53 | | static inline bool |
54 | | fitness_is_valid(Fitness fitness) |
55 | 0 | { |
56 | 0 | return fitness.disabled_nodes < INT_MAX || fitness.cost < DBL_MAX; |
57 | 0 | } Unexecuted instantiation: geqo_copy.c:fitness_is_valid Unexecuted instantiation: geqo_cx.c:fitness_is_valid Unexecuted instantiation: geqo_erx.c:fitness_is_valid Unexecuted instantiation: geqo_eval.c:fitness_is_valid Unexecuted instantiation: geqo_main.c:fitness_is_valid Unexecuted instantiation: geqo_misc.c:fitness_is_valid Unexecuted instantiation: geqo_mutation.c:fitness_is_valid Unexecuted instantiation: geqo_ox1.c:fitness_is_valid Unexecuted instantiation: geqo_ox2.c:fitness_is_valid Unexecuted instantiation: geqo_pmx.c:fitness_is_valid Unexecuted instantiation: geqo_pool.c:fitness_is_valid Unexecuted instantiation: geqo_px.c:fitness_is_valid Unexecuted instantiation: geqo_random.c:fitness_is_valid Unexecuted instantiation: geqo_recombination.c:fitness_is_valid Unexecuted instantiation: geqo_selection.c:fitness_is_valid Unexecuted instantiation: allpaths.c:fitness_is_valid Unexecuted instantiation: guc_tables.c:fitness_is_valid |
58 | | |
59 | | /* |
60 | | * Which fitness is better? |
61 | | */ |
62 | | static inline int |
63 | | fitness_compare(Fitness fitness1, Fitness fitness2) |
64 | 0 | { |
65 | 0 | if (fitness1.disabled_nodes != fitness2.disabled_nodes) |
66 | 0 | return fitness1.disabled_nodes < fitness2.disabled_nodes ? -1 : 1; |
67 | 0 | if (fitness1.cost != fitness2.cost) |
68 | 0 | return fitness1.cost < fitness2.cost ? -1 : 1; |
69 | 0 | return 0; |
70 | 0 | } Unexecuted instantiation: geqo_copy.c:fitness_compare Unexecuted instantiation: geqo_cx.c:fitness_compare Unexecuted instantiation: geqo_erx.c:fitness_compare Unexecuted instantiation: geqo_eval.c:fitness_compare Unexecuted instantiation: geqo_main.c:fitness_compare Unexecuted instantiation: geqo_misc.c:fitness_compare Unexecuted instantiation: geqo_mutation.c:fitness_compare Unexecuted instantiation: geqo_ox1.c:fitness_compare Unexecuted instantiation: geqo_ox2.c:fitness_compare Unexecuted instantiation: geqo_pmx.c:fitness_compare Unexecuted instantiation: geqo_pool.c:fitness_compare Unexecuted instantiation: geqo_px.c:fitness_compare Unexecuted instantiation: geqo_random.c:fitness_compare Unexecuted instantiation: geqo_recombination.c:fitness_compare Unexecuted instantiation: geqo_selection.c:fitness_compare Unexecuted instantiation: allpaths.c:fitness_compare Unexecuted instantiation: guc_tables.c:fitness_compare |
71 | | |
72 | | typedef struct Chromosome |
73 | | { |
74 | | Gene *string; |
75 | | Fitness worth; |
76 | | } Chromosome; |
77 | | |
78 | | typedef struct Pool |
79 | | { |
80 | | Chromosome *data; |
81 | | int size; |
82 | | int string_length; |
83 | | } Pool; |
84 | | |
85 | | #endif /* GEQO_GENE_H */ |