Installing JGAP in 5 minutes

[JGAP Home]


Short introduction

JGAP is a framework written in Java. It is not an application you can run like an executable. But there is an example provided with JGAP you can run by using the command line (or a batch file, preferrably). As I am running Windows as operating system, the following description is somewhat orientated on that. But JGAP is a  piece of Java and therefor able to be run on other systems as well!

Laying ground

1 First, download the JGAP package from the sourceforge site. You can use this link to get to the list of available JGAP files. Make sure you get the full installation (jgap_xxx_full.zip), not only the source code as the source would need to be compiled before executing anything! If you know how to compile Java source, then do it. This is a simple tutorial.
2 After that, extract the files to a directory of your choice, say to directory named jgap-current somewhere on your harddisk.
3

Open this directory in a file manager of your choice, like Windows Explorer for Windows systems or another one for *NIX systems.
There is no need for registry entries, and no entry will be created in the start-menu of Windows.

4 In the directory you put JGAP in and opened in your explorer, there should be some files ending with .jar. These files contain the compiled JGAP distribution and that is all we need for now. Please notice that there are some dependencied to external libraries. You find all these jar files in the sub directory lib.

Running the example

5 Windows: Start the example by executing the batch file start_example.bat.

Other operating systems: Go to the command line and change your working directory to jgap-current. Now type the following:

java -classpath ".;jgap-examples.jar;jgap.jar" examples.MinimizingMakeChange 89

Ubuntu Linux: As before but with the following (use the double-colon instead of the semicolon for separating classpath components):

java -classpath ".:jgap-examples.jar:jgap.jar" examples.MinimizingMakeChange 89

6 In case you use classes that rely on external libraries, you have to add these jar files to the class path in previous step five. For example, if you run a class that utilizes the WeightedRouletteSelector class from package org.jgap.impl you will have to add the file lib/trove-2.0.2.jar to the classpath. For running the above example, this is not necessary!

That's it! On your console there should appear something like (an example, your output may vary as a Genetic Algorithm involves randomness):

WordPress Hosting

The best solution has a fitness value of 1599.0
It contained the following:
       3 quarters.
       1 dimes.
       0 nickels.
       4 pennies.
For a total of 89 cents in 8 coins.

Investigating the sources

7

JGAP can be compiled with Java version 5 or later. If you have  to use Java 1.4, you should get along with not too much  modifications.

If you want to code your own genetic algorithm by using JGAP, a good starting point is the examples provided with JGAP.

We suggest you have a look at the class examples.simpleBoolean.SimpleExample. Try to understand what happens there, modify and extend the example's code, run it and see what happens. Also have a look at the other examples shipped with JGAP.

Investigating the test cases

8

To get even more behind the scenes, investigate into the test cases. You find them under sub directory tests. It really might help studying the test code to understand how JGAP is supposed to work. 

Still problems?

If you still have problems running the JGAP example or getting JGAP up and running in general, don't hesitate posting your question to the JGAP forum here! Or look at the main page of this site to get further contact information