I have a genetic algorithm/programming problem where I need the best arrange of items in a binary tree. My question is the best way to mutate/cross this binary tree subject to constraints described below.
All items need to be leaves in this binary tree and there are no nodes with only one branch populated. That is, all nodes are attached to two items and/or branches. So for example, this could work where 8, 9, 5, 6, 7 are items and all nodes have two branches:
This would not work because node 10 has only one branch:
My goal is to find the best binary tree arrangement of the items subject to an evaluation function, so all items have to be present.
For mutation, I thought about swapping nodes in this tree, but what would be a good algorithm for this? Clearly, we pick two nodes, and swap their attachments. But it is tricky, because one node cannot be the parent of another, otherwise attachment does not work.
Are there established algorithms for crossover/mutation for this problem setup where a binary tree needs to be mutated assuming all items are leaves and must be present?