diff options
| author | Marc G. Fournier | 1997-02-19 12:59:07 +0000 |
|---|---|---|
| committer | Marc G. Fournier | 1997-02-19 12:59:07 +0000 |
| commit | 29138eeb3ca299d0fdc3d4ea2cbe523b759c9db0 (patch) | |
| tree | bac9efe5ffc3619cd09d8b920e31209a0d5f9a75 /src/include/optimizer | |
| parent | 34f35a4c19a92d7869e25cdd522366df74285729 (diff) | |
Merge in GEQO Optimizer
From: "Martin S. Utesch" <utesch@aut.tu-freiberg.de>
Diffstat (limited to 'src/include/optimizer')
| -rw-r--r-- | src/include/optimizer/geqo.h | 78 | ||||
| -rw-r--r-- | src/include/optimizer/geqo_copy.h | 27 | ||||
| -rw-r--r-- | src/include/optimizer/geqo_gene.h | 42 | ||||
| -rw-r--r-- | src/include/optimizer/geqo_misc.h | 34 | ||||
| -rw-r--r-- | src/include/optimizer/geqo_mutation.h | 27 | ||||
| -rw-r--r-- | src/include/optimizer/geqo_paths.h | 28 | ||||
| -rw-r--r-- | src/include/optimizer/geqo_pool.h | 37 | ||||
| -rw-r--r-- | src/include/optimizer/geqo_random.h | 37 | ||||
| -rw-r--r-- | src/include/optimizer/geqo_recombination.h | 77 | ||||
| -rw-r--r-- | src/include/optimizer/geqo_selection.h | 28 |
10 files changed, 415 insertions, 0 deletions
diff --git a/src/include/optimizer/geqo.h b/src/include/optimizer/geqo.h new file mode 100644 index 00000000000..b25d443be0a --- /dev/null +++ b/src/include/optimizer/geqo.h @@ -0,0 +1,78 @@ +/*------------------------------------------------------------------------- + * + * geqo.h-- + * prototypes for various files in optimizer/geqo + * + * Copyright (c) 1994, Regents of the University of California + * + * $Id: geqo.h,v 1.1 1997/02/19 12:58:28 scrappy Exp $ + * + *------------------------------------------------------------------------- + */ + +/* contributed by: + =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*= + * Martin Utesch * Institute of Automatic Control * + = = University of Mining and Technology = + * utesch@aut.tu-freiberg.de * Freiberg, Germany * + =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*= + */ + +#ifndef GEQO_H +#define GEQO_H + + +/* GEQO debug flag */ +/* + #define GEQO_DEBUG +*/ + +/* recombination mechanism */ +/* + #define ERX + #define PMX + #define CX + #define PX + #define OX1 + #define OX2 + */ +#define ERX + + +/* genetic algorithm parameters */ + +#define GEQO_FILE "pg_geqo" /* Name of the ga config file */ + +#define MIN_POOL 128 /* minimum number of individuals */ +#define MAX_POOL 1024 /* maximum number of individuals */ + +#define LOW_EFFORT 1 /* optimization effort values */ +#define MEDIUM_EFFORT 40 /* are multipliers for computed */ +#define HIGH_EFFORT 80 /* number of generations */ + +#define SELECTION_BIAS 2.0 /* selective pressure within population */ + /* should be 1.5 <= SELECTION_BIAS <= 2.0 */ + + int PoolSize; + int Generations; + + long RandomSeed; /* defaults to (long) time(NULL) in geqo_params.c */ + double SelectionBias; + +/* logarithmic base for rel->size decrease in case of long + queries that cause an integer overflow; used in geqo_eval.c */ + +#define GEQO_LOG_BASE 1.5 /* should be 1.0 < GEQO_LOG_BASE <= 2.0 */ + /* ^^^ */ + +/* geqo prototypes */ +extern Rel *geqo(Query *root); + +extern void geqo_params(int string_length); + +extern Cost geqo_eval (Query *root, Gene *tour, int num_gene); +double geqo_log(double x, double b); +extern Rel *gimme_tree(Query *root, Gene *tour, int rel_count, int num_gene, Rel *outer_rel); + + +#endif /* GEQO_H */ diff --git a/src/include/optimizer/geqo_copy.h b/src/include/optimizer/geqo_copy.h new file mode 100644 index 00000000000..fcc61791689 --- /dev/null +++ b/src/include/optimizer/geqo_copy.h @@ -0,0 +1,27 @@ +/*------------------------------------------------------------------------- + * + * geqo_copy.h-- + * prototypes for copy functions in optimizer/geqo + * + * Copyright (c) 1994, Regents of the University of California + * + * $Id: geqo_copy.h,v 1.1 1997/02/19 12:58:32 scrappy Exp $ + * + *------------------------------------------------------------------------- + */ + +/* contributed by: + =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*= + * Martin Utesch * Institute of Automatic Control * + = = University of Mining and Technology = + * utesch@aut.tu-freiberg.de * Freiberg, Germany * + =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*= + */ + +#ifndef GEQO_COPY_H +#define GEQO_COPY_H + + +extern void geqo_copy (Chromosome *chromo1, Chromosome *chromo2, int string_length); + +#endif /* GEQO_COPY_H */ diff --git a/src/include/optimizer/geqo_gene.h b/src/include/optimizer/geqo_gene.h new file mode 100644 index 00000000000..3d38bd26f8a --- /dev/null +++ b/src/include/optimizer/geqo_gene.h @@ -0,0 +1,42 @@ +/*------------------------------------------------------------------------- + * + * geqo_gene.h-- + * genome representation in optimizer/geqo + * + * Copyright (c) 1994, Regents of the University of California + * + * $Id: geqo_gene.h,v 1.1 1997/02/19 12:58:37 scrappy Exp $ + * + *------------------------------------------------------------------------- + */ + +/* contributed by: + =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*= + * Martin Utesch * Institute of Automatic Control * + = = University of Mining and Technology = + * utesch@aut.tu-freiberg.de * Freiberg, Germany * + =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*= + */ + + +#ifndef GEQO_GENE_H +#define GEQO_GENE_H + + +/* we presume that int instead of Relid + is o.k. for Gene; so don't change it! */ +typedef +int Gene; + +typedef struct Chromosome { + Gene *string; + Cost worth; +} Chromosome; + +typedef struct Pool { + Chromosome *data; + int size; + int string_length; +} Pool; + +#endif /* GEQO_GENE_H */ diff --git a/src/include/optimizer/geqo_misc.h b/src/include/optimizer/geqo_misc.h new file mode 100644 index 00000000000..904b85123e3 --- /dev/null +++ b/src/include/optimizer/geqo_misc.h @@ -0,0 +1,34 @@ +/*------------------------------------------------------------------------- + * + * geqo_misc.h-- + * prototypes for printout routines in optimizer/geqo + * + * Copyright (c) 1994, Regents of the University of California + * + * $Id: geqo_misc.h,v 1.1 1997/02/19 12:58:41 scrappy Exp $ + * + *------------------------------------------------------------------------- + */ + +/* contributed by: + =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*= + * Martin Utesch * Institute of Automatic Control * + = = University of Mining and Technology = + * utesch@aut.tu-freiberg.de * Freiberg, Germany * + =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*= + */ + +#ifndef GEQO_MISC_H +#define GEQO_MISC_H + +#include <stdio.h> + +extern void print_pool (FILE *fp, Pool *pool, int start, int stop); +extern void print_gen(FILE *fp, Pool *pool, int generation); +extern void print_edge_table (FILE *fp, Edge *edge_table, int num_gene); + +extern void geqo_print_rel(Query *root, Rel *rel); +extern void geqo_print_path(Query *root, Path *path, int indent); +extern void geqo_print_joinclauses(Query *root, List *clauses); + +#endif /* GEQO_MISC_H */ diff --git a/src/include/optimizer/geqo_mutation.h b/src/include/optimizer/geqo_mutation.h new file mode 100644 index 00000000000..91e4b4b5386 --- /dev/null +++ b/src/include/optimizer/geqo_mutation.h @@ -0,0 +1,27 @@ +/*------------------------------------------------------------------------- + * + * geqo_mutation.h-- + * prototypes for mutation functions in optimizer/geqo + * + * Copyright (c) 1994, Regents of the University of California + * + * $Id: geqo_mutation.h,v 1.1 1997/02/19 12:58:49 scrappy Exp $ + * + *------------------------------------------------------------------------- + */ + +/* contributed by: + =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*= + * Martin Utesch * Institute of Automatic Control * + = = University of Mining and Technology = + * utesch@aut.tu-freiberg.de * Freiberg, Germany * + =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*= + */ + +#ifndef GEQO_MUTATION_H +#define GEQO_MUTATION_H + + +extern void geqo_mutation (Gene *tour, int num_gene); + +#endif /* GEQO_MUTATION_H */ diff --git a/src/include/optimizer/geqo_paths.h b/src/include/optimizer/geqo_paths.h new file mode 100644 index 00000000000..c4b890a3dbd --- /dev/null +++ b/src/include/optimizer/geqo_paths.h @@ -0,0 +1,28 @@ +/*------------------------------------------------------------------------- + * + * geqo_paths.h-- + * prototypes for various subroutines in geqo_path.c + * + * Copyright (c) 1994, Regents of the University of California + * + * $Id: geqo_paths.h,v 1.1 1997/02/19 12:58:55 scrappy Exp $ + * + *------------------------------------------------------------------------- + */ + +/* contributed by: + =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*= + * Martin Utesch * Institute of Automatic Control * + = = University of Mining and Technology = + * utesch@aut.tu-freiberg.de * Freiberg, Germany * + =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*= + */ + +#ifndef GEQO_PATHS_H +#define GEQO_PATHS_H + + +extern List *geqo_prune_rels(List *rel_list); +extern void geqo_rel_paths(Rel *rel); + +#endif /* GEQO_PATHS_H */ diff --git a/src/include/optimizer/geqo_pool.h b/src/include/optimizer/geqo_pool.h new file mode 100644 index 00000000000..ba7cb529726 --- /dev/null +++ b/src/include/optimizer/geqo_pool.h @@ -0,0 +1,37 @@ +/*------------------------------------------------------------------------- + * + * geqo_pool.h-- + * pool representation in optimizer/geqo + * + * Copyright (c) 1994, Regents of the University of California + * + * $Id: geqo_pool.h,v 1.1 1997/02/19 12:58:59 scrappy Exp $ + * + *------------------------------------------------------------------------- + */ + +/* contributed by: + =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*= + * Martin Utesch * Institute of Automatic Control * + = = University of Mining and Technology = + * utesch@aut.tu-freiberg.de * Freiberg, Germany * + =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*= + */ + + +#ifndef GEQO_POOL_H +#define GEQO_POOL_H + + +extern Pool *alloc_pool(int pool_size, int string_length); +extern void free_pool(Pool *pool); + +extern void random_init_pool(Query *root, Pool *pool, int strt, int stop); +extern Chromosome *alloc_chromo(int string_length); +extern void free_chromo(Chromosome *chromo); + +extern void spread_chromo(Chromosome *chromo, Pool *pool); + +extern void sort_pool (Pool *pool); + +#endif /* GEQO_POOL_H */ diff --git a/src/include/optimizer/geqo_random.h b/src/include/optimizer/geqo_random.h new file mode 100644 index 00000000000..9bb3affe725 --- /dev/null +++ b/src/include/optimizer/geqo_random.h @@ -0,0 +1,37 @@ +/*------------------------------------------------------------------------- + * + * geqo_random.h-- + * random number generator + * + * Copyright (c) 1994, Regents of the University of California + * + * $Id: geqo_random.h,v 1.1 1997/02/19 12:59:02 scrappy Exp $ + * + *------------------------------------------------------------------------- + */ + +/* contributed by: + =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*= + * Martin Utesch * Institute of Automatic Control * + = = University of Mining and Technology = + * utesch@aut.tu-freiberg.de * Freiberg, Germany * + =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*= + */ + +/* -- parts of this are adapted from D. Whitley's Genitor algorithm -- */ + +#ifndef GEQO_RANDOM_H +#define GEQO_RANDOM_H + +#include <math.h> + +#define MASK 2147483647 + +#define geqo_rand() ((double)random()/MASK) + +/* geqo_randint returns integer value + between lower and upper inclusive */ + +#define geqo_randint(upper,lower) ( (int) floor( geqo_rand()*((upper-lower)+0.999999) ) + lower ) + +#endif /* GEQO_RANDOM_H */ diff --git a/src/include/optimizer/geqo_recombination.h b/src/include/optimizer/geqo_recombination.h new file mode 100644 index 00000000000..baa7fc24fa4 --- /dev/null +++ b/src/include/optimizer/geqo_recombination.h @@ -0,0 +1,77 @@ +/*------------------------------------------------------------------------- + * + * geqo_recombination.h-- + * prototypes for recombination in the genetic query optimizer + * + * Copyright (c) 1994, Regents of the University of California + * + * $Id: geqo_recombination.h,v 1.1 1997/02/19 12:59:04 scrappy Exp $ + * + *------------------------------------------------------------------------- + */ + +/* contributed by: + =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*= + * Martin Utesch * Institute of Automatic Control * + = = University of Mining and Technology = + * utesch@aut.tu-freiberg.de * Freiberg, Germany * + =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*= + */ + +/* -- parts of this are adapted from D. Whitley's Genitor algorithm -- */ + +#ifndef GEQO_RECOMBINATION_H +#define GEQO_RECOMBINATION_H + + +extern void init_tour(Gene *tour, int num_gene); + + +/* edge recombination crossover [ERX] */ + +typedef struct Edge { + Gene edge_list[4]; /* list of edges */ + int total_edges; + int unused_edges; +} Edge; + +extern Edge *alloc_edge_table(int num_gene); +extern void free_edge_table(Edge *edge_table); + +extern float gimme_edge_table (Gene *tour1, Gene *tour2, int num_gene, Edge *edge_table); + +extern int gimme_tour(Edge *edge_table, Gene *new_gene, int num_gene); + + +/* partially matched crossover [PMX] */ + +#define DAD 1 /* indicator for gene from dad */ +#define MOM 0 /* indicator for gene from mom */ + +extern void pmx(Gene *tour1, Gene *tour2, Gene *offspring, int num_gene); + + +typedef struct City { + int tour2_position; + int tour1_position; + int used; + int select_list; +} City; + +extern City *alloc_city_table(int num_gene); +extern void free_city_table(City *city_table); + +/* cycle crossover [CX] */ +extern int cx(Gene *tour1, Gene *tour2, Gene *offspring, int num_gene, City *city_table); + +/* position crossover [PX] */ +extern void px(Gene *tour1, Gene *tour2, Gene *offspring, int num_gene, City *city_table); + +/* order crossover [OX1] according to Davis */ +extern void ox1(Gene *mom, Gene *dad, Gene *offspring, int num_gene, City *city_table); + +/* order crossover [OX2] according to Syswerda */ +extern void ox2(Gene *mom, Gene *dad, Gene *offspring, int num_gene, City *city_table); + + +#endif /* GEQO_RECOMBINATION_H */ diff --git a/src/include/optimizer/geqo_selection.h b/src/include/optimizer/geqo_selection.h new file mode 100644 index 00000000000..8f3c22170f1 --- /dev/null +++ b/src/include/optimizer/geqo_selection.h @@ -0,0 +1,28 @@ +/*------------------------------------------------------------------------- + * + * geqo_selection.h-- + * prototypes for selection routines in optimizer/geqo + * + * Copyright (c) 1994, Regents of the University of California + * + * $Id: geqo_selection.h,v 1.1 1997/02/19 12:59:07 scrappy Exp $ + * + *------------------------------------------------------------------------- + */ + +/* contributed by: + =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*= + * Martin Utesch * Institute of Automatic Control * + = = University of Mining and Technology = + * utesch@aut.tu-freiberg.de * Freiberg, Germany * + =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*= + */ + + +#ifndef GEQO_SELECTION_H +#define GEQO_SELECTION_H + + +extern void geqo_selection (Chromosome *momma, Chromosome *daddy, Pool *pool, double bias); + +#endif /* GEQO_SELECTION_H */ |
