Galapagos
A Genetic Algorithm Framework in Java
Home

...by Andy Meneely
in his Senior Project at Calvin College.

Runner Documentation

Galapagos comes with a "runner" mechanism which allows the user to simply define and run their genetic algorithm in an XML file. This way is a good way to keep all of your preferences all in one place.

When to Use the Runner

For most purposes, it would be more beneficial to run your algorithm straight from your own main method, but the runner is there to get your project off the ground.

Brush up on XML

XML is a series of user-defined tags which markup data (much like HTML except for the user-defined part). Now in the context of Galapagos, the tags are defined for you. All you need to do is put in your own data in the right place.

Remember, a tag which wraps the string "data" looks like this: <tag>data</tag>

Also, some tags don't wrap any data, and they have a slash at the end: <noScale/>

Lastly, some tags wrap data and some tags have attributes, like the name attribute for the "galapagos" tag: <galapagos name="Our Example Algorithm"/>

Note: attributes and wrapped data are not interchangeable in Galapagos, so pay attention to whether data goes in as an attribute or wrapped in the tag. The way to remember this is that primitives are in attributes (number, string, etc...) and objects are wrapped.

Writing the XML Specification

Here is an example XML file which is accepted by the runner.

<?xml version="1.0" encoding="UTF-8"?>
<galapagos name="Named Algorithm" numGen="80">
<population size="50" factory="galapagosExamples.intgenome.IntGenomeFactory" />
<operators>
<mate>
<singlePoint children="2" />
</mate>
<mutate> <flip numFlips="6" probPerGen="1.0" />
</mutate>
<survive> <nuclear />
</survive>
<select>
<roulette numFamilies="17">
<scaler>
<noScale/> </scaler>
</roulette>
</select>
<speciation>
<noSpeciation />
</speciation>
</operators> </galapagos>

Notice how the bulk of the data is in defining each operator. Now if you're missing any attributes or operators, the runner will complain (the only exceptions are if you don't define any speciation or scaling operators, then the empty version is substituted).

Running the Runner

If you're in Eclipse, then right-click the library and select Run As... > Run..

In the run window, create a new Configuration under Java Application (I called mine RunnerConfig). Then select your main class. You can do this by checking the "Include libraries..." line and then searching for the main class GalapagosRunner.

Now select the Arguments tab and enter the filename of your xml file. The working directory needs to be pointed to the Workspace's folder (which is the Default), but you can use a path relative to that directory. Click Run.

You should get your output in your console. It might look something like this:

Running algorithm...
Finished at gen: 80, elite: 999798799579896988193796499409-[0, 0, 0, 2, 0, 1, 2, 0, 0, 4, 2, 0, 1, 0, 3, 0, 1, 1, 8, 0, 6, 2, 0, 3, 5, 0, 1, 1, 1, 0]:s
Algorithm finished successfully

Note that if you want to run a different XML configuration, just change that filename in the Arguments pane.

 

Page last updated: April 12, 2006