1 | /****************************************************************************** |
---|
2 | * FILE: pgapack.h: This file contains all constant and structure |
---|
3 | * definitions definitions for PGAPack as well as all |
---|
4 | * function declarations. |
---|
5 | * Authors: David M. Levine, Philip L. Hallstrom, David M. Noelle, |
---|
6 | * Brian P. Walenz |
---|
7 | ******************************************************************************/ |
---|
8 | |
---|
9 | #ifndef __PGA_PACK_H_ |
---|
10 | #define __PGA_PACK_H_ |
---|
11 | |
---|
12 | #include <stdio.h> |
---|
13 | #include <stdlib.h> |
---|
14 | #include <math.h> |
---|
15 | #include <time.h> |
---|
16 | #include <limits.h> |
---|
17 | #include <float.h> |
---|
18 | #include <string.h> |
---|
19 | #include <ctype.h> |
---|
20 | #include <mpi.h> |
---|
21 | |
---|
22 | |
---|
23 | |
---|
24 | /* If OPTIMIZED, remove various sanity checks, and debug output. |
---|
25 | * |
---|
26 | * PGADebugEntered(a) - Print a debug message about entering "a" |
---|
27 | * PGADebugExited(a) - Print a debug message about exiting "a" |
---|
28 | * PGAFailIfNotSetup(a) - Fail fatally if PGASetUp has not been called |
---|
29 | * PGAFailIfSetup(a) - Fail fatally if PGASetUp has been called |
---|
30 | * PGACheckDataType(a, D) - Fail fatally if the datatype is not D |
---|
31 | */ |
---|
32 | #ifndef OPTIMIZE |
---|
33 | #define OPTIMIZE 0 |
---|
34 | |
---|
35 | |
---|
36 | #define PGADebugEntered(a) \ |
---|
37 | PGADebugPrint(ctx, PGA_DEBUG_ENTERED, a, "Entered", PGA_VOID, NULL) |
---|
38 | #define PGADebugExited(a) \ |
---|
39 | PGADebugPrint(ctx, PGA_DEBUG_EXIT, a, "Exited", PGA_VOID, NULL) |
---|
40 | #define PGAFailIfNotSetUp(Name) \ |
---|
41 | if (ctx->sys.SetUpCalled == PGA_FALSE) \ |
---|
42 | PGAError(ctx, "PGASetUp must be called before " Name, \ |
---|
43 | PGA_FATAL, PGA_VOID, NULL) |
---|
44 | #define PGAFailIfSetUp(Name) \ |
---|
45 | if (ctx->sys.SetUpCalled == PGA_TRUE) \ |
---|
46 | PGAError(ctx, Name " must be called before PGASetUp", PGA_FATAL, \ |
---|
47 | PGA_VOID, NULL) |
---|
48 | #define PGACheckDataType(Name, DataType) \ |
---|
49 | if (ctx->ga.datatype != DataType) \ |
---|
50 | PGAError(ctx, "DataType is incorrect for " Name,PGA_FATAL,PGA_VOID,NULL) |
---|
51 | |
---|
52 | #else |
---|
53 | #undef OPTIMIZE |
---|
54 | #define OPTIMIZE 1 |
---|
55 | #define PGADebugPrint(a,b,c,x,y,z) ; |
---|
56 | #define PGADebugEntered(a) ; |
---|
57 | #define PGADebugExited(a) ; |
---|
58 | #define PGAFailIfNotSetUp(Name) ; |
---|
59 | #define PGAFailIfSetUp(Name) ; |
---|
60 | #define PGACheckDataType(Name, DataType) ; |
---|
61 | #endif |
---|
62 | |
---|
63 | /***************************************** |
---|
64 | * BINARY MACROS * |
---|
65 | *****************************************/ |
---|
66 | #ifndef WL |
---|
67 | #error WL must be defined on the command line! |
---|
68 | #endif |
---|
69 | |
---|
70 | #define ONEL ((PGABinary)1) |
---|
71 | #define BIT(x,y) (y&(ONEL<<((WL-1)-(x)))) /* true if bit is 1, */ |
---|
72 | #define SET(x,y) (y|=(ONEL<<((WL-1)-(x)))) /* set a bit to 1 */ |
---|
73 | #define UNSET(x,y) (y&=(~(ONEL<<((WL-1)-(x)))))/* set a bit to 0, clear */ |
---|
74 | #define TOGGLE(x,y) (y^=(ONEL<<((WL-1)-(x)))) /* complement a bits value */ |
---|
75 | #define INDEX(ix,bx,bit,WL) ix=bit/WL;bx=bit%WL /* map global column (bit) */ |
---|
76 | /* to word (ix) and bit (bx) */ |
---|
77 | |
---|
78 | /***************************************** |
---|
79 | * ABSTRACT DATA TYPES * |
---|
80 | *****************************************/ |
---|
81 | #define PGA_DATATYPE_BINARY 1 /* Array of unsigned ints */ |
---|
82 | /* parsed into bits : binary.c */ |
---|
83 | #define PGA_DATATYPE_INTEGER 2 /* Array of ints : integer.c */ |
---|
84 | #define PGA_DATATYPE_REAL 3 /* Array of doubles : real.c */ |
---|
85 | #define PGA_DATATYPE_CHARACTER 4 /* Array of characters : character.c */ |
---|
86 | #define PGA_DATATYPE_USER 5 /* --user defined-- */ |
---|
87 | |
---|
88 | #define PGABinary unsigned long |
---|
89 | #define PGAInteger signed long int |
---|
90 | #define PGAReal double |
---|
91 | #define PGACharacter signed char |
---|
92 | |
---|
93 | #define PGA_INT 1 |
---|
94 | #define PGA_DOUBLE 2 |
---|
95 | #define PGA_CHAR 3 |
---|
96 | #define PGA_VOID 4 |
---|
97 | |
---|
98 | |
---|
99 | /***************************************** |
---|
100 | * BOOLEANS * |
---|
101 | *****************************************/ |
---|
102 | #define PGA_TRUE 1 |
---|
103 | #define PGA_FALSE 0 |
---|
104 | |
---|
105 | /***************************************** |
---|
106 | * FLAGS * |
---|
107 | *****************************************/ |
---|
108 | #define PGA_FATAL 1 |
---|
109 | #define PGA_WARNING 2 |
---|
110 | |
---|
111 | /***************************************** |
---|
112 | * MISC CONSTANT * |
---|
113 | *****************************************/ |
---|
114 | #define PGA_TEMP1 -1138 |
---|
115 | #define PGA_TEMP2 -4239 |
---|
116 | #define PGA_TEMP3 -4238 |
---|
117 | |
---|
118 | #define PGA_OLDPOP -6728 |
---|
119 | #define PGA_NEWPOP -8376 |
---|
120 | |
---|
121 | #define PGA_UNINITIALIZED_INT -3827 |
---|
122 | #define PGA_UNINITIALIZED_DOUBLE -968.3827 |
---|
123 | |
---|
124 | /***************************************** |
---|
125 | * DEBUG LEVELS * |
---|
126 | *****************************************/ |
---|
127 | #define PGA_DEBUG_ENTERED 12 |
---|
128 | #define PGA_DEBUG_EXIT 13 |
---|
129 | #define PGA_DEBUG_MALLOC 80 |
---|
130 | #define PGA_DEBUG_PRINTVAR 82 |
---|
131 | #define PGA_DEBUG_SEND 22 |
---|
132 | #define PGA_DEBUG_RECV 23 |
---|
133 | #define PGA_DEBUG_MAXPGAPACKFUNCTIONS 300 |
---|
134 | #define PGA_DEBUG_MAXFLAGS 1000 |
---|
135 | |
---|
136 | /***************************************** |
---|
137 | * DIRECTION * |
---|
138 | *****************************************/ |
---|
139 | #define PGA_MAXIMIZE 1 /* specify direction for fitness calc */ |
---|
140 | #define PGA_MINIMIZE 2 /* specify direction for fitness calc */ |
---|
141 | |
---|
142 | /***************************************** |
---|
143 | * STOPPING CRITERIA * |
---|
144 | *****************************************/ |
---|
145 | #define PGA_STOP_MAXITER 1 /* Stop: for maximum iterations */ |
---|
146 | #define PGA_STOP_NOCHANGE 2 /* Stop: no change in best string */ |
---|
147 | #define PGA_STOP_TOOSIMILAR 4 /* Stop: homogeneous population */ |
---|
148 | |
---|
149 | /***************************************** |
---|
150 | * CROSSOVER * |
---|
151 | *****************************************/ |
---|
152 | #define PGA_CROSSOVER_ONEPT 1 /* One point crossover */ |
---|
153 | #define PGA_CROSSOVER_TWOPT 2 /* Two point crossover */ |
---|
154 | #define PGA_CROSSOVER_UNIFORM 3 /* Uniform crossover */ |
---|
155 | |
---|
156 | /***************************************** |
---|
157 | * SELECTION * |
---|
158 | *****************************************/ |
---|
159 | #define PGA_SELECT_PROPORTIONAL 1 /* proportional selection */ |
---|
160 | #define PGA_SELECT_SUS 2 /* stochastic universal selection */ |
---|
161 | #define PGA_SELECT_TOURNAMENT 3 /* tournament selection */ |
---|
162 | #define PGA_SELECT_PTOURNAMENT 4 /* probabilistic tournament selection */ |
---|
163 | |
---|
164 | /***************************************** |
---|
165 | * FITNESS * |
---|
166 | *****************************************/ |
---|
167 | #define PGA_FITNESS_RAW 1 /* use raw fitness (evaluation) */ |
---|
168 | #define PGA_FITNESS_NORMAL 2 /* linear normalization fitness */ |
---|
169 | #define PGA_FITNESS_RANKING 3 /* linear ranking fitness */ |
---|
170 | |
---|
171 | /***************************************** |
---|
172 | * FITNESS (MINIMIZATION) * |
---|
173 | *****************************************/ |
---|
174 | #define PGA_FITNESSMIN_RECIPROCAL 1 /* reciprocal fitness */ |
---|
175 | #define PGA_FITNESSMIN_CMAX 2 /* cmax fitness */ |
---|
176 | |
---|
177 | /***************************************** |
---|
178 | * MUTATION * |
---|
179 | *****************************************/ |
---|
180 | #define PGA_MUTATION_CONSTANT 1 /* Real/Integer: Fixed value */ |
---|
181 | #define PGA_MUTATION_RANGE 2 /* Real/Integer: Uniform range */ |
---|
182 | #define PGA_MUTATION_UNIFORM 3 /* Real: +- Uniform random no. */ |
---|
183 | #define PGA_MUTATION_GAUSSIAN 4 /* Real: +- Gaussian random no. */ |
---|
184 | #define PGA_MUTATION_PERMUTE 5 /* Integer: Permutation (swap) */ |
---|
185 | |
---|
186 | /***************************************** |
---|
187 | * POPULATION REPLACEMENT * |
---|
188 | *****************************************/ |
---|
189 | #define PGA_POPREPL_BEST 1 /* Select best string */ |
---|
190 | #define PGA_POPREPL_RANDOM_NOREP 2 /* Select random string w/o replacement*/ |
---|
191 | #define PGA_POPREPL_RANDOM_REP 3 /* Select random string w/ replacement*/ |
---|
192 | |
---|
193 | /**************************************** |
---|
194 | * REPORT OPTIONS * |
---|
195 | ****************************************/ |
---|
196 | #define PGA_REPORT_ONLINE 1 /* Print the online analysis */ |
---|
197 | #define PGA_REPORT_OFFLINE 2 /* Print the offline analysis */ |
---|
198 | #define PGA_REPORT_HAMMING 4 /* Print the Hamming distance */ |
---|
199 | #define PGA_REPORT_STRING 8 /* Print the string */ |
---|
200 | #define PGA_REPORT_WORST 16 /* Print the worst individual */ |
---|
201 | #define PGA_REPORT_AVERAGE 32 /* Print the average of the population */ |
---|
202 | |
---|
203 | /***************************************** |
---|
204 | * RANDOMIZER * |
---|
205 | *****************************************/ |
---|
206 | #define PGA_RINIT_PERCENT 1 /* real percent offset */ |
---|
207 | #define PGA_RINIT_RANGE 2 /* real range */ |
---|
208 | #define PGA_IINIT_PERMUTE 1 /* integer permutation */ |
---|
209 | #define PGA_IINIT_RANGE 2 /* integer range (nonunique) */ |
---|
210 | #define PGA_CINIT_LOWER 1 /* all lowercase letters */ |
---|
211 | #define PGA_CINIT_UPPER 2 /* all uppercase letters */ |
---|
212 | #define PGA_CINIT_MIXED 3 /* both upper and lower case letters */ |
---|
213 | |
---|
214 | /***************************************** |
---|
215 | * SET USER FUNCTION * |
---|
216 | *****************************************/ |
---|
217 | #define PGA_USERFUNCTION_CREATESTRING 1 |
---|
218 | #define PGA_USERFUNCTION_MUTATION 2 |
---|
219 | #define PGA_USERFUNCTION_CROSSOVER 3 |
---|
220 | #define PGA_USERFUNCTION_PRINTSTRING 4 |
---|
221 | #define PGA_USERFUNCTION_COPYSTRING 5 |
---|
222 | #define PGA_USERFUNCTION_DUPLICATE 6 |
---|
223 | #define PGA_USERFUNCTION_INITSTRING 7 |
---|
224 | #define PGA_USERFUNCTION_BUILDDATATYPE 8 |
---|
225 | #define PGA_USERFUNCTION_STOPCOND 9 |
---|
226 | #define PGA_USERFUNCTION_ENDOFGEN 10 |
---|
227 | #define PGA_USERFUNCTION_RANKING 11 |
---|
228 | #define PGA_USERFUNCTION_FITNESS 12 |
---|
229 | #define PGA_USERFUNCTION_SELECT 13 |
---|
230 | #define PGA_USERFUNCTION_SORTPOP 14 |
---|
231 | |
---|
232 | /******* EHW Modification ************************/ |
---|
233 | #define PGA_USERFUNCTION_SETTEMP 15 |
---|
234 | #define PGA_USERFUNCTION_ENDOFREPFCN 16 |
---|
235 | #define PGA_USERFUNCTION_DESTROYUD 17 |
---|
236 | |
---|
237 | #define PGA_USERFUNCTION_INITUSERCTX 18 |
---|
238 | #define PGA_USERFUNCTION_KILLUSERCTX 19 |
---|
239 | #define PGA_NUM_USERFUNCTIONS 19 |
---|
240 | /*************************************************/ |
---|
241 | |
---|
242 | /***************************************** |
---|
243 | * MPI SEND/RECV TAGS * |
---|
244 | *****************************************/ |
---|
245 | #define PGA_COMM_STRINGTOEVAL 1 /* MPI tag for sending string */ |
---|
246 | #define PGA_COMM_EVALOFSTRING 2 /* MPI tag for returning evaluation */ |
---|
247 | #define PGA_COMM_DONEWITHEVALS 3 /* MPI tag for ending parallel eval */ |
---|
248 | |
---|
249 | |
---|
250 | |
---|
251 | |
---|
252 | /***************************************** |
---|
253 | * INDIVIDUAL STRUTURE * |
---|
254 | *****************************************/ |
---|
255 | |
---|
256 | typedef struct { /* primary population data structure */ |
---|
257 | double evalfunc; /* evaluation function value */ |
---|
258 | double fitness; /* fitness function value */ |
---|
259 | int evaluptodate; /* flag whether evalfunc is current */ |
---|
260 | void *chrom; /* pointer to the GA string */ |
---|
261 | |
---|
262 | /***************** EHW Project Modifications **********************/ |
---|
263 | void *UserData; /* pointer to circuit response */ |
---|
264 | /********************************************************************/ |
---|
265 | } PGAIndividual; |
---|
266 | |
---|
267 | |
---|
268 | /***************************************** |
---|
269 | * GA ALGORITHM STRUCTURE * |
---|
270 | *****************************************/ |
---|
271 | typedef struct { |
---|
272 | int datatype; /* data type: binary, integer, or real */ |
---|
273 | int optdir; /* direction of optimization */ |
---|
274 | int tw; /* total number of words, full + partial */ |
---|
275 | int fw; /* number of full (WL length) words */ |
---|
276 | int eb; /* number of extra bits in last NOT full word*/ |
---|
277 | int PopSize; /* Number of strings to use */ |
---|
278 | int StringLen; /* string lengths */ |
---|
279 | int StoppingRule; /* Termination Criteria */ |
---|
280 | int MaxIter; /* Maximum number of iterations to run */ |
---|
281 | int MaxNoChange; /* # of iters with no change before stopping */ |
---|
282 | int MaxSimilarity; /* % of pop the same before stopping */ |
---|
283 | int NumReplace; /* Number of string to replace each gen */ |
---|
284 | int PopReplace; /* Method of choosing ind.s to copy to newpop*/ |
---|
285 | int iter; /* iteration (generation) counter */ |
---|
286 | int ItersOfSame; /* # iters with no change in best */ |
---|
287 | int PercentSame; /* % of pop that is homogeneous */ |
---|
288 | int NoDuplicates; /* Don't allow duplicate strings */ |
---|
289 | int CrossoverType; /* Type of crossover for genetic algorithm */ |
---|
290 | int SelectType; /* Type of selection for genetic algorithm */ |
---|
291 | int SelectIndex; /* index of Select for next two individuals */ |
---|
292 | int FitnessType; /* Type of fitness transformation used */ |
---|
293 | int FitnessMinType; /* Transformation for minimization problems */ |
---|
294 | int MutateOnlyNoCross; /* Mutate only strings not from crossover */ |
---|
295 | int MutationType; /* Type of mutation used */ |
---|
296 | int MutateIntegerValue; /* Multiplier to mutate Integer strings with */ |
---|
297 | int MutateBoundedFlag; /* Confine integer alleles to given range */ |
---|
298 | double MutateRealValue; /* Multiplier to mutate Real strings with */ |
---|
299 | double MutationProb; /* Starting mutation probability */ |
---|
300 | double CrossoverProb; /* Crossover probability */ |
---|
301 | double UniformCrossProb; /* Prob of bit select in uniform crossover */ |
---|
302 | double PTournamentProb; /* Prob of selection in Prob. Tournament */ |
---|
303 | double FitnessRankMax; /* MAX value for use in ranking */ |
---|
304 | double FitnessCmaxValue; /* Cmax value used to convert minimizations */ |
---|
305 | double restartAlleleProb;/* prob of changing an allele in a restart */ |
---|
306 | int restart; /* whether to use the restart operator */ |
---|
307 | int restartFreq; /* frequency with which to restart */ |
---|
308 | int *selected; /* array of indices for selection */ |
---|
309 | int *sorted; /* array of sorted individual indices */ |
---|
310 | PGAIndividual *oldpop; /* pointer to population (old) */ |
---|
311 | PGAIndividual *newpop; /* pointer to population (new) */ |
---|
312 | |
---|
313 | /********************** EHW project modifications *********************/ |
---|
314 | int sUD; /* Size of User Data array structure */ |
---|
315 | /**********************************************************************/ |
---|
316 | } PGAAlgorithm; |
---|
317 | |
---|
318 | |
---|
319 | |
---|
320 | /***************************************** |
---|
321 | * OPERATIONS STRUCTURES * |
---|
322 | *****************************************/ |
---|
323 | typedef struct PGAContext PGAContext; |
---|
324 | typedef struct { |
---|
325 | void (*CreateString)(PGAContext *, int, int, int); |
---|
326 | int (*Mutation)(PGAContext *, int, int, double); |
---|
327 | void (*Crossover)(PGAContext *, int, int, int, int, int, int); |
---|
328 | void (*PrintString)(PGAContext *, FILE *, int, int); |
---|
329 | void (*CopyString)(PGAContext *, int, int, int, int); |
---|
330 | int (*Duplicate)(PGAContext *, int, int, int, int); |
---|
331 | void (*InitString)(PGAContext *, int, int); |
---|
332 | MPI_Datatype (*BuildDatatype)(PGAContext *, int, int); |
---|
333 | int (*StopCond)(PGAContext *); |
---|
334 | void (*EndOfGen)(PGAContext *); |
---|
335 | |
---|
336 | /******************* DRH Mod for MMPAT ********************************/ |
---|
337 | void (*Rank)(PGAContext *, int); /* Calls a custom */ |
---|
338 | /*ranking function*/ |
---|
339 | void (*Fitness)(PGAContext *, int); /* Calls a custom fitness eval*/ |
---|
340 | void (*Select) (PGAContext *, int); /* Calls a custom selection */ |
---|
341 | /*********************************************/ |
---|
342 | /* new added by Lu Yang */ |
---|
343 | void (*SortPop) (PGAContext *, int); /* Calls a custom sort pop */ |
---|
344 | /*********************************************/ |
---|
345 | /* function */ |
---|
346 | /*********************************************************************/ |
---|
347 | |
---|
348 | /********************** EHW project modifications *********************/ |
---|
349 | void (*SetTemp)(PGAContext *); /* Sets the Temperature */ |
---|
350 | /* Parameter */ |
---|
351 | /**********************************************************************/ |
---|
352 | |
---|
353 | /*** SNS Addition, it sets the reproductive flags *************/ |
---|
354 | /*** This may be part of The Chromosome User Data ************/ |
---|
355 | |
---|
356 | /* Gets executed when PGASetEvaluationUpToDateFlag is called |
---|
357 | and the flag is set to PGA_FALSE Is called so that the user |
---|
358 | data is updated whenever the Evaluation up to date flag is set to |
---|
359 | false |
---|
360 | */ |
---|
361 | void (*EndOfRepFcn)(PGAContext *,int,int); |
---|
362 | |
---|
363 | void (*DestroyUD)(PGAContext *,int,int); |
---|
364 | /* CHSL: Executed before the GA is run (gen 0) */ |
---|
365 | void (*InitUserCtx)(PGAContext *); |
---|
366 | /* CHSL: Executed after the GA is finished (end of last gen) */ |
---|
367 | void (*KillUserCtx)(PGAContext *); |
---|
368 | |
---|
369 | |
---|
370 | |
---|
371 | /**********************************************************************/ |
---|
372 | |
---|
373 | |
---|
374 | |
---|
375 | } PGACOperations; |
---|
376 | |
---|
377 | typedef struct { |
---|
378 | int (*Mutation)(void *, void *, void *, void *); |
---|
379 | void (*Crossover)(void *, void *, void *, void *, void *, void *, void *); |
---|
380 | void (*PrintString)(void *, void *, void *, void *); |
---|
381 | void (*CopyString)(void *, void *, void *, void *, void *); |
---|
382 | int (*Duplicate)(void *, void *, void *, void *, void *); |
---|
383 | void (*InitString)(void *, void *, void *); |
---|
384 | int (*StopCond)(void *); |
---|
385 | void (*EndOfGen)(void *); |
---|
386 | /******************* DRH Mod for MMPAT ********************************/ |
---|
387 | void (*Rank)( void *, void *); /* calls a custom */ |
---|
388 | /* ranking function*/ |
---|
389 | void (*Fitness)( void *, void *); /* Calls a custom fitness eval*/ |
---|
390 | void (*Select )( void *, void *); /* Calls a custom selection fn*/ |
---|
391 | /*********************************************/ |
---|
392 | /* new added by Lu Yang */ |
---|
393 | void (*SortPop) (void *, void *); /* Calls a custom sort pop */ |
---|
394 | /*********************************************************************/ |
---|
395 | |
---|
396 | /********************** EHW project modifications *********************/ |
---|
397 | void (*SetTemp)(void *); /* Sets the Temperature */ |
---|
398 | /* Parameter */ |
---|
399 | /**********************************************************************/ |
---|
400 | |
---|
401 | /*** SNS Addition, it sets the reproductive flags *************/ |
---|
402 | /*** This may be part of The Chromosome User Data ************/ |
---|
403 | void (*EndOfRepFcn)(void *,void *,void *); |
---|
404 | void (*DestroyUD)(void *,void *,void *); |
---|
405 | |
---|
406 | /* CHSL: Executed before the GA is run (gen 0) */ |
---|
407 | void (*InitUserCtx)(void *); |
---|
408 | /* CHSL: Executed after the GA is finished (end of last gen) */ |
---|
409 | void (*KillUserCtx)(void *); |
---|
410 | |
---|
411 | /**********************************************************************/ |
---|
412 | |
---|
413 | } PGAFortranOperations; |
---|
414 | |
---|
415 | /***************************************** |
---|
416 | * PARALLEL STRUCTURE * |
---|
417 | *****************************************/ |
---|
418 | typedef struct { |
---|
419 | int MPIAlreadyInit; /* Flag whether MPI was previously initialized*/ |
---|
420 | int NumIslands; /* Number of islands in island model */ |
---|
421 | int NumDemes; /* Number of demes in neighborhood model */ |
---|
422 | MPI_Comm DefaultComm; /* Default communicator for PGARun */ |
---|
423 | int MPIStubLibrary; /* Boolean: real or stub version of MPI */ |
---|
424 | } PGAParallel; |
---|
425 | |
---|
426 | /***************************************** |
---|
427 | * REPORT STRUCTURE * |
---|
428 | *****************************************/ |
---|
429 | typedef struct { |
---|
430 | int PrintFreq; /* How often to print statistics reports*/ |
---|
431 | int PrintOptions; |
---|
432 | double Offline; |
---|
433 | double Online; |
---|
434 | double Average; |
---|
435 | double Best; |
---|
436 | time_t starttime; |
---|
437 | } PGAReport; |
---|
438 | |
---|
439 | |
---|
440 | /***************************************** |
---|
441 | * SYSTEM STRUCTURE * |
---|
442 | *****************************************/ |
---|
443 | typedef struct { |
---|
444 | int UserFortran; /* user routines in Fortran or C? */ |
---|
445 | int SetUpCalled; /* has PGASetUp been called? */ |
---|
446 | int PGAMaxInt; /* largest int of machine */ |
---|
447 | int PGAMinInt; /* smallest int of machine */ |
---|
448 | double PGAMaxDouble; /* largest double of machine */ |
---|
449 | double PGAMinDouble; /* smallest double of machine */ |
---|
450 | } PGASystem; |
---|
451 | |
---|
452 | |
---|
453 | /***************************************** |
---|
454 | * DEBUG STRUCTURE * |
---|
455 | *****************************************/ |
---|
456 | typedef struct { |
---|
457 | int PGADebugFlags[PGA_DEBUG_MAXFLAGS]; |
---|
458 | } PGADebug; |
---|
459 | |
---|
460 | /***************************************** |
---|
461 | * INITIALIZATION STRUCTURE * |
---|
462 | *****************************************/ |
---|
463 | typedef struct { |
---|
464 | int RandomInit; /* flag whether to randomize strings */ |
---|
465 | double BinaryProbability; /* probability that a Bit will be 1 */ |
---|
466 | int RealType; /* type of real initialization */ |
---|
467 | int IntegerType; /* type of integer initialization */ |
---|
468 | int CharacterType; /* type of character initialization */ |
---|
469 | int *IntegerMin; /* minimum of range of integers */ |
---|
470 | int *IntegerMax; /* maximum of range of integers */ |
---|
471 | double *RealMin; /* minimum of range of reals */ |
---|
472 | double *RealMax; /* maximum of range of reals */ |
---|
473 | int RandomSeed; /* integer to seed random numbers with */ |
---|
474 | } PGAInitialize; |
---|
475 | |
---|
476 | /***************************************** |
---|
477 | * SCRATCH DATA STRUCTURES * |
---|
478 | *****************************************/ |
---|
479 | typedef struct { |
---|
480 | int *intscratch; /* integer-scratch space */ |
---|
481 | double *dblscratch; /* double- scratch space */ |
---|
482 | } PGAScratch; |
---|
483 | |
---|
484 | /***************************************** |
---|
485 | * CONTEXT STRUCTURE * |
---|
486 | *****************************************/ |
---|
487 | struct PGAContext { |
---|
488 | PGAAlgorithm ga; |
---|
489 | PGACOperations cops; |
---|
490 | PGAFortranOperations fops; |
---|
491 | PGAParallel par; |
---|
492 | PGAReport rep; |
---|
493 | PGASystem sys; |
---|
494 | PGADebug debug; |
---|
495 | PGAInitialize init; |
---|
496 | PGAScratch scratch; |
---|
497 | |
---|
498 | /************************* |
---|
499 | * EHW ADDITION * |
---|
500 | *************************/ |
---|
501 | void *inputex; |
---|
502 | |
---|
503 | }; |
---|
504 | |
---|
505 | /***************************************** |
---|
506 | * binary.c |
---|
507 | *****************************************/ |
---|
508 | |
---|
509 | |
---|
510 | |
---|
511 | void PGASetBinaryAllele ( PGAContext *ctx, int p, int pop, int i, int val ); |
---|
512 | int PGAGetBinaryAllele ( PGAContext *ctx, int p, int pop, int i ); |
---|
513 | void PGASetBinaryInitProb ( PGAContext *ctx, double probability ); |
---|
514 | double PGAGetBinaryInitProb (PGAContext *ctx); |
---|
515 | void PGABinaryCreateString(PGAContext *ctx, int p, int pop, int initflag); |
---|
516 | int PGABinaryMutation( PGAContext *ctx, int p, int pop, double mr ); |
---|
517 | void PGABinaryOneptCrossover(PGAContext *ctx, int p1, int p2, int pop1, int c1, |
---|
518 | int c2, int pop2); |
---|
519 | void PGABinaryTwoptCrossover(PGAContext *ctx, int p1, int p2, int pop1, int c1, |
---|
520 | int c2, int pop2); |
---|
521 | void PGABinaryUniformCrossover(PGAContext *ctx, int p1, int p2, int pop1, |
---|
522 | int c1, int c2, int pop2); |
---|
523 | void PGABinaryPrintString( PGAContext *ctx, FILE *fp, int p, int pop ); |
---|
524 | void PGABinaryCopyString (PGAContext *ctx, int p1, int pop1, int p2, int pop2); |
---|
525 | int PGABinaryDuplicate( PGAContext *ctx, int p1, int pop1, int p2, int pop2); |
---|
526 | void PGABinaryInitString(PGAContext *ctx, int p, int pop); |
---|
527 | MPI_Datatype PGABinaryBuildDatatype(PGAContext *ctx, int p, int pop); |
---|
528 | int PGABinaryHammingDistance ( PGAContext *ctx, PGABinary *s1, PGABinary *s2 ); |
---|
529 | void PGABinaryPrint( PGAContext *ctx, FILE *fp, PGABinary *chrom, int nb ); |
---|
530 | |
---|
531 | /***************************************** |
---|
532 | * char.c |
---|
533 | *****************************************/ |
---|
534 | |
---|
535 | |
---|
536 | void PGASetCharacterAllele (PGAContext *ctx, int p, int pop, int i, char value); |
---|
537 | char PGAGetCharacterAllele (PGAContext *ctx, int p, int pop, int i); |
---|
538 | void PGASetCharacterInitType(PGAContext *ctx, int value); |
---|
539 | void PGACharacterCreateString (PGAContext *ctx, int p, int pop, int InitFlag); |
---|
540 | int PGACharacterMutation( PGAContext *ctx, int p, int pop, double mr ); |
---|
541 | void PGACharacterOneptCrossover(PGAContext *ctx, int p1, int p2, int pop1, |
---|
542 | int c1, int c2, int pop2); |
---|
543 | void PGACharacterTwoptCrossover( PGAContext *ctx, int p1, int p2, int pop1, |
---|
544 | int c1, int c2, int pop2); |
---|
545 | void PGACharacterUniformCrossover(PGAContext *ctx, int p1, int p2, int pop1, |
---|
546 | int c1, int c2, int pop2); |
---|
547 | void PGACharacterPrintString ( PGAContext *ctx, FILE *fp, int p, int pop); |
---|
548 | void PGACharacterCopyString (PGAContext *ctx, int p1, int pop1, int p2, |
---|
549 | int pop2); |
---|
550 | int PGACharacterDuplicate( PGAContext *ctx, int p1, int pop1, int p2, int pop2); |
---|
551 | void PGACharacterInitString(PGAContext *ctx, int p, int pop); |
---|
552 | MPI_Datatype PGACharacterBuildDatatype(PGAContext *ctx, int p, int pop); |
---|
553 | |
---|
554 | /***************************************** |
---|
555 | * cmdline.c |
---|
556 | *****************************************/ |
---|
557 | |
---|
558 | |
---|
559 | void PGAReadCmdLine( PGAContext *ctx, int *argc, char **argv ); |
---|
560 | void PGAParseDebugArg(PGAContext *ctx, char *st); |
---|
561 | void PGAStripArgs(char **argv, int *argc, int *c, int num); |
---|
562 | |
---|
563 | /***************************************** |
---|
564 | * create.c |
---|
565 | *****************************************/ |
---|
566 | |
---|
567 | PGAContext *PGACreate ( int *argc, char **argv, |
---|
568 | int datatype, int len, int maxormin ); |
---|
569 | void PGASetUp ( PGAContext *ctx ); |
---|
570 | void PGASetRandomInitFlag(PGAContext *ctx, int RandomBoolean); |
---|
571 | int PGAGetRandomInitFlag (PGAContext *ctx); |
---|
572 | void PGACreatePop (PGAContext *ctx, int pop); |
---|
573 | void PGACreateIndividual (PGAContext *ctx, int p, int pop, int initflag); |
---|
574 | |
---|
575 | /***************************************** |
---|
576 | * cross.c |
---|
577 | *****************************************/ |
---|
578 | |
---|
579 | void PGACrossover ( PGAContext *ctx, int p1, int p2, int pop1, |
---|
580 | int c1, int c2, int pop2 ); |
---|
581 | int PGAGetCrossoverType (PGAContext *ctx); |
---|
582 | double PGAGetCrossoverProb (PGAContext *ctx); |
---|
583 | double PGAGetUniformCrossoverProb (PGAContext *ctx); |
---|
584 | void PGASetCrossoverType (PGAContext *ctx, int crossover_type); |
---|
585 | void PGASetCrossoverProb( PGAContext *ctx, double crossover_prob); |
---|
586 | void PGASetUniformCrossoverProb( PGAContext *ctx, double uniform_cross_prob); |
---|
587 | |
---|
588 | /***************************************** |
---|
589 | * debug.c |
---|
590 | *****************************************/ |
---|
591 | |
---|
592 | |
---|
593 | void PGASortFuncNameIndex(PGAContext *ctx); |
---|
594 | #if OPTIMIZE==0 |
---|
595 | void PGADebugPrint( PGAContext *ctx, int level, char *funcname, |
---|
596 | char *msg, int datatype, void *data ); |
---|
597 | #endif |
---|
598 | void PGASetDebugLevel(PGAContext *ctx, int level); |
---|
599 | void PGAClearDebugLevel(PGAContext *ctx, int level); |
---|
600 | void PGASetDebugLevelByName(PGAContext *ctx, char *funcname); |
---|
601 | void PGAClearDebugLevelByName(PGAContext *ctx, char *funcname); |
---|
602 | int PGAGetDebugLevelOfName(PGAContext *ctx, char *funcname); |
---|
603 | int PGAGetDebugFlag(PGAContext *ctx, char *funcname); |
---|
604 | void PGASetDebugFlag11(PGAContext *ctx, int Flag); |
---|
605 | void PGASetDebugFlag20(PGAContext *ctx, int Flag); |
---|
606 | void PGASetDebugFlag21(PGAContext *ctx, int Flag); |
---|
607 | void PGASetDebugFlag30(PGAContext *ctx, int Flag); |
---|
608 | void PGASetDebugFlag32(PGAContext *ctx, int Flag); |
---|
609 | void PGASetDebugFlag34(PGAContext *ctx, int Flag); |
---|
610 | void PGASetDebugFlag36(PGAContext *ctx, int Flag); |
---|
611 | void PGASetDebugFlag40(PGAContext *ctx, int Flag); |
---|
612 | void PGASetDebugFlag42(PGAContext *ctx, int Flag); |
---|
613 | void PGASetDebugFlag44(PGAContext *ctx, int Flag); |
---|
614 | void PGASetDebugFlag46(PGAContext *ctx, int Flag); |
---|
615 | void PGASetDebugFlag48(PGAContext *ctx, int Flag); |
---|
616 | void PGASetDebugFlag50(PGAContext *ctx, int Flag); |
---|
617 | void PGASetDebugFlag52(PGAContext *ctx, int Flag); |
---|
618 | void PGASetDebugFlag54(PGAContext *ctx, int Flag); |
---|
619 | void PGASetDebugFlag56(PGAContext *ctx, int Flag); |
---|
620 | void PGASetDebugFlag58(PGAContext *ctx, int Flag); |
---|
621 | void PGASetDebugFlag60(PGAContext *ctx, int Flag); |
---|
622 | void PGASetDebugFlag62(PGAContext *ctx, int Flag); |
---|
623 | void PGASetDebugFlag64(PGAContext *ctx, int Flag); |
---|
624 | void PGASetDebugFlag66(PGAContext *ctx, int Flag); |
---|
625 | void PGAPrintDebugOptions(PGAContext *ctx); |
---|
626 | |
---|
627 | /***************************************** |
---|
628 | * duplcate.c |
---|
629 | *****************************************/ |
---|
630 | |
---|
631 | |
---|
632 | int PGADuplicate(PGAContext *ctx, int p, int pop1, int pop2, int n); |
---|
633 | void PGAChange( PGAContext *ctx, int p, int pop ); |
---|
634 | void PGASetNoDuplicatesFlag( PGAContext *ctx, int no_dup); |
---|
635 | int PGAGetNoDuplicatesFlag (PGAContext *ctx); |
---|
636 | |
---|
637 | /***************************************** |
---|
638 | * evaluate.c |
---|
639 | *****************************************/ |
---|
640 | |
---|
641 | |
---|
642 | void PGASetEvaluation ( PGAContext *ctx, int p, int pop, double val ); |
---|
643 | double PGAGetEvaluation ( PGAContext *ctx, int p, int pop ); |
---|
644 | void PGASetEvaluationUpToDateFlag ( PGAContext *ctx, int p, int pop, |
---|
645 | int status ); |
---|
646 | int PGAGetEvaluationUpToDateFlag ( PGAContext *ctx, int p, int pop ); |
---|
647 | double PGAGetRealFromBinary(PGAContext *ctx, int p, int pop, int start, |
---|
648 | int end, double lower, double upper); |
---|
649 | double PGAGetRealFromGrayCode(PGAContext *ctx, int p, int pop, int start, |
---|
650 | int end, double lower, double upper); |
---|
651 | void PGAEncodeRealAsBinary(PGAContext *ctx, int p, int pop, int start, |
---|
652 | int end, double low, double high, double val); |
---|
653 | void PGAEncodeRealAsGrayCode(PGAContext *ctx, int p, int pop, int start, |
---|
654 | int end, double low, double high, double val); |
---|
655 | int PGAGetIntegerFromBinary(PGAContext *ctx, int p, int pop, int start, |
---|
656 | int end); |
---|
657 | int PGAGetIntegerFromGrayCode(PGAContext *ctx, int p, int pop, int start, |
---|
658 | int end); |
---|
659 | void PGAEncodeIntegerAsBinary(PGAContext *ctx, int p, int pop, int start, |
---|
660 | int end, int val); |
---|
661 | void PGAEncodeIntegerAsGrayCode(PGAContext *ctx, int p, int pop, int start, |
---|
662 | int end, int val); |
---|
663 | double PGAMapIntegerToReal (PGAContext *ctx, int v, int a, int b, double l, |
---|
664 | double u); |
---|
665 | int PGAMapRealToInteger(PGAContext *ctx, double r, double l, double u, int a, |
---|
666 | int b); |
---|
667 | |
---|
668 | /***************************************** |
---|
669 | * fitness.c |
---|
670 | *****************************************/ |
---|
671 | |
---|
672 | |
---|
673 | void PGAFitness ( PGAContext *ctx, int popindex ); |
---|
674 | int PGARank( PGAContext *ctx, int p, int *order, int n ); |
---|
675 | double PGAGetFitness ( PGAContext *ctx, int p, int pop ); |
---|
676 | int PGAGetFitnessType (PGAContext *ctx); |
---|
677 | int PGAGetFitnessMinType (PGAContext *ctx); |
---|
678 | double PGAGetMaxFitnessRank (PGAContext *ctx); |
---|
679 | void PGASetFitnessType( PGAContext *ctx, int fitness_type); |
---|
680 | void PGASetFitnessMinType( PGAContext *ctx, int fitness_type); |
---|
681 | void PGASetMaxFitnessRank( PGAContext *ctx, double fitness_rank_max); |
---|
682 | void PGAFitnessLinearNormal ( PGAContext *ctx, PGAIndividual *pop ); |
---|
683 | void PGAFitnessLinearRank ( PGAContext *ctx, PGAIndividual *pop ); |
---|
684 | void PGAFitnessMinReciprocal ( PGAContext *ctx, PGAIndividual *pop ); |
---|
685 | void PGAFitnessMinCmax ( PGAContext *ctx, PGAIndividual *pop ); |
---|
686 | void PGASetFitnessCmaxValue( PGAContext *ctx, double val); |
---|
687 | double PGAGetFitnessCmaxValue (PGAContext *ctx); |
---|
688 | |
---|
689 | /***************************************** |
---|
690 | * hamming.c |
---|
691 | *****************************************/ |
---|
692 | |
---|
693 | double PGAHammingDistance( PGAContext *ctx, int popindex); |
---|
694 | |
---|
695 | /***************************************** |
---|
696 | * heap.c |
---|
697 | *****************************************/ |
---|
698 | |
---|
699 | |
---|
700 | void PGADblHeapSort ( PGAContext *ctx, double *a, int *idx, int n ); |
---|
701 | void PGAIntHeapSort ( PGAContext *ctx, int *a, int *idx, int n ); |
---|
702 | |
---|
703 | /***************************************** |
---|
704 | * integer.c |
---|
705 | *****************************************/ |
---|
706 | |
---|
707 | |
---|
708 | |
---|
709 | void PGASetIntegerAllele (PGAContext *ctx, int p, int pop, int i, int value); |
---|
710 | int PGAGetIntegerAllele (PGAContext *ctx, int p, int pop, int i); |
---|
711 | void PGASetIntegerInitPermute ( PGAContext *ctx, int min, int max); |
---|
712 | void PGASetIntegerInitRange (PGAContext *ctx, int *min, int *max); |
---|
713 | int PGAGetIntegerInitType (PGAContext *ctx); |
---|
714 | int PGAGetMinIntegerInitValue (PGAContext *ctx, int i); |
---|
715 | int PGAGetMaxIntegerInitValue (PGAContext *ctx, int i); |
---|
716 | void PGAIntegerCreateString (PGAContext *ctx, int p, int pop, int InitFlag); |
---|
717 | int PGAIntegerMutation( PGAContext *ctx, int p, int pop, double mr ); |
---|
718 | void PGAIntegerOneptCrossover(PGAContext *ctx, int p1, int p2, int pop1, |
---|
719 | int c1, int c2, int pop2); |
---|
720 | void PGAIntegerTwoptCrossover( PGAContext *ctx, int p1, int p2, int pop1, |
---|
721 | int c1, int c2, int pop2); |
---|
722 | void PGAIntegerUniformCrossover(PGAContext *ctx, int p1, int p2, int pop1, |
---|
723 | int c1, int c2, int pop2); |
---|
724 | void PGAIntegerPrintString ( PGAContext *ctx, FILE *fp, int p, int pop); |
---|
725 | void PGAIntegerCopyString (PGAContext *ctx, int p1, int pop1, int p2, int pop2); |
---|
726 | int PGAIntegerDuplicate( PGAContext *ctx, int p1, int pop1, int p2, int pop2); |
---|
727 | void PGAIntegerInitString(PGAContext *ctx, int p, int pop); |
---|
728 | MPI_Datatype PGAIntegerBuildDatatype(PGAContext *ctx, int p, int pop); |
---|
729 | |
---|
730 | /***************************************** |
---|
731 | * mpi_stub.c |
---|
732 | *****************************************/ |
---|
733 | |
---|
734 | |
---|
735 | /***************************************** |
---|
736 | * mutation.c |
---|
737 | *****************************************/ |
---|
738 | |
---|
739 | |
---|
740 | |
---|
741 | int PGAMutate(PGAContext *ctx, int p, int pop); |
---|
742 | void PGASetMutationType( PGAContext *ctx, int mutation_type); |
---|
743 | int PGAGetMutationType (PGAContext *ctx); |
---|
744 | void PGASetMutationRealValue( PGAContext *ctx, double val); |
---|
745 | double PGAGetMutationRealValue (PGAContext *ctx); |
---|
746 | void PGASetMutationIntegerValue( PGAContext *ctx, int val); |
---|
747 | int PGAGetMutationIntegerValue (PGAContext *ctx); |
---|
748 | void PGASetMutationBoundedFlag(PGAContext *ctx, int val); |
---|
749 | int PGAGetMutationBoundedFlag(PGAContext *ctx); |
---|
750 | void PGASetMutationProb(PGAContext *ctx, double mutation_prob); |
---|
751 | double PGAGetMutationProb (PGAContext *ctx); |
---|
752 | |
---|
753 | /***************************************** |
---|
754 | * parallel.c |
---|
755 | *****************************************/ |
---|
756 | |
---|
757 | |
---|
758 | |
---|
759 | void PGARunGM(PGAContext *ctx, double (*f)(PGAContext *, int, int), |
---|
760 | MPI_Comm comm); |
---|
761 | void PGAEvaluateSeq(PGAContext *ctx, int pop, |
---|
762 | double (*f)(PGAContext *, int, int)); |
---|
763 | void PGAEvaluateCoop(PGAContext *ctx, int pop, |
---|
764 | double (*f)(PGAContext *, int, int), MPI_Comm comm); |
---|
765 | void PGAEvaluateMS(PGAContext *ctx, int pop, |
---|
766 | double (*f)(PGAContext *c, int p, int pop), MPI_Comm comm); |
---|
767 | void PGAEvaluateSlave(PGAContext *ctx, int pop, |
---|
768 | double (*f)(PGAContext *, int, int), MPI_Comm comm); |
---|
769 | void PGAEvaluate(PGAContext *ctx, int pop, |
---|
770 | double (*f)(PGAContext *, int, int), MPI_Comm comm); |
---|
771 | MPI_Datatype PGABuildDatatype(PGAContext *ctx, int p, int pop); |
---|
772 | void PGASendIndividual(PGAContext *ctx, int p, int pop, int dest, int tag, |
---|
773 | MPI_Comm comm); |
---|
774 | void PGAReceiveIndividual(PGAContext *ctx, int p, int pop, int source, int tag, |
---|
775 | MPI_Comm comm, MPI_Status *status); |
---|
776 | void PGASendReceiveIndividual(PGAContext *ctx, int send_p, int send_pop, |
---|
777 | int dest, int send_tag, int recv_p, int recv_pop, |
---|
778 | int source, int recv_tag, MPI_Comm comm, |
---|
779 | MPI_Status *status); |
---|
780 | void PGARunIM(PGAContext *ctx, double (*f)(PGAContext *c, int p, int pop), |
---|
781 | MPI_Comm tcomm); |
---|
782 | void PGARunNM(PGAContext *ctx, double (*f)(PGAContext *c, int p, int pop), |
---|
783 | MPI_Comm tcomm); |
---|
784 | int PGAGetRank (PGAContext *ctx, MPI_Comm comm); |
---|
785 | int PGAGetNumProcs (PGAContext *ctx, MPI_Comm comm); |
---|
786 | void PGASetNumIslands( PGAContext *ctx, int n); |
---|
787 | int PGAGetNumIslands (PGAContext *ctx); |
---|
788 | void PGASetNumDemes( PGAContext *ctx, int numdemes); |
---|
789 | int PGAGetNumDemes (PGAContext *ctx); |
---|
790 | void PGASetCommunicator( PGAContext *ctx, MPI_Comm comm); |
---|
791 | MPI_Comm PGAGetCommunicator( PGAContext *ctx); |
---|
792 | |
---|
793 | /***************************************** |
---|
794 | * pga.c |
---|
795 | *****************************************/ |
---|
796 | |
---|
797 | |
---|
798 | void PGARun(PGAContext *ctx, double (*evaluate)(PGAContext *c, int p, int pop)); |
---|
799 | void PGARunMutationAndCrossover (PGAContext *ctx, int oldpop, int newpop); |
---|
800 | void PGARunMutationOrCrossover ( PGAContext *ctx, int oldpop, int newpop ); |
---|
801 | void PGAUpdateGeneration(PGAContext *ctx, MPI_Comm comm); |
---|
802 | int PGAGetDataType (PGAContext *ctx); |
---|
803 | int PGAGetOptDirFlag (PGAContext *ctx); |
---|
804 | int PGAGetStringLength (PGAContext *ctx); |
---|
805 | int PGAGetVariableStringLength (PGAContext *ctx, int p, int pop); |
---|
806 | int PGAGetGAIterValue (PGAContext *ctx); |
---|
807 | void PGASetMutationOrCrossoverFlag( PGAContext *ctx, int flag); |
---|
808 | void PGASetMutationAndCrossoverFlag( PGAContext *ctx, int flag); |
---|
809 | int PGAGetMutationOrCrossoverFlag (PGAContext *ctx); |
---|
810 | int PGAGetMutationAndCrossoverFlag (PGAContext *ctx); |
---|
811 | |
---|
812 | /***************************************** |
---|
813 | * pop.c |
---|
814 | *****************************************/ |
---|
815 | |
---|
816 | |
---|
817 | void PGASortPop ( PGAContext *ctx, int pop ); |
---|
818 | int PGAGetPopSize (PGAContext *ctx); |
---|
819 | int PGAGetNumReplaceValue (PGAContext *ctx); |
---|
820 | int PGAGetPopReplaceType (PGAContext *ctx); |
---|
821 | int PGAGetSortedPopIndex ( PGAContext *ctx, int n ); |
---|
822 | void PGASetPopSize (PGAContext *ctx, int popsize); |
---|
823 | void PGASetNumReplaceValue( PGAContext *ctx, int pop_replace); |
---|
824 | void PGASetPopReplaceType( PGAContext *ctx, int pop_replace); |
---|
825 | |
---|
826 | /***************************************** |
---|
827 | * random.c |
---|
828 | *****************************************/ |
---|
829 | |
---|
830 | |
---|
831 | int PGARandomFlip ( PGAContext *ctx, double p ); |
---|
832 | int PGARandomInterval( PGAContext *ctx, int start, int end); |
---|
833 | double PGARandom01( PGAContext *ctx, int newseed ); |
---|
834 | double PGARandomUniform( PGAContext *ctx, double start, double end); |
---|
835 | double PGARandomGaussian( PGAContext *ctx, double mean, double sigma); |
---|
836 | int PGAGetRandomSeed(PGAContext *ctx); |
---|
837 | void PGASetRandomSeed(PGAContext *ctx, int seed); |
---|
838 | |
---|
839 | /***************************************** |
---|
840 | * real.c |
---|
841 | *****************************************/ |
---|
842 | |
---|
843 | |
---|
844 | void PGASetRealAllele (PGAContext *ctx, int p, int pop, int i, double value); |
---|
845 | double PGAGetRealAllele (PGAContext *ctx, int p, int pop, int i); |
---|
846 | void PGASetRealInitPercent ( PGAContext *ctx, double *median, double *percent); |
---|
847 | void PGASetRealInitRange (PGAContext *ctx, double *min, double *max); |
---|
848 | double PGAGetMinRealInitValue (PGAContext *ctx, int i); |
---|
849 | double PGAGetMaxRealInitValue (PGAContext *ctx, int i); |
---|
850 | int PGAGetRealInitType (PGAContext *ctx); |
---|
851 | void PGARealCreateString (PGAContext *ctx, int p, int pop, int initflag); |
---|
852 | int PGARealMutation( PGAContext *ctx, int p, int pop, double mr ); |
---|
853 | void PGARealOneptCrossover( PGAContext *ctx, int p1, int p2, int pop1, |
---|
854 | int c1, int c2, int pop2); |
---|
855 | void PGARealTwoptCrossover( PGAContext *ctx, int p1, int p2, int pop1, |
---|
856 | int c1, int c2, int pop2); |
---|
857 | void PGARealUniformCrossover( PGAContext *ctx, int p1, int p2, int pop1, |
---|
858 | int c1, int c2, int pop2); |
---|
859 | void PGARealPrintString (PGAContext *ctx, FILE *fp, int p, int pop); |
---|
860 | void PGARealCopyString ( PGAContext *ctx, int p1, int pop1, int p2, int pop2); |
---|
861 | int PGARealDuplicate( PGAContext *ctx, int p1, int pop1, int p2, int pop2); |
---|
862 | void PGARealInitString ( PGAContext *ctx, int p, int pop); |
---|
863 | MPI_Datatype PGARealBuildDatatype(PGAContext *ctx, int p, int pop); |
---|
864 | |
---|
865 | /***************************************** |
---|
866 | * report.c |
---|
867 | *****************************************/ |
---|
868 | |
---|
869 | |
---|
870 | void PGAPrintReport(PGAContext *ctx, FILE *fp, int pop); |
---|
871 | void PGASetPrintOptions (PGAContext *ctx, int option); |
---|
872 | void PGASetPrintFrequencyValue( PGAContext *ctx, int print_freq); |
---|
873 | int PGAGetPrintFrequencyValue (PGAContext *ctx); |
---|
874 | void PGAPrintPopulation ( PGAContext *ctx, FILE *fp, int pop ); |
---|
875 | void PGAPrintIndividual ( PGAContext *ctx, FILE *fp, int p, int pop ); |
---|
876 | void PGAPrintString ( PGAContext *ctx, FILE *file, int p, int pop ); |
---|
877 | void PGAPrintContextVariable ( PGAContext *ctx, FILE *fp ); |
---|
878 | |
---|
879 | /***************************************** |
---|
880 | * restart.c |
---|
881 | *****************************************/ |
---|
882 | |
---|
883 | void PGARestart(PGAContext *ctx, int source_pop, int dest_pop); |
---|
884 | void PGASetRestartFlag(PGAContext *ctx, int val); |
---|
885 | int PGAGetRestartFlag(PGAContext *ctx); |
---|
886 | void PGASetRestartFrequencyValue(PGAContext *ctx, int numiter); |
---|
887 | int PGAGetRestartFrequencyValue(PGAContext *ctx); |
---|
888 | void PGASetRestartAlleleChangeProb(PGAContext *ctx, double prob); |
---|
889 | double PGAGetRestartAlleleChangeProb(PGAContext *ctx); |
---|
890 | |
---|
891 | /***************************************** |
---|
892 | * select.c |
---|
893 | *****************************************/ |
---|
894 | |
---|
895 | void PGASelect( PGAContext *ctx, int popix ); |
---|
896 | int PGASelectNextIndex ( PGAContext *ctx ); |
---|
897 | void PGASetSelectType( PGAContext *ctx, int select_type); |
---|
898 | int PGAGetSelectType (PGAContext *ctx); |
---|
899 | void PGASetPTournamentProb(PGAContext *ctx, double ptournament_prob); |
---|
900 | double PGAGetPTournamentProb(PGAContext *ctx); |
---|
901 | int PGASelectProportional(PGAContext *ctx, PGAIndividual *pop); |
---|
902 | void PGASelectSUS( PGAContext *ctx, PGAIndividual *pop ); |
---|
903 | int PGASelectTournament( PGAContext *ctx, PGAIndividual *pop ); |
---|
904 | int PGASelectPTournament( PGAContext *ctx, PGAIndividual *pop ); |
---|
905 | |
---|
906 | /***************************************** |
---|
907 | * stop.c |
---|
908 | *****************************************/ |
---|
909 | |
---|
910 | int PGADone(PGAContext *ctx, MPI_Comm comm); |
---|
911 | int PGACheckStoppingConditions( PGAContext *ctx); |
---|
912 | void PGASetStoppingRuleType (PGAContext *ctx, int stoprule); |
---|
913 | int PGAGetStoppingRuleType (PGAContext *ctx); |
---|
914 | void PGASetMaxGAIterValue(PGAContext *ctx, int maxiter); |
---|
915 | int PGAGetMaxGAIterValue (PGAContext *ctx); |
---|
916 | void PGASetMaxNoChangeValue(PGAContext *ctx, int max_no_change); |
---|
917 | void PGASetMaxSimilarityValue(PGAContext *ctx, int max_similarity); |
---|
918 | |
---|
919 | /***************************************** |
---|
920 | * system.c |
---|
921 | *****************************************/ |
---|
922 | |
---|
923 | |
---|
924 | void PGAError( PGAContext *ctx, char *msg, |
---|
925 | int level, int datatype, void *data ); |
---|
926 | void PGADestroy (PGAContext *ctx); |
---|
927 | void PGADestroyUD (PGAContext *ctx,int,int); |
---|
928 | int PGAGetMaxMachineIntValue (PGAContext *ctx); |
---|
929 | int PGAGetMinMachineIntValue (PGAContext *ctx); |
---|
930 | double PGAGetMaxMachineDoubleValue (PGAContext *ctx); |
---|
931 | double PGAGetMinMachineDoubleValue (PGAContext *ctx); |
---|
932 | void PGAUsage( PGAContext *ctx ); |
---|
933 | void PGAPrintVersionNumber( PGAContext *ctx ); |
---|
934 | |
---|
935 | /***************************************** |
---|
936 | * user.c |
---|
937 | *****************************************/ |
---|
938 | |
---|
939 | |
---|
940 | void PGASetUserFunction(PGAContext *ctx, int constant, void *f); |
---|
941 | |
---|
942 | /**************************************************************************/ |
---|
943 | /* EHW project Modification ( ADDITION OF FUNCTION ) */ |
---|
944 | /* This function returns the size of the user data vector in all */ |
---|
945 | /* individual's chromosome vector */ |
---|
946 | /**************************************************************************/ |
---|
947 | int PGAGetSizeUD(PGAContext *ctx); |
---|
948 | |
---|
949 | /**************************************************************************/ |
---|
950 | /* EHW project Modification ( ADDITION OF FUNCTION ) */ |
---|
951 | /* This function sets the size of the user data vector in all */ |
---|
952 | /* individual's chromosome vector */ |
---|
953 | /**************************************************************************/ |
---|
954 | void PGASetSizeUD(PGAContext *ctx,int s); |
---|
955 | |
---|
956 | /**************************************************************************/ |
---|
957 | /* EHW project Modification ( ADDITION OF FUNCTION ) */ |
---|
958 | /* This function gets the user data vector in all */ |
---|
959 | /* individual's chromosome vector */ |
---|
960 | /**************************************************************************/ |
---|
961 | void *PGAGetUD(PGAContext *ctx,int s,int pop); |
---|
962 | |
---|
963 | |
---|
964 | /***************************************** |
---|
965 | * utility.c |
---|
966 | *****************************************/ |
---|
967 | |
---|
968 | |
---|
969 | double PGAMean ( PGAContext *ctx, double *a, int n); |
---|
970 | double PGAStddev ( PGAContext *ctx, double *a, int n, double mean); |
---|
971 | int PGARound(PGAContext *ctx, double x); |
---|
972 | void PGACopyIndividual( PGAContext *ctx, int p1, int pop1, int p2, int pop2); |
---|
973 | int PGACheckSum(PGAContext *ctx, int p, int pop); |
---|
974 | int PGAGetWorstIndex(PGAContext *ctx, int pop); |
---|
975 | int PGAGetBestIndex(PGAContext *ctx, int pop); |
---|
976 | PGAIndividual *PGAGetIndividual ( PGAContext *ctx, int p, int pop); |
---|
977 | void PGAUpdateAverage(PGAContext *ctx, int pop); |
---|
978 | void PGAUpdateOnline(PGAContext *ctx, int pop); |
---|
979 | void PGAUpdateOffline(PGAContext *ctx, int pop); |
---|
980 | int PGAComputeSimilarity(PGAContext *ctx, PGAIndividual *pop); |
---|
981 | |
---|
982 | |
---|
983 | #endif |
---|