RobGP Tutorials

Writing your first GP program can be difficult. This tutorial aims to get you started. You can skip ahead to any of the following steps if you are comfortable with those before it.

Step 1: Obtain RobGP from the downloads page or SVN repository and compile it.

Step 2: Install RobGP as a system library or copy it locally into your project and configure the project accordingly.

Step 3: Writing your first GP program. This encompasses creating a function and terminal set, defining a fitness function, writing an XML file describing your GP setup and writing a main loop to run through several generations of the GP.

Obtaining RobGP

Get a copy of RobGP:

  1. From the subversion repository
  2. From the release package

The latest subversion revisions often contain many new and exciting features as well as bug fixes and documentation improvements. The system is highly stable and using the latest SVN version is encouraged.

Getting RobGP from SVN

To fetch RobGP from SVN open up your favourite terminal and run the following to download from the trunk repository.

svn co https://robgp.svn.sourceforge.net/svnroot/robgp/trunk/robgp robgp
cd robgp

Getting RobGP from the web

To fetch RobGP from the web proceed to the download page and get the latest release of robgp available. Alternately, run the following in your favourite terminal.

wget http://downloads.sourceforge.net/project/robgp/robgp/0.1/robgp-0.1.tar.gz
tar zxvf robgp-0.1.tar.gz
cd robgp-0.1

Compiling RobGP

Assuming you have the compiler and a normal environment and no special compilation requirements you should be able to compile RobGP using the make utility. This picks up from having just downloaded (and extracted) RobGP.

make

Installing RobGP

Proceeding from the previous step, you can either install RobGP as a system library or copy it to your local application folder and configure your Makefile to look for it there.

Install as a system library

To install RobGP, simply use the Makefile install target. This will install the library itself in /usr/local/lib/librobgp.so and the header files in /usr/local/include/robgp/ where they should be included automatically from g++ in your projects.

sudo make install

Then to use RobGP in your project you can include the header files in your program with the following include statement:

mygp.cpp
#include <robgp/robgp.hpp>

...

And you can compile your program by linking with the dynamic library librobgp.so as follows:

g++ -O2 -lrobgp mygp.cpp -o mygp

Copy RobGP to your local project folder

Assuming you have a project in ~/myproject you can include RobGP without installing it by copying the library and necessary header files into the project folder and modifying your project to search the local directory for libraries.

cp -r bin/librobgp.so bin/robgp.a bin/robgp ~/myproject/

Then you can include the robgp header files into your code with the following:

mygp.cpp
#include "robgp/robgp.hpp"

...

Lastly, you can compile, link and run your code either using the dynamically linked library, or by using the static library. The latter of which is easier, as it will produce a portable binary that contains the GP code and can be run anywhere, but it will also result in a larger binary.

g++ -O2 -L. -lrobgp mygp.cpp -o mygp
LD_LIBRARY_PATH=. ./mygp
Example: Using RobGP as a dynamically linked library producing a smaller binary.
g++ -O2 robgp.a mygp.cpp -o mygp
./mygp
Example: Using RobGP as a static library producing a larger portable binary.