gabump
find a bump's peak with a genetic algorithm
gabump -help
or
gabump [-target double] [-var double] [-size integer]
[-len integer] [-gens integer] [-seed integer]
[-crate double] [-mrate double]
Uses a genetic algorithm to find the maximum of a single-humped function that is centered at a user-specified location. This program serves as an example of how GAs can be used to optimize functions which take a floating-point argument.
Use a genetic algorithm to find the maximum of a singlehumped function that is centered at a user-specified location. This program serves as an example of how GAs can be used to optimize functions which take a floating point argument. Reproduction of strings entails crossover and mutation with strings being selected based on fitness.
Miscellany
The bit strings are converted to floating point numbers with the formula (8 * int(string) / 2^len - 4) where int(string) is the integer value of a binary string. Thus, all numbers are forced to be between -4 and 4.
A more sophisticated GA encoding would use Gray codes to represent the floating point numbers which arguably are better behaved under mutation.
Bugs
No sanity checks are performed to make sure that any of the options make sense.
Options
-target | Target value for function. | 0.5 |
-var | Variance of bump. | 1.0 |
-size | Population size. | 10 |
-len | DNA length. | 16 |
-gens | Number of generations. | 50 |
-seed | Random seed. | 0 |
-crate | Crossover rate. | 0.25 |
-mrate | Mutation rate. | 0.01 |