plan 1.18 KB
Newer Older
David Speck's avatar
David Speck committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
#!/bin/bash

set -e

BASEDIR="$(dirname "$0")"
echo $(dirname "$0")

function die {
    echo "$@" 1>&2
    exit 1
}

function usage {
    die "usage: $(basename "$0") [DOMAIN_FILE] PROBLEM_FILE SEARCH_OPTION ..."
}

# Paths to planner components
TRANSLATE="$BASEDIR/translate/translate.py"
PREPROCESS="$BASEDIR/preprocess/preprocess"
SEARCH="$BASEDIR/search/downward"

# Need to explicitly ask for GNU time (from MacPorts) on Mac OS X.
if [[ "$(uname)" == "Darwin" ]]; then
    TIME="gtime"
    if ! which $TIME >/dev/null; then
        die "$TIME must be installed on Mac OSX (from MacPorts, perhaps) for this to work"
    fi
else
    TIME="command time"
fi

TIME="$TIME --output=elapsed.time --format=%S\n%U\n"

if [[ "$#" < 2 ]]; then
    usage
fi

echo "1. Running translator"
if [[ -e "$2" ]]; then
    echo "Second argument is a file name: use two translator arguments."
    $TIME "$TRANSLATE" "$1" "$2"
    shift 2
else
    echo "Second argument is not a file name: auto-detect domain file."
    $TIME "$TRANSLATE" "$1"
    shift
fi
echo

echo "2. Running preprocessor"
$TIME --append "$PREPROCESS" < output.sas
echo

echo "3. Running search"
echo "$SEARCH" < output "$@"
"$SEARCH" < output "$@"
echo