So in general when you perform a crossover in GA, you directly flip a random section in the "genome", with the corresponding section in the other parent, and mutate it based on the mutation rate.
Consider the sequences below:
0100 1000 0001 1011
0010 0110 1101 1111
A crossover without any mutation might look like this:
0100 0110 1101 1011
0010 1000 0001 1111
In that case, blocks 2 and 3 were swapped and blocks 1 and 4 remained unchanged.
I'm unsure how that would work in GP with abstract syntax trees however, because there is no guarantee that the point in the abstract tree you reference in the first parent will be compatible with the section from the second parent, for example one section might have a return type of boolean while the other has a return type of string, such as in the example below:
p1
/ \
b i
/\ /\
b f i s
p2
/ \
s b
/\ /\
i n s i
if you were to try to crossover branch 1 from parent 1 which has a return type of b, with branch 1 from parent 2 which has a return type of s, it would create a syntax error if it were to be ran, so how would I correctly perform a crossover on an AST, specific examples would be appreciated.
What I have tried:
I have done some research on the subject but from what I can tell the algorithms I have found assume uniformity among return types.