Skip to content

Latest commit

 

History

History
13 lines (10 loc) · 1.29 KB

README.md

File metadata and controls

13 lines (10 loc) · 1.29 KB

Genetic Programming

Genetic programming was derived from the model of biological evolution. At first we generate random trees that holds p, r, h strings and " * , / , +, -" operations as string. As you know, area of the cylinder is 2xpxrxh and volume is pxr^2xh. Then we randomly crossover tree's genes that generated randomly. After crossovers our radiation session starts! We randomly mutate our trees genes. At last, we kill all the trees that are under some threshold. Repeat these steps until there are few trees left. Finally, we can print all the remaining trees!

Main Program

9

Finding the area of the cylinder formula

10

Wait!? This looks like wrong! but actually it is not. Program traverse our trees in infix order and we do not have parenthesis, so actually this is "pxhx(r+r) = pxhx2r"

Now let's try to find the volume of the cylinder formula

11

Again, it looks wrong at first glance but it is NOT! We actually multiply h by h then divide by h, this is equivalent to h.