John Porter writes:
> The class is hard-wired to only handle individuals which are > bitvectors. > That is unnecessarily restrictive. In fact, the GA algorithm Is it really restrictive? As I said, I'm not really an expert in this field, but the way I see it is that if the user wants more than a single bit to represent a given feature, then he/she can still use the module the way it is, but will have to do some manual high level grouping of the bits to get the information needed. This leads me to think that maybe a multidimentional bit vector can be implemented instead of the single dimentional one I have right now. What other representations can be used for the genetic string other than bit vectors? > shouldn't > care about the internal representation of the individual. Make a > separate class for bitvector individuals; it can implement a some > necessary methods -- mutute, crossover, fitness -- which GA will then > call. GA itself should only implement the evolutionary process. Let me see if I understand you correctly. I should have an AI::Genetic::Individual class that handles the representation of each individual. This class may or may not use bit vectors as an internal representation. It also implements all the evolutionary methods. All the AI::Genetic module itself does is to instantiate the individuals, and to call their evolutionary methods according to what the user requested. This approach seems more suitable (it doesn't need to change the API, but at this point, I don't really care if it does), and lends itself quite nicely to any additional extensions to the module. > Also, consider making the generation process (creating the next gen > from the previous) a Strategy, since this could be rather more complex > than the simple "select/mutate/crossover" pipeline you've got now. > If you do that, then the strategy object would also be a good place > to store the parametrics (mutution prob., etc.). So, a default strategy would be to evolve each generation according to the current process (namely selection -> crossover -> mutation). But, there can be other defined strategies, and the users should be able to create their own simply by combining those three steps however they like. I like that! > How to handle identical individuals? Why is it a problem? I thought maybe I can improve the speed of the processing by eliminating duplicates, but maybe it's not such a good idea. After all, if there are many individuals with the same genes, then there is a reason for this and this will favour them more in keeping their genes alive in generations to come. Thanks a lot for your input. And, please keep 'em comin' :) Ala