🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

General GA class

Started by
5 comments, last by edotorpedo 22 years, 6 months ago
Well, I finished my *general* neuralnet-dll, which can create any kind of network (for example a 1000-324-321432 network). Now I want to build a *general* GA-dll, which can provide a solution to all problems that can be handled with GA''s. Thinking about the implementation, how do I create a standard fitness function? This function always depends on the problem at hand. Has anyone encountered the same problem or perhaps solved this ? Thanks, Edotorpedo PS: don''t start yelling about my spelling, I''m Dutch.
Edo
Advertisement
A general fitness function is not possible. Perhaps the user can provide a pointer to a function which will serve as the fitness function. Or the user can overload the fitness function and provide their own implementation.

-Kirk
Or alternatively, write a symbolic text parser so that the user can enter the fitness function either via file input or GUI.

You face another, more difficult problem if you want to implement a generalised GA class: that of the encoding scheme implemented. The chosen encoding of the domain (state) variables into a ''genetic chromosome'' dictates the performance of the GA through the effectiveness of the genetic operators on that encoding. Additionally, the implementation of two of the three operators of the canonical GA - namely crossover and mutation (selection being the third) - depend directly on the encoding scheme chosen.

So, somehow you need to implement an encoding scheme that will handle any domain for which a user wishes to optimise a user defined fitness function.

Your task is not an easy one. Good luck with it.

Cheers,

Timkin
Of course you could choose a binary encoding, with binary operators for mutation and crossover, the problem with that is the mutation operators might cause huge jumps in the values. Say you have an integer stored as 32 bits. A change at one end only has a small effect on the final value, a change at the other end has an enourmous effect. This is why grey (or gray) coding was invented, to reinvent the way bits were interpreted for integers for GA''s specifically (it reorders the bits so that any single value change will only alter the integer by one). A small change in the genotype should _always_ have a small effect in the phenotype.

Mike
Not quite what I meant Mike. Most users of GA''s accept the use of either a binary or Gray codes.

The problem I was alluding to was that it is VERY difficult to come up with a single mapping from the set of arbitrary domains to a chromosome. A domain can be continuous or discrete, or a mixture of both. The most common way to deal with continuous variables is to discretise them. Then of course, you need to decide on the resolution of the disretisation. Finding a mapping is generally domain dependent and hence not something that is easily generalised.

Cheers,

Timkin
I should have thought of this sooner, but have you checked out GALib by Matthew Wall? It is a general GA/EP library which is fully open and free to use. Matthew has put a huge amount of effort into this and it performs fantastically.

http://lancet.mit.edu/ga/


-Kirk
Genericity is over-rated Passing the pointer to the fitness function, and using that as a hook sounds like a good plan. That''s the approach Matthew took, except in a C++ friendly / legal fashion!

I did the opposite, a server based approach, where the GA class is not in control. The game engine runs normally, and regularly reports individuals back to the GA with the corresponding fitness. It can then request new instances.... it works great for online evolution, which is a major problem with the standard approach.

As for genotypes and phenotypes, yes... keep the search space smooth by avoiding fractures in fitness space. Floating point based genotypes are a good idea for this reason.


Artificial Intelligence Depot - Maybe it''s not all about graphics...

Join us in Vienna for the nucl.ai Conference 2015, on July 20-22... Don't miss it!

This topic is closed to new replies.

Advertisement