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!
|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.|
Open this directory in a file manager of your choice, like Windows Explorer
for Windows systems or another one for *NIX systems.
|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.|
|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):
The best solution has a fitness value of 1599.0
It contained the following:
For a total of 89 cents in 8 coins.
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.
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.
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
Copyright © 2005-2017 Dr. Klaus Meffert. All rights reserved.