#!/bin/bash
###############################################################################
# This hook is the command that is executed every run.
# Check the examples in examples/
#
# PARAMETERS:
# $1 is the instance name  
# $2 is the candidate number
# The rest ($* after `shift 2') are parameters to the run of program
#
# RETURN VALUE:
# This script should print nothing.
# Exit with 0 if no error, with 1 in case of error
###############################################################################

# Path to the software:
EXE=~/bin/program
FIXED_PARAMS="--trials 1 --time 60"

# The instance name and the candidate id are the first parameters
INSTANCE=$1
CANDIDATE=$2

# All other parameters are the candidate parameters to be passed to program
shift 2 || exit 1
CAND_PARAMS=$*

STDOUT="c${CANDIDATE}.stdout"
STDERR="c${CANDIDATE}.stderr"

mkdir -p arena
cd arena

$EXE ${FIXED_PARAMS} --input $INSTANCE ${CAND_PARAMS} 1> $STDOUT 2> $STDERR
echo "OK" >> $STDERR
exit 0
