1 /**********************************************************************
2   gaul.h
3  **********************************************************************
4 
5   gaul - Genetic Algorithm Utility Library.
6   Copyright ©2000-2005, Stewart Adcock <stewart@linux-domain.com>
7   All rights reserved.
8 
9   The latest version of this program should be available at:
10   http://gaul.sourceforge.net/
11 
12   This program is free software; you can redistribute it and/or modify
13   it under the terms of the GNU General Public License as published by
14   the Free Software Foundation; either version 2 of the License, or
15   (at your option) any later version.  Alternatively, if your project
16   is incompatible with the GPL, I will probably agree to requests
17   for permission to use the terms of any other license.
18 
19   This program is distributed in the hope that it will be useful, but
20   WITHOUT ANY WARRANTY WHATSOEVER.
21 
22   A full copy of the GNU General Public License should be in the file
23   "COPYING" provided with this distribution; if not, see:
24   http://www.gnu.org/
25 
26  **********************************************************************
27 
28   Synopsis:	Public header file for GAUL.
29 
30 		This file should be included by any code that will
31 		be linking to libgaul.
32 
33  **********************************************************************/
34 
35 #ifndef GAUL_H_INCLUDED
36 #define GAUL_H_INCLUDED
37 
38 /**********************************************************************
39  * Include requisite headers.
40  **********************************************************************/
41 
42 #include "gaul/gaul_util.h"	/* General header containing commonly
43 				   used convenience definitions.
44 				   This also includes a platform-
45 				   specific configuration file. */
46 
47 /*
48  * Portable programming utilities.
49  */
50 #include "gaul/compatibility.h"      /* For portability stuff. */
51 #include "gaul/linkedlist.h"         /* For linked lists. */
52 #include "gaul/log_util.h"           /* For logging facilities. */
53 #include "gaul/memory_util.h"        /* Memory handling. */
54 #include "gaul/random_util.h"        /* For PRNGs. */
55 #include "gaul/table_util.h"         /* Handling unique integer ids. */
56 
57 
58 /**********************************************************************
59  * Forward declarations.
60  **********************************************************************/
61 
62 /* The entity datatype stores single individuals. */
63 typedef struct entity_t entity;
64 /* The population datatype stores single populations. */
65 typedef struct population_t population;
66 
67 /**********************************************************************
68  * Enumerated types, used to define varients of the GA algorithms.
69  **********************************************************************/
70 
71 /*
72  * Evolutionary mode.
73  */
74 typedef enum ga_scheme_type_t
75   {
76   GA_SCHEME_DARWIN = 0,
77   GA_SCHEME_LAMARCK_PARENTS = 1,
78   GA_SCHEME_LAMARCK_CHILDREN = 2,
79   GA_SCHEME_LAMARCK_ALL = 3,
80   GA_SCHEME_BALDWIN_PARENTS = 4,
81   GA_SCHEME_BALDWIN_CHILDREN = 8,
82   GA_SCHEME_BALDWIN_ALL = 12
83   } ga_scheme_type;
84 
85 /*
86  * Elitism mode.
87  */
88 typedef enum ga_elitism_type_t
89   {
90   GA_ELITISM_UNKNOWN = 0,
91   GA_ELITISM_NULL = 0,
92   GA_ELITISM_PARENTS_SURVIVE = 1,
93   GA_ELITISM_ONE_PARENT_SURVIVES = 2,
94   GA_ELITISM_PARENTS_DIE = 3,
95   GA_ELITISM_RESCORE_PARENTS = 4
96   } ga_elitism_type;
97 
98 /*
99  * Stategies available with Differential Evolution implementation.
100  */
101 typedef enum de_strategy_t
102   {
103   GA_DE_STRATEGY_UNKNOWN = 0,
104   GA_DE_STRATEGY_BEST = 1,
105   GA_DE_STRATEGY_RAND = 2,
106   GA_DE_STRATEGY_RANDTOBEST = 3
107   } ga_de_strategy_type;
108 
109 typedef enum de_crossover_t
110   {
111   GA_DE_CROSSOVER_UNKNOWN = 0,
112   GA_DE_CROSSOVER_BINOMIAL = 1,
113   GA_DE_CROSSOVER_EXPONENTIAL = 2
114   } ga_de_crossover_type;
115 
116 /**********************************************************************
117  * Callback function typedefs.
118  **********************************************************************/
119 /*
120  * Analysis and termination.
121  */
122 /* GAgeneration_hook is called at the beginning of each generation by
123  * all evolutionary functions. */
124 typedef boolean (*GAgeneration_hook)(const int generation, population *pop);
125 /* GAiteration_hook is called at the beginning of each iteration by
126  * all non-evolutionary functions. */
127 typedef boolean (*GAiteration_hook)(const int iteration, entity *entity);
128 
129 /*
130  * Phenome (A general purpose data cache) handling.
131  */
132 /* GAdata_destructor is used to deallocate phenomic data. */
133 typedef void    (*GAdata_destructor)(vpointer data);
134 /* GAdata_ref_incrementor is used for reference counting of phenomic data. */
135 typedef void    (*GAdata_ref_incrementor)(vpointer data);
136 
137 /*
138  * Genome handling.
139  */
140 /* GAchromosome_constructor is used to allocate single chromosomes. */
141 typedef boolean (*GAchromosome_constructor)(population *pop, entity *entity);
142 /* GAchromosome_destructor is used to deallocate single chromosomes. */
143 typedef void    (*GAchromosome_destructor)(population *pop, entity *entity);
144 /* GAchromosome_replicate is used to clone single chromosomes. */
145 typedef void    (*GAchromosome_replicate)(const population *pop, entity *parent, entity *child, const int chromosomeid);
146 /* GAchromosome_to_bytes is used to pack genomic data into a
147  * contiguous block of memory. */
148 typedef unsigned int    (*GAchromosome_to_bytes)(const population *pop, entity *joe, byte **bytes, unsigned int *max_bytes);
149 /* GAchromosome_from_bytes is used to unpack genomic data from a
150  * contiguous block of memory. */
151 typedef void    (*GAchromosome_from_bytes)(const population *pop, entity *joe, byte *bytes);
152 /* GAchromosome_to_string is used to generate a human readable
153  * representation of genomic data. */
154 typedef char    *(*GAchromosome_to_string)(const population *pop, const entity *joe, char *text, size_t *textlen);
155 
156 /*
157  * GA operations.
158  *
159  * FIXME: Adaptation prototype should match the mutation prototype so that
160  * the adaptation local optimisation algorithms may be used as mutation
161  * operators.
162  */
163 /* GAevaluate determines the fitness of an entity. */
164 typedef boolean (*GAevaluate)(population *pop, entity *entity);
165 /* GAseed initialises the genomic contents of an entity. */
166 typedef boolean	(*GAseed)(population *pop, entity *adam);
167 /* GAadapt optimises/performs learning for an entity. */
168 typedef entity *(*GAadapt)(population *pop, entity *child);
169 /* GAselect_one selects a single entity from the population. */
170 typedef boolean (*GAselect_one)(population *pop, entity **mother);
171 /* GAselect_two selects a pair of entities from the population. */
172 typedef boolean (*GAselect_two)(population *pop, entity **mother, entity **father);
173 /* GAmutate introduces a mutation into an entity. */
174 typedef void    (*GAmutate)(population *pop, entity *mother, entity *daughter);
175 /* GAcrossover produces two new sets of chromosomes from two parent sets. */
176 typedef void    (*GAcrossover)(population *pop, entity *mother, entity *father, entity *daughter, entity *son);
177 /* GAreplace inserts a new entity into the population. */
178 typedef void    (*GAreplace)(population *pop, entity *child);
179 /* GArank Compare two entities and return 1, 0, or -1, if alpha should rank higher,
180  * they should have equal rank, or beta should rank higher. */
181 typedef int	(*GArank)(population *alphapop, entity *alpha, population *betapop, entity *beta);
182 
183 /*
184  * Alternative heuristic search function operations.
185  *
186  * GAtabu_accept     - Tabu-search tabu+aspiration criteria.
187  * GAsa_accept       - Simulated Annealing acceptance criteria.
188  * GAmutate_allele   - Mutate a single, specified, allele.
189  * GAto_double       - Map chromosomal data to double-precision float array.
190  * GAfrom_double     - Map chromosomal data from double-precision float array.
191  * GAgradient        - Return array of gradients.
192  * GAscan_chromosome - Produce next permutation of genome.
193  * GAcompare         - Compare two entities and return distance.
194  */
195 typedef boolean	(*GAtabu_accept)(population *pop, entity *putative, entity *tabu);
196 typedef boolean	(*GAsa_accept)(population *pop, entity *current, entity *trial);
197 typedef boolean	(*GAmutate_allele)(population *pop, entity *parent, entity *child, const int chromosomeid, const int alleleid);
198 typedef boolean	(*GAto_double)(population *pop, entity *entity, double *darray);
199 typedef boolean	(*GAfrom_double)(population *pop, entity *entity, double *darray);
200 typedef double	(*GAgradient)(population *pop, entity *entity, double *darray, double *varray);
201 typedef boolean	(*GAscan_chromosome)(population *pop, entity *entity, int enumeration_num);
202 typedef double	(*GAcompare)(population *pop, entity *alpha, entity *beta);
203 
204 /**********************************************************************
205  * Public prototypes.
206  **********************************************************************/
207 
208 /*
209  * Functions located in ga_core.c:
210  * (Basic entity and population handling)
211  */
212 FUNCPROTO population *ga_population_new(	const int stable_size,
213 				const int num_chromosome,
214 				const int len_chromosome);
215 FUNCPROTO population *ga_population_clone_empty( population *pop );
216 FUNCPROTO population *ga_population_clone( population *pop );
217 FUNCPROTO int	ga_get_num_populations(void);
218 FUNCPROTO population *ga_get_population_from_id(unsigned int id);
219 FUNCPROTO unsigned int ga_get_population_id(population *pop);
220 FUNCPROTO unsigned int *ga_get_all_population_ids(void);
221 FUNCPROTO population **ga_get_all_populations(void);
222 FUNCPROTO boolean	ga_entity_seed(population *pop, entity *e);
223 FUNCPROTO boolean ga_population_seed(population *pop);
224 FUNCPROTO double	ga_entity_evaluate(population *pop, entity *entity);
225 FUNCPROTO boolean	ga_population_score_and_sort(population *pop);
226 FUNCPROTO boolean	ga_population_sort(population *pop);
227 FUNCPROTO int ga_get_entity_rank(population *pop, entity *e);
228 FUNCPROTO int ga_get_entity_id(population *pop, entity *e);
229 FUNCPROTO entity *ga_get_entity_from_id(population *pop, const unsigned int id);
230 FUNCPROTO entity *ga_get_entity_from_rank(population *pop, const unsigned int rank);
231 FUNCPROTO int	ga_get_entity_rank_from_id(population *pop, int id);
232 FUNCPROTO int	ga_get_entity_id_from_rank(population *pop, int rank);
233 FUNCPROTO boolean	ga_entity_dereference_by_rank(population *pop, int rank);
234 FUNCPROTO boolean ga_entity_dereference(population *p, entity *dying);
235 FUNCPROTO boolean ga_entity_dereference_by_id(population *pop, int id);
236 FUNCPROTO void ga_entity_clear_data(population *p, entity *entity, const int chromosome);
237 FUNCPROTO void ga_entity_blank(population *p, entity *entity);
238 FUNCPROTO entity *ga_get_free_entity(population *pop);
239 FUNCPROTO boolean ga_copy_data(population *pop, entity *dest, entity *src, const int chromosome);
240 FUNCPROTO boolean ga_entity_copy_all_chromosomes(population *pop, entity *dest, entity *src);
241 FUNCPROTO boolean ga_entity_copy_chromosome(population *pop, entity *dest, entity *src, int chromo);
242 FUNCPROTO boolean ga_entity_copy(population *pop, entity *dest, entity *src);
243 FUNCPROTO entity	*ga_entity_clone(population *pop, entity *parent);
244 
245 FUNCPROTO void ga_population_send_by_mask( population *pop, int dest_node, int num_to_send, boolean *send_mask );
246 FUNCPROTO void ga_population_send_every( population *pop, int dest_node );
247 FUNCPROTO void ga_population_append_receive( population *pop, int src_node );
248 FUNCPROTO population *ga_population_new_receive( int src_node );
249 FUNCPROTO population *ga_population_receive( int src_node );
250 FUNCPROTO void ga_population_send( population *pop, int dest_node );
251 FUNCPROTO void ga_population_send_all( population *pop, int dest_node );
252 
253 FUNCPROTO entity	*ga_optimise_entity(population *pop, entity *unopt);
254 FUNCPROTO void	ga_population_set_parameters(  population            *pop,
255 		                       const ga_scheme_type  scheme,
256 		                       const ga_elitism_type elitism,
257 		                       const double          crossover,
258 		                       const double          mutation,
259 		                       const double          migration);
260 FUNCPROTO void	ga_population_set_scheme(      population            *pop,
261 		                       const ga_scheme_type  scheme);
262 FUNCPROTO void	ga_population_set_elitism(     population            *pop,
263 		                       const ga_elitism_type elitism);
264 FUNCPROTO void	ga_population_set_crossover(   population            *pop,
265 		                       const double          crossover);
266 FUNCPROTO void	ga_population_set_mutation(    population            *pop,
267 		                       const double          mutation);
268 FUNCPROTO void	ga_population_set_migration(   population            *pop,
269 		                       const double          migration);
270 FUNCPROTO void	ga_population_set_allele_mutation_prob(   population            *pop,
271 		                       const double          prob);
272 FUNCPROTO void	ga_population_set_allele_min_integer(   population            *pop,
273 		                       const int          value);
274 FUNCPROTO void	ga_population_set_allele_max_integer(   population            *pop,
275 		                       const int          value);
276 FUNCPROTO void	ga_population_set_allele_min_double(   population            *pop,
277 		                       const double          value);
278 FUNCPROTO void	ga_population_set_allele_max_double(   population            *pop,
279 		                       const double          value);
280 FUNCPROTO double ga_population_get_crossover(population       *pop);
281 FUNCPROTO double ga_population_get_mutation(population       *pop);
282 FUNCPROTO double ga_population_get_migration(population       *pop);
283 FUNCPROTO double ga_population_get_allele_mutation_prob(population       *pop);
284 FUNCPROTO int ga_population_get_allele_min_integer(population       *pop);
285 FUNCPROTO int ga_population_get_allele_max_integer(population       *pop);
286 FUNCPROTO double ga_population_get_allele_min_double(population       *pop);
287 FUNCPROTO double ga_population_get_allele_max_double(population       *pop);
288 FUNCPROTO ga_scheme_type ga_population_get_scheme(population       *pop);
289 FUNCPROTO ga_elitism_type ga_population_get_elitism(population       *pop);
290 FUNCPROTO population *ga_transcend(unsigned int id);
291 FUNCPROTO unsigned int ga_resurect(population *pop);
292 FUNCPROTO boolean ga_extinction(population *extinct);
293 FUNCPROTO boolean ga_genocide(population *pop, int target_size);
294 FUNCPROTO boolean ga_genocide_by_fitness(population *pop, double target_fitness);
295 FUNCPROTO boolean ga_population_set_data(population *pop, vpointer data);
296 FUNCPROTO vpointer ga_population_get_data(population *pop);
297 FUNCPROTO boolean ga_entity_set_data(population *pop, entity *e, SLList *data);
298 FUNCPROTO SLList	*ga_entity_get_data(population *pop, entity *e);
299 FUNCPROTO int	ga_population_get_generation(population *pop);
300 
301 FUNCPROTO double	ga_entity_get_fitness(entity *e);
302 FUNCPROTO boolean	ga_entity_set_fitness(entity *e, double fitness);
303 FUNCPROTO int	ga_population_get_stablesize(population *pop);
304 FUNCPROTO int	ga_population_get_size(population *pop);
305 FUNCPROTO int	ga_population_get_maxsize(population *pop);
306 FUNCPROTO boolean	ga_population_set_stablesize(population *pop, int stable_size);
307 
308 FUNCPROTO int	ga_funclookup_ptr_to_id(void *func);
309 FUNCPROTO int	ga_funclookup_label_to_id(char *funcname);
310 FUNCPROTO void	*ga_funclookup_label_to_ptr(char *funcname);
311 FUNCPROTO void	*ga_funclookup_id_to_ptr(int id);
312 FUNCPROTO char	*ga_funclookup_id_to_label(int id);
313 FUNCPROTO void	ga_init_openmp( void );
314 
315 /*
316  * Functions located in ga_io.c:
317  * (Disk I/O)
318  */
319 FUNCPROTO boolean ga_population_write(population *pop, char *fname);
320 FUNCPROTO population *ga_population_read(char *fname);
321 FUNCPROTO boolean ga_entity_write(population *pop, entity *entity, char *fname);
322 FUNCPROTO entity *ga_entity_read(population *pop, char *fname);
323 
324 /*
325  * Functions located in ga_select.c:
326  * (Selection operators)
327  */
328 FUNCPROTO boolean ga_select_one_random(population *pop, entity **mother);
329 FUNCPROTO boolean ga_select_two_random(population *pop, entity **mother, entity **father);
330 FUNCPROTO boolean ga_select_one_every(population *pop, entity **mother);
331 FUNCPROTO boolean ga_select_two_every(population *pop, entity **mother, entity **father);
332 FUNCPROTO boolean	ga_select_one_randomrank(population *pop, entity **mother);
333 FUNCPROTO boolean ga_select_two_randomrank(population *pop, entity **mother, entity **father);
334 FUNCPROTO boolean ga_select_one_bestof2(population *pop, entity **mother);
335 FUNCPROTO boolean ga_select_two_bestof2(population *pop, entity **mother, entity **father);
336 FUNCPROTO boolean ga_select_one_bestof3(population *pop, entity **mother);
337 FUNCPROTO boolean ga_select_two_bestof3(population *pop, entity **mother, entity **father);
338 FUNCPROTO boolean	ga_select_one_roulette( population *pop, entity **mother );
339 FUNCPROTO boolean	ga_select_two_roulette( population *pop, entity **mother, entity **father );
340 FUNCPROTO boolean	ga_select_one_roulette_rebased( population *pop, entity **mother );
341 FUNCPROTO boolean	ga_select_two_roulette_rebased( population *pop, entity **mother, entity **father );
342 FUNCPROTO boolean	ga_select_one_sus( population *pop, entity **mother );
343 FUNCPROTO boolean	ga_select_two_sus( population *pop, entity **mother, entity **father );
344 FUNCPROTO boolean	ga_select_one_sussq( population *pop, entity **mother );
345 FUNCPROTO boolean	ga_select_two_sussq( population *pop, entity **mother, entity **father );
346 FUNCPROTO boolean	ga_select_one_aggressive( population *pop, entity **mother );
347 FUNCPROTO boolean	ga_select_two_aggressive( population *pop, entity **mother, entity **father );
348 FUNCPROTO boolean	ga_select_one_best( population *pop, entity **mother );
349 FUNCPROTO boolean	ga_select_two_best( population *pop, entity **mother, entity **father );
350 FUNCPROTO boolean ga_select_one_linearrank( population *pop, entity **mother );
351 FUNCPROTO boolean ga_select_two_linearrank( population *pop, entity **mother, entity **father );
352 FUNCPROTO boolean ga_select_one_roundrobin( population *pop, entity **mother );
353 
354 /*
355  * Functions located in ga_crossover.c:
356  * (Crossover operators)
357  */
358 FUNCPROTO void	ga_crossover_integer_singlepoints(population *pop, entity *father, entity *mother, entity *son, entity *daughter);
359 FUNCPROTO void	ga_crossover_integer_doublepoints(population *pop, entity *father, entity *mother, entity *son, entity *daughter);
360 FUNCPROTO void	ga_crossover_integer_mean(population *pop, entity *father, entity *mother, entity *son, entity *daughter);
361 FUNCPROTO void	ga_crossover_integer_mixing(population *pop, entity *father, entity *mother, entity *son, entity *daughter);
362 FUNCPROTO void	ga_crossover_integer_allele_mixing( population *pop,
363                                  entity *father, entity *mother,
364                                   entity *son, entity *daughter );
365 FUNCPROTO void	ga_crossover_boolean_singlepoints(population *pop, entity *father, entity *mother, entity *son, entity *daughter);
366 FUNCPROTO void	ga_crossover_boolean_doublepoints(population *pop, entity *father, entity *mother, entity *son, entity *daughter);
367 FUNCPROTO void	ga_crossover_boolean_mixing(population *pop, entity *father, entity *mother, entity *son, entity *daughter);
368 FUNCPROTO void	ga_crossover_boolean_allele_mixing( population *pop,
369                                  entity *father, entity *mother,
370                                   entity *son, entity *daughter );
371 FUNCPROTO void	ga_crossover_char_singlepoints( population *pop,
372                                      entity *father, entity *mother,
373                                           entity *son, entity *daughter );
374 FUNCPROTO void	ga_crossover_char_doublepoints( population *pop,
375                                     entity *father, entity *mother,
376                                     entity *son, entity *daughter );
377 FUNCPROTO void	ga_crossover_char_mixing(population *pop, entity *father, entity *mother, entity *son, entity *daughter);
378 FUNCPROTO void	ga_crossover_char_allele_mixing( population *pop,
379 	                                 entity *father, entity *mother,
380                                   entity *son, entity *daughter );
381 FUNCPROTO void	ga_crossover_double_singlepoints( population *pop,
382                                        entity *father, entity *mother,
383                                        entity *son, entity *daughter );
384 FUNCPROTO void	ga_crossover_double_doublepoints( population *pop,
385                                         entity *father, entity *mother,
386                                        entity *son, entity *daughter );
387 FUNCPROTO void	ga_crossover_double_mixing(population *pop, entity *father, entity *mother, entity *son, entity *daughter);
388 FUNCPROTO void	ga_crossover_double_mean(population *pop, entity *father, entity *mother, entity *son, entity *daughter);
389 FUNCPROTO void	ga_crossover_double_allele_mixing( population *pop,
390                                 entity *father, entity *mother,
391                                  entity *son, entity *daughter );
392 FUNCPROTO void	ga_crossover_bitstring_singlepoints(population *pop, entity *father, entity *mother, entity *son, entity *daughter);
393 FUNCPROTO void	ga_crossover_bitstring_doublepoints(population *pop, entity *father, entity *mother, entity *son, entity *daughter);
394 FUNCPROTO void	ga_crossover_bitstring_mixing(population *pop, entity *father, entity *mother, entity *son, entity *daughter);
395 FUNCPROTO void	ga_crossover_bitstring_allele_mixing( population *pop,
396                                 entity *father, entity *mother,
397                                 entity *son, entity *daughter );
398 
399 /*
400  * Functions located in ga_mutate.c:
401  * (Mutation operators)
402  */
403 FUNCPROTO void	ga_mutate_integer_singlepoint_drift(population *pop, entity *father, entity *son);
404 FUNCPROTO void	ga_mutate_integer_singlepoint_randomize(population *pop, entity *father, entity *son);
405 FUNCPROTO void	ga_mutate_integer_multipoint(population *pop, entity *father, entity *son);
406 FUNCPROTO void	ga_mutate_integer_allpoint(population *pop, entity *father, entity *son);
407 FUNCPROTO void	ga_mutate_boolean_singlepoint(population *pop, entity *father, entity *son);
408 FUNCPROTO void	ga_mutate_boolean_multipoint(population *pop, entity *father, entity *son);
409 FUNCPROTO void	ga_mutate_char_singlepoint_drift(population *pop, entity *father, entity *son);
410 FUNCPROTO void	ga_mutate_char_singlepoint_randomize(population *pop, entity *father, entity *son);
411 FUNCPROTO void	ga_mutate_char_allpoint(population *pop, entity *father, entity *son);
412 FUNCPROTO void	ga_mutate_char_multipoint(population *pop, entity *father, entity *son);
413 FUNCPROTO void	ga_mutate_printable_singlepoint_drift(population *pop, entity *father, entity *son);
414 FUNCPROTO void	ga_mutate_printable_singlepoint_randomize(population *pop, entity *father, entity *son);
415 FUNCPROTO void	ga_mutate_printable_allpoint(population *pop, entity *father, entity *son);
416 FUNCPROTO void	ga_mutate_printable_multipoint(population *pop, entity *father, entity *son);
417 FUNCPROTO void	ga_mutate_bitstring_singlepoint(population *pop, entity *father, entity *son);
418 FUNCPROTO void	ga_mutate_bitstring_multipoint(population *pop, entity *father, entity *son);
419 FUNCPROTO void	ga_mutate_double_singlepoint_drift( population *pop,
420                                           entity *father, entity *son );
421 FUNCPROTO void	ga_mutate_double_singlepoint_randomize( population *pop,
422                                               entity *father, entity *son );
423 FUNCPROTO void	ga_mutate_double_multipoint(population *pop, entity *father, entity *son);
424 FUNCPROTO void	ga_mutate_double_allpoint(population *pop, entity *father, entity *son);
425 
426 /*
427  * Functions located in ga_seed.c:
428  * (Genesis operators)
429  */
430 FUNCPROTO boolean	ga_seed_boolean_random(population *pop, entity *adam);
431 FUNCPROTO boolean ga_seed_boolean_zero(population *pop, entity *adam);
432 FUNCPROTO boolean	ga_seed_integer_random(population *pop, entity *adam);
433 FUNCPROTO boolean	ga_seed_integer_zero(population *pop, entity *adam);
434 FUNCPROTO boolean	ga_seed_double_random(population *pop, entity *adam);
435 FUNCPROTO boolean	ga_seed_double_zero(population *pop, entity *adam);
436 FUNCPROTO boolean	ga_seed_double_random_unit_gaussian(population *pop, entity *adam);
437 FUNCPROTO boolean	ga_seed_char_random(population *pop, entity *adam);
438 FUNCPROTO boolean	ga_seed_printable_random(population *pop, entity *adam);
439 FUNCPROTO boolean	ga_seed_bitstring_random(population *pop, entity *adam);
440 FUNCPROTO boolean	ga_seed_bitstring_zero(population *pop, entity *adam);
441 
442 /*
443  * Functions located in ga_replace.c:
444  * (Replacement operators)
445  */
446 FUNCPROTO void	ga_replace_by_fitness(population *pop, entity *child);
447 
448 /*
449  * Functions located in ga_utility.c:
450  * (Miscellaneous support functions)
451  */
452 FUNCPROTO void    ga_diagnostics( void );
453 FUNCPROTO int	ga_get_major_version( void );
454 FUNCPROTO int	ga_get_minor_version( void );
455 FUNCPROTO int	ga_get_patch_version( void );
456 /* ga_genesis() is deprecated! Use ga_genesis_integer() instead. */
457 FUNCPROTO population *ga_genesis( const int               population_size,
458                         const int               num_chromo,
459                         const int               len_chromo,
460                         GAgeneration_hook       generation_hook,
461                         GAiteration_hook        iteration_hook,
462                         GAdata_destructor       data_destructor,
463                         GAdata_ref_incrementor  data_ref_incrementor,
464                         GAevaluate              evaluate,
465                         GAseed                  seed,
466                         GAadapt                 adapt,
467                         GAselect_one            select_one,
468                         GAselect_two            select_two,
469                         GAmutate                mutate,
470                         GAcrossover             crossover,
471                         GAreplace               replace,
472 			vpointer		userdata );
473 /* ga_genesis_int() is deprecated! Use ga_genesis_integer() instead. */
474 FUNCPROTO population *ga_genesis_int( const int           population_size,
475                         const int               num_chromo,
476                         const int               len_chromo,
477                         GAgeneration_hook       generation_hook,
478                         GAiteration_hook        iteration_hook,
479                         GAdata_destructor       data_destructor,
480                         GAdata_ref_incrementor  data_ref_incrementor,
481                         GAevaluate              evaluate,
482                         GAseed                  seed,
483                         GAadapt                 adapt,
484                         GAselect_one            select_one,
485                         GAselect_two            select_two,
486                         GAmutate                mutate,
487                         GAcrossover             crossover,
488                         GAreplace               replace,
489 			vpointer		userdata );
490 FUNCPROTO population *ga_genesis_integer( const int           population_size,
491                         const int               num_chromo,
492                         const int               len_chromo,
493                         GAgeneration_hook       generation_hook,
494                         GAiteration_hook        iteration_hook,
495                         GAdata_destructor       data_destructor,
496                         GAdata_ref_incrementor  data_ref_incrementor,
497                         GAevaluate              evaluate,
498                         GAseed                  seed,
499                         GAadapt                 adapt,
500                         GAselect_one            select_one,
501                         GAselect_two            select_two,
502                         GAmutate                mutate,
503                         GAcrossover             crossover,
504                         GAreplace               replace,
505 			vpointer		userdata );
506 FUNCPROTO population *ga_genesis_boolean( const int               population_size,
507                         const int               num_chromo,
508                         const int               len_chromo,
509                         GAgeneration_hook       generation_hook,
510                         GAiteration_hook        iteration_hook,
511                         GAdata_destructor       data_destructor,
512                         GAdata_ref_incrementor  data_ref_incrementor,
513                         GAevaluate              evaluate,
514                         GAseed                  seed,
515                         GAadapt                 adapt,
516                         GAselect_one            select_one,
517                         GAselect_two            select_two,
518                         GAmutate                mutate,
519                         GAcrossover             crossover,
520                         GAreplace               replace,
521 			vpointer		userdata );
522 FUNCPROTO population *ga_genesis_char( const int               population_size,
523                         const int               num_chromo,
524                         const int               len_chromo,
525                         GAgeneration_hook       generation_hook,
526                         GAiteration_hook        iteration_hook,
527                         GAdata_destructor       data_destructor,
528                         GAdata_ref_incrementor  data_ref_incrementor,
529                         GAevaluate              evaluate,
530                         GAseed                  seed,
531                         GAadapt                 adapt,
532                         GAselect_one            select_one,
533                         GAselect_two            select_two,
534                         GAmutate                mutate,
535                         GAcrossover             crossover,
536                         GAreplace               replace,
537 			vpointer		userdata );
538 FUNCPROTO population *ga_genesis_double( const int               population_size,
539                         const int               num_chromo,
540                         const int               len_chromo,
541                         GAgeneration_hook       generation_hook,
542                         GAiteration_hook        iteration_hook,
543                         GAdata_destructor       data_destructor,
544                         GAdata_ref_incrementor  data_ref_incrementor,
545                         GAevaluate              evaluate,
546                         GAseed                  seed,
547                         GAadapt                 adapt,
548                         GAselect_one            select_one,
549                         GAselect_two            select_two,
550                         GAmutate                mutate,
551                         GAcrossover             crossover,
552                         GAreplace               replace,
553 			vpointer		userdata );
554 FUNCPROTO population *ga_genesis_bitstring( const int               population_size,
555                         const int               num_chromo,
556                         const int               len_chromo,
557                         GAgeneration_hook       generation_hook,
558                         GAiteration_hook        iteration_hook,
559                         GAdata_destructor       data_destructor,
560                         GAdata_ref_incrementor  data_ref_incrementor,
561                         GAevaluate              evaluate,
562                         GAseed                  seed,
563                         GAadapt                 adapt,
564                         GAselect_one            select_one,
565                         GAselect_two            select_two,
566                         GAmutate                mutate,
567                         GAcrossover             crossover,
568                         GAreplace               replace,
569 			vpointer		userdata );
570 FUNCPROTO entity  *ga_allele_search(      population      *pop,
571                                 const int       chromosomeid,
572                                 const int       point,
573                                 const int       min_val,
574                                 const int       max_val,
575                                 entity          *initial );
576 FUNCPROTO void ga_population_dump(population *pop);
577 FUNCPROTO void ga_entity_dump(population *pop, entity *john);
578 
579 /*
580  * Functions located in ga_stats.c:
581  * (Statistics functions)
582  */
583 FUNCPROTO boolean ga_fitness_mean( population *pop, double *average );
584 FUNCPROTO boolean ga_fitness_mean_stddev( population *pop,
585                              double *average, double *stddev );
586 FUNCPROTO boolean ga_fitness_stats( population *pop,
587                           double *max, double *min,
588                           double *mean, double *median,
589                           double *variance, double *stddev,
590                           double *kurtosis, double *skew );
591 
592 /*
593  * Functions located in ga_compare.c:
594  * (Entity comparison functions)
595  */
596 FUNCPROTO double ga_compare_char_hamming(population *pop, entity *alpha, entity *beta);
597 FUNCPROTO double ga_compare_char_euclidean(population *pop, entity *alpha, entity *beta);
598 FUNCPROTO double ga_compare_integer_hamming(population *pop, entity *alpha, entity *beta);
599 FUNCPROTO double ga_compare_integer_euclidean(population *pop, entity *alpha, entity *beta);
600 FUNCPROTO double ga_compare_double_hamming(population *pop, entity *alpha, entity *beta);
601 FUNCPROTO double ga_compare_double_euclidean(population *pop, entity *alpha, entity *beta);
602 FUNCPROTO double ga_compare_boolean_hamming(population *pop, entity *alpha, entity *beta);
603 FUNCPROTO double ga_compare_boolean_euclidean(population *pop, entity *alpha, entity *beta);
604 FUNCPROTO double ga_compare_bitstring_hamming(population *pop, entity *alpha, entity *beta);
605 FUNCPROTO double ga_compare_bitstring_euclidean(population *pop, entity *alpha, entity *beta);
606 
607 /*
608  * Functions located in ga_rank.c:
609  * (Entity comparison functions)
610  */
611 FUNCPROTO int ga_rank_fitness(population *alphapop, entity *alpha, population *betapop, entity *beta);
612 
613 /**********************************************************************
614  * Include remainder of this library's headers.
615  * These should, mostly, contain private definitions etc.
616  * But they currently contain almost everything.
617  **********************************************************************/
618 
619 #include "gaul/ga_core.h"		/* Private aspects of GAUL. */
620 
621 #if HAVE_SLANG==1
622 #include "gaul/ga_intrinsics.h"         /* GAUL's S-Lang interface. */
623 #endif
624 
625 #endif	/* GAUL_H_INCLUDED */
626 
627