Header And Logo

PostgreSQL
| The world's most advanced open source database.

geqo_recombination.h

Go to the documentation of this file.
00001 /*-------------------------------------------------------------------------
00002  *
00003  * geqo_recombination.h
00004  *    prototypes for recombination in the genetic query optimizer
00005  *
00006  * Portions Copyright (c) 1996-2013, PostgreSQL Global Development Group
00007  * Portions Copyright (c) 1994, Regents of the University of California
00008  *
00009  * src/include/optimizer/geqo_recombination.h
00010  *
00011  *-------------------------------------------------------------------------
00012  */
00013 
00014 /* contributed by:
00015    =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
00016    *  Martin Utesch              * Institute of Automatic Control      *
00017    =                             = University of Mining and Technology =
00018    *  [email protected]  * Freiberg, Germany                   *
00019    =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
00020  */
00021 
00022 /* -- parts of this are adapted from D. Whitley's Genitor algorithm -- */
00023 
00024 #ifndef GEQO_RECOMBINATION_H
00025 #define GEQO_RECOMBINATION_H
00026 
00027 #include "optimizer/geqo.h"
00028 
00029 
00030 extern void init_tour(PlannerInfo *root, Gene *tour, int num_gene);
00031 
00032 
00033 /* edge recombination crossover [ERX] */
00034 
00035 typedef struct Edge
00036 {
00037     Gene        edge_list[4];   /* list of edges */
00038     int         total_edges;
00039     int         unused_edges;
00040 } Edge;
00041 
00042 extern Edge *alloc_edge_table(PlannerInfo *root, int num_gene);
00043 extern void free_edge_table(PlannerInfo *root, Edge *edge_table);
00044 
00045 extern float gimme_edge_table(PlannerInfo *root, Gene *tour1, Gene *tour2,
00046                  int num_gene, Edge *edge_table);
00047 
00048 extern int gimme_tour(PlannerInfo *root, Edge *edge_table, Gene *new_gene,
00049            int num_gene);
00050 
00051 
00052 /* partially matched crossover [PMX] */
00053 
00054 #define DAD 1                   /* indicator for gene from dad */
00055 #define MOM 0                   /* indicator for gene from mom */
00056 
00057 extern void pmx(PlannerInfo *root,
00058     Gene *tour1, Gene *tour2,
00059     Gene *offspring, int num_gene);
00060 
00061 
00062 typedef struct City
00063 {
00064     int         tour2_position;
00065     int         tour1_position;
00066     int         used;
00067     int         select_list;
00068 } City;
00069 
00070 extern City *alloc_city_table(PlannerInfo *root, int num_gene);
00071 extern void free_city_table(PlannerInfo *root, City *city_table);
00072 
00073 /* cycle crossover [CX] */
00074 extern int cx(PlannerInfo *root, Gene *tour1, Gene *tour2,
00075    Gene *offspring, int num_gene, City *city_table);
00076 
00077 /* position crossover [PX] */
00078 extern void px(PlannerInfo *root, Gene *tour1, Gene *tour2, Gene *offspring,
00079    int num_gene, City *city_table);
00080 
00081 /* order crossover [OX1] according to Davis */
00082 extern void ox1(PlannerInfo *root, Gene *mom, Gene *dad, Gene *offspring,
00083     int num_gene, City *city_table);
00084 
00085 /* order crossover [OX2] according to Syswerda */
00086 extern void ox2(PlannerInfo *root, Gene *mom, Gene *dad, Gene *offspring,
00087     int num_gene, City *city_table);
00088 
00089 #endif   /* GEQO_RECOMBINATION_H */