JGAP – A Framework For Genetic Algorithms
There are several frameworks available to help you building up your own GA implementation without coping with the sticky details. One of these frameworks is JGAP. I have been involved in developing it after the ground was laid. JGAP can be used as a startup basis as it provides basic functionality as well as the possibility of easily extending the system and modifying the underlying algorithms; Although JGAP’s complexity is rising steadily since the last few months.
JGAP sets you into the position concentrating on the real problems of a GA: Setting up a fitness function, choosing a representation for your problem and fine-tuning the parameters. No need to hassle around with those boring stuff like programming random functions, genetic operators and so on. Although it is possible to implement your own extensions quite easily.
Implementing a GA
With JGAP comes a simple example demonstrating the procedure of using the framework. The story behind the example is: For a given number between 1 and 100 find the minimum set of coins required to reach the given number in summation. The coin values available are 25, 10, 5, 2 and 1.
The Fitness Function
The fitness function is measuring the quality or fitness of a solution encoded by the internal state of an individual. In our example we just would calculate the difference between the number to be reached, say 100, and the number reached by the individual (using coins of several valences).
Representing an Individual
For the example an individual could be represented as a chromosome consisting of 5 IntegerGenes. An IntegerGene is a JGAP class and represents an integer number, that’s easy. In our case, the index of the IntegerGene (1 to 5) would indicate the coin to use (25, 10 etc.). Additionally, the value of the IntegerGene would determine the number of coins of a certain value (25, 10…) to use.
With that we can easily encode possible solutions without knowing the solution exactly. And the fitness function could easily evaluate the state (resp. the coin value) of each single individual within the population.
With JGAP it is easy to implement Genetic Algorithms. It is offering all basic functionalities required to do so. Hosted at sourceforge you can use it freely and therefor be able to “go for gold” with evolutionary algorithms at no cost. Admitted: GA’s – or generally speaking: EA’s – are not a solution to any problem. They do not make you a magician. But for some problems they are definitively better than other algorithms (take the NASA who designed an antenna for space with help of GA’s).
Watch out for other frameworks, like ECJ by Sean Luke. ECJ is more complex than JGAP which means it is more powerful on the one hand but you need more effort implementing your solution on the other hand.
Also see Genetic Programming: Coding Progress for further information on the subject of Evolutionary Programming.