Tuning your algorithm with irace on the IRIDIA cluster

From IridiaWiki
Revision as of 12:40, 2 March 2012 by Mascia (talk | contribs)
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("multicore")
> 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 R_LIBS=~/R:${R_LIBS}
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=""

in tune-mpi add in the qsub shell script before the MPIRUN command

export R_LIBS=~/R:${R_LIBS}

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.

You can check if the job is waiting, running, or complete with the qstat command. In the directory ~/tuning you will find an irace-$PID.stdout and an irace-$PID.stderr file.