PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
geqo_recombination.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * geqo_recombination.h
4  * prototypes for recombination in the genetic query optimizer
5  *
6  * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
7  * Portions Copyright (c) 1994, Regents of the University of California
8  *
9  * src/include/optimizer/geqo_recombination.h
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 /* -- parts of this are adapted from D. Whitley's Genitor algorithm -- */
23 
24 #ifndef GEQO_RECOMBINATION_H
25 #define GEQO_RECOMBINATION_H
26 
27 #include "optimizer/geqo.h"
28 
29 
30 extern void init_tour(PlannerInfo *root, Gene *tour, int num_gene);
31 
32 
33 /* edge recombination crossover [ERX] */
34 
35 typedef struct Edge
36 {
37  Gene edge_list[4]; /* list of edges */
40 } Edge;
41 
42 extern Edge *alloc_edge_table(PlannerInfo *root, int num_gene);
43 extern void free_edge_table(PlannerInfo *root, Edge *edge_table);
44 
45 extern float gimme_edge_table(PlannerInfo *root, Gene *tour1, Gene *tour2,
46  int num_gene, Edge *edge_table);
47 
48 extern int gimme_tour(PlannerInfo *root, Edge *edge_table, Gene *new_gene,
49  int num_gene);
50 
51 
52 /* partially matched crossover [PMX] */
53 
54 #define DAD 1 /* indicator for gene from dad */
55 #define MOM 0 /* indicator for gene from mom */
56 
57 extern void pmx(PlannerInfo *root,
58  Gene *tour1, Gene *tour2,
59  Gene *offspring, int num_gene);
60 
61 
62 typedef struct City
63 {
66  int used;
68 } City;
69 
70 extern City *alloc_city_table(PlannerInfo *root, int num_gene);
71 extern void free_city_table(PlannerInfo *root, City *city_table);
72 
73 /* cycle crossover [CX] */
74 extern int cx(PlannerInfo *root, Gene *tour1, Gene *tour2,
75  Gene *offspring, int num_gene, City *city_table);
76 
77 /* position crossover [PX] */
78 extern void px(PlannerInfo *root, Gene *tour1, Gene *tour2, Gene *offspring,
79  int num_gene, City *city_table);
80 
81 /* order crossover [OX1] according to Davis */
82 extern void ox1(PlannerInfo *root, Gene *mom, Gene *dad, Gene *offspring,
83  int num_gene, City *city_table);
84 
85 /* order crossover [OX2] according to Syswerda */
86 extern void ox2(PlannerInfo *root, Gene *mom, Gene *dad, Gene *offspring,
87  int num_gene, City *city_table);
88 
89 #endif /* GEQO_RECOMBINATION_H */
void free_city_table(PlannerInfo *root, City *city_table)
int Gene
Definition: geqo_gene.h:30
int total_edges
int select_list
int cx(PlannerInfo *root, Gene *tour1, Gene *tour2, Gene *offspring, int num_gene, City *city_table)
Definition: geqo_cx.c:47
Gene edge_list[4]
City * alloc_city_table(PlannerInfo *root, int num_gene)
void init_tour(PlannerInfo *root, Gene *tour, int num_gene)
struct Edge Edge
int tour1_position
int tour2_position
Edge * alloc_edge_table(PlannerInfo *root, int num_gene)
Definition: geqo_erx.c:53
void px(PlannerInfo *root, Gene *tour1, Gene *tour2, Gene *offspring, int num_gene, City *city_table)
Definition: geqo_px.c:46
void ox1(PlannerInfo *root, Gene *mom, Gene *dad, Gene *offspring, int num_gene, City *city_table)
Definition: geqo_ox1.c:46
struct City City
int gimme_tour(PlannerInfo *root, Edge *edge_table, Gene *new_gene, int num_gene)
Definition: geqo_erx.c:193
void ox2(PlannerInfo *root, Gene *mom, Gene *dad, Gene *offspring, int num_gene, City *city_table)
Definition: geqo_ox2.c:46
float gimme_edge_table(PlannerInfo *root, Gene *tour1, Gene *tour2, int num_gene, Edge *edge_table)
Definition: geqo_erx.c:92
void pmx(PlannerInfo *root, Gene *tour1, Gene *tour2, Gene *offspring, int num_gene)
Definition: geqo_pmx.c:46
void free_edge_table(PlannerInfo *root, Edge *edge_table)
Definition: geqo_erx.c:73
int unused_edges