Skip to Content
Author's profile photo Former Member

Genetic Algorithms: Introducing JGAP

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

Using JGAP

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.

Assigned tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Mark Finnern
      Mark Finnern
      Hi Klaus,

      Thanks for pointing out ways to get into programing Genetic Algorithms.

      If fellow SDN Members would like to know about the possibilities, check out the book "Swarm Intelligence" from Eric Bonabeau. I once saw him present his findings and they were really amazing.

      Especially in the area of optimization to bring in these genetic algorithms would make a tremendous difference.

      Keep it up, Mark.

      Author's profile photo Former Member
      Former Member
      I've read your Article and found it very interesting. The JGAP project is indeed nice. We were happy to see such a good GA project. We're developing a distributed Framework for randomized heuristic searches like GA and randomized Hill Climbing ourselvs too, called DGPF ( It can be adapted to any possible problem space easily but comes with a built-in ability for Genetic Programming of Turing-complete code.
      Maybe it could be interesting for you too.
      Author's profile photo Former Member
      Former Member
      Blog Post Author
      Hi Klaus,

      believe it or not, but I already had a look at DGPF. In the JGAP task list the distributed computing issue is present since last year, I think.

      Maybe you could contact me via mail (via sourceforge's site of JGAP, I'm JGAP's administrator), I could not figure out your mail address. I would like to know how to best use DGPF with JGAP.