On a Genetic Algorithm, would it be correct to make the Fitness Function something other than a mathematical ecuation? Could it have a recursive function and a loop inside of it?
The thing is I'm evaluating if I can work with Genetic Algorithms for my thesis and this fitness function I'm thinking about could be a little complicated. But maybe not, I'll just have to make sure the program can handle such function and it doesn't create a bottleneck, right?.
Basic idea:
FitnessFunction(){
fitness = RecursiveFunction();
}
RecursiveFunction(){
do{
//Do something
}while(other_condition);
if(another_condition){
return RecursiveFunction();
}
return fitness;
}
It will be a bottleneck, but that is expected. The evaluation function usually takes the great majority of the execution time, since the genetic operators (crossover, mutation) are very simple operations in comparison. I've seen GA where the evaluation function is to simulate a house structure receiving an earthquake, so you should be fine.
Is worth, however, that you isolate, measure the time and try to optimize the function as much as possible. Consider that it will run for hundreds or thousands of individuals, for many generations, and you will repeat the whole process a lot, tweaking parameters and your GA implementation.