Can standard representation trees in genetic programming (GP) contain operators such as if then?

242 views Asked by At

Reading about representation trees, almost all the texts only contain numeric operators such as plus, minus, times, etc... However, a few casually have "if then" operators in there. I'm really confused on whether this is shared trough every version of representation trees or whether it is something only a small amount of programs have.

1

There are 1 answers

0
avysk On

It is definitely possible to use if as one of the functions allowed in the trees, but there is a catch. Usual if takes three inputs: condition, then-result and else-result. Very often those are of different types -- condition is boolean, and then-result/else-result are something else (numerical). If you insert such if in your tree, you break type consistency -- not every subtree produces the result of the same type. This causes difficulties at, for example, crossover, as you cannot just take any subtree of if and replace it with some random subtree from the second parent -- it may be of the wrong type.

So the common solutions are:

  • either make crossover / mutation operators type-aware;
  • or use some kind of type consistent if; for example, you can consider if to be a function with 4 numerical inputs f(a, b, c, d) which returns c if a > b and d otherwise. In this case all subtrees still expected to produce the values of the same type, and no additional fiddling with crossover and mutation is needed. Of course, you can simplify this to three-input if: return b if a is positive, c otherwise. However, as far as I know, this approach is often considered (at least in some literature, section 3.2.1) as "possible introduction of unexpected bias" and is not recommended over 4-input if.