Tuning your algorithm with irace on the IRIDIA cluster

From IridiaWiki
Revision as of 17:37, 1 March 2012 by Mascia (talk | contribs) (New page: You should '''really''' read the [http://iridia.ulb.ac.be/irace/files/README README] file, and take a look on the ''examples'' and ''templates'' in the irace directory. Or you can just fol...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

You should really read the README file, and take a look on the examples and templates in the irace directory. Or you can just follow this walk-through for a quick start but you will miss many options and configuration possibilities. You can start from this example and then adapt it to the algorithm you want to configure.

Installation

First of all, you have to install the irace R package on majorana:

    $ ssh majorana
    $ export R_LIBS=~/R:${R_LIBS}
    $ R
    > install.packages("irace")

select the belgian mirror and test the installation with

    > library(irace)
    > CTRL+d

Once installed, exit R, and add at the end of your .bash_profile or .bashrc or .profile:

    export IRACE_HOME=~/R/2.14/library/irace/
    # export PATH=$IRACE_HOME/bin/:$PATH

The algorithm to be tuned

You have to create a directory where you do the tuning

    $ mkdir ~/tuning
    $ cd ~/tuning

you copy here the program you are tuning, in this case it's just a simple C program

    $ cat > algo.c
    #include <stdio.h>
    int main(int argc, char **argv) {
        // call me with ./algo -i instance --whatever <integer_parameter>
        printf("Best %d\n", atoi(argv[4]));
    }
    CTRL+d
    $ make algo
    cc     algo.c   -o algo

Prepare for the tuning

Copy some of the template and example files in the current (tuning) directory

    $ cd ~/tuning
    $ cp $IRACE_HOME/templates/tune-conf.tmpl tune-conf
    $ cp $IRACE_HOME/examples/mpi/tune-main-cluster-mpi tune-main-cluster-mpi
    $ cp $IRACE_HOME/examples/acotsp/hook-run .

in hook-run change the two environment variables like below

    EXE=./algo
    FIXED_PARAMS=""

create some dummy instances

    $ mkdir Instances
    $ for i in {1..100}; do touch Instances/$i; done

create a parameters file

    $ cat > parameters.txt
    dummy_par        "--whatever"        i   (1, 100)~
    CTRL+d

you should look in the examples/acotsp directory for a more complete example...

Tuning time!

Now you are ready to run irace:

    $ ./tune-main-cluster-mpi $IRACE_HOME/bin . --parallel 10

take a look at tune-main-cluster-mpi and change cluster queues and qsub parameters to better suit your needs.