You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Joshua Moerman
26e0a2ccb7
|
10 years ago | |
---|---|---|
lib | 10 years ago | |
src | 11 years ago | |
.gitignore | 11 years ago | |
CMakeLists.txt | 10 years ago | |
README.md | 11 years ago |
README.md
Genetic Sequence Formulizer
This program will take a sequence entered by the user and tries to find a formula producing this sequence. I made this to play around with genetic programming. Inspired by the following two talks:
- Reducing Wasted Evaluations in Cartesian Genetic Programming, by Brian Goldman
- Automatic Algorithm Invention with a GPU, by Wes Faler
I used a technique similar to the one described in the first presentation (the one called single), as it seemed to be the easiest one. The nice thing is that there is always just one parent, but there are inactive genes which are allowed to mutate freely.
Examples
Some actual output of the program (truncated):
$ ./main 0 0 0 0 0 0 0
your input: 0, 0, 0, 0, 0, 0, 0,
formula: (x-x)*x
continuation: 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...
$ ./main 1 2 3
your input: 1, 2, 3,
formula: ((x-18)/(x-18))+x
continuation: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, ...
$ ./main 1 2 4 8
your input: 1, 2, 4, 8,
formula: 2^x
continuation: 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, ...
$ ./main 37
your input: 37,
formula: (10+12)+15
continuation: 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
Notes
- The algorithm does not yet simplify the formula (I should take this into account when scoring the genes).
- The sequences are 0-based.
- The constants used in the genes are bound to 20 (so in the last example, it needed multiple constants added).
- It treats
1/0
asINT_MAX
(we need some safety as we evaluate randomly generated expressions). - I may be using some c++14 features. Install a new clang or gcc to get this awesomeness.