How to structure a Genetic Algorithm class hierarchy?
Posted
by MahlerFive
on Stack Overflow
See other posts from Stack Overflow
or by MahlerFive
Published on 2009-11-27T17:43:30Z
Indexed on
2010/05/17
4:20 UTC
Read the original article
Hit count: 461
I'm doing some work with Genetic Algorithms and want to write my own GA classes. Since a GA can have different ways of doing selection, mutation, cross-over, generating an initial population, calculating fitness, and terminating the algorithm, I need a way to plug in different combinations of these. My initial approach was to have an abstract class that had all of these methods defined as pure virtual, and any concrete class would have to implement them. If I want to try out two GAs that are the same but with different cross-over methods for example, I would have to make an abstract class that inherits from GeneticAlgorithm and implements all the methods except the cross-over method, then two concrete classes that inherit from this class and only implement the cross-over method. The downside to this is that every time I want to swap out a method or two to try out something new I have to make one or more new classes.
Is there another approach that might apply better to this problem?
© Stack Overflow or respective owner