Sampling script

This page describes how to write the script Tuner relies on to interface with the algorithm to be sampled. This script is responsible for passing a csv file of sample points generated by Tuner to the computer code and then packaging up the outputs into a csv file for Tuner to read.

Overview

Tuner will call an executable on your system. This executable can be written in any language you want but it must take the following 4 arguments:

  1. The absolute path to the sample csv
  2. The absolute path to where Tuner wants the outputs csv
  3. The absolute path to where Tuner wants images saved
  4. The starting index number for the images.

Note that the paths in items 1 and 2 are non-negotiable. Tuner chooses where these csv files need to be placed. If the algorithm you are running wants files in a specific place, this is the responsibility of the script.

Items 3 and 4 are really only for image segmentation algoritms. They don't have to be used in the script. Item 3 is the absolute path to a directory for storing images. Item 4 is the index at which to start start numbering images.

Example sampling script

The following is a sample for what the sampling script will look like. It is written in bash. In this case the script copies the csv file generated by Tuner to a separate working directory, calls the computer code, and then copies the output file to the location Tuner expects.

#!sh

locations=$1
output=$2
imagedir=$3
startcount=$4

MYDIR=`dirname $0`
WORKINGDIR=/Users/tom/workingdir
ALGO=/bin/start

cp ${locations} ${WORKINGDIR}/params.csv

# run the code
cd ${WORKINGDIR}
${ALGO} -in params.csv -out results.csv

# some post-processing is needed
cp results.csv ${output}