darwins-challenge / moonlander-ast-rust

Code to create, manipulate and evaluate abstract syntax tree for the moonlander control code in Rust
http://darwins-challenge.github.io/moonlander-ast-rust
MIT License
1 stars 0 forks source link

Prepare genetic algorithms for abstract syntax tree #2

Closed dvberkel closed 8 years ago

dvberkel commented 8 years ago

Genetic programming

In artificial intelligence, genetic programming (GP) is an evolutionary algorithm-based methodology inspired by biological evolution to find computer programs that perform a user-defined task. Essentially GP is a set of instructions and a fitness function to measure how well a computer has performed a task.

should be able to safely bring a lander to the surface of the moon. Create the various kinds of genetic operations on abstract syntax trees.

dvberkel commented 8 years ago

I have been musing on the various genetic operations on the moon lander program structure.

Specifically I want to raise the following concerns

Mutable or Immutable?

Should the operations mutate the program structure or should a copy be made.

Mutate recursively?

Should mutation mutate recursively? The idea behind mutation is to allow programs to escape local optima by having a small chance of changing. The problem is that with larger programs, even with a small probability of mutation for each kind of structure, we could end up mutation a lot.

Should crossover be commutative?

I have the feeling that crossovers should be commutative. I.e. For two programs p and q I feel that crossover(p,q) and crossover(q,p should be the same, in the sense that they should produce programs according to the same distribution.

The reason I am raising this concern is that with the implementation of crossover I have in mind, i.e. pick a random node of p and try to crossover with a similar random node in q, seems depend on the program you start with.

The simplest solution that springs to mind, if it is a problem at all, is to crossover twice to allow both crossover(p,q) and crossover(q,p).

rix0rrr commented 8 years ago

I've gotten most of my knowledge from this page, which provides a good overview yet is very accessible (imho):

http://geneticprogramming.us/Genetic_Operations.html

My take on this:

dvberkel commented 8 years ago

I will take a look at the link you provided.

rix0rrr commented 8 years ago

I suppose actually the arity doesn't matter. I feel like if we swap any 2 subtrees we should be good.

dvberkel commented 8 years ago

Actually the program should be grammatically correct. So you can not just swap any two subtrees. See structure

rix0rrr commented 8 years ago

Ah, of course!

Well, we can make a list of node types that occur in both trees and draw randomly from that list. They must share at least one--even if it's only the root, which will always be the same type.

dvberkel commented 8 years ago

Genetic algorithms are implemented in the darwin module