#!/bin/sh
CURDIR=`pwd`
EXEDIR=`dirname $0`
EXENAME=`basename $0`

pushd $EXEDIR/.. >/dev/null
BASEDIR=`pwd`
popd >/dev/null

if [ -z "$1" ]
   then echo "Usage:  solve-special-cases Algorithm "
   echo "where algorithm is the java class file with main."
   exit
fi


if [ "$EXEDIR" == "." ]
    then EXEDIR=./
else EXEDIR=$EXEDIR/
fi

for problem in `ls $BASEDIR/input/*.csp`
    do problem=`basename $problem .csp`
    echo "Solving $problem using $1";
    /usr/bin/time -f "%U %S" -a -o $BASEDIR/output/results/special/$problem-$1.time $EXEDIR$1 -q $BASEDIR/output/results/special/$problem-$1.soln $BASEDIR/input/$problem.csp >>$BASEDIR/output/results/$problem-$1.time
    cmp $BASEDIR/output/results/special/$problem-$1.soln $BASEDIR/input/solutions/$problem
    if [ $? -ne 0 ]
        then echo "Solutions do not match for $problem-$1.soln" >>$BASEDIR/output/results/special/mismatches.$1
    fi

    RESULTS=`cat $BASEDIR/output/results/special/$problem-$1.time`
    echo -n "\"Zebra\",\"NotK\",\"$1\",\"$problem\"" >>$BASEDIR/output/results/special.csv
    for outpart in $RESULTS
       do echo -n ",\"$outpart\"" >>$BASEDIR/output/results/special.csv 
    done
    echo "" >>$BASEDIR/output/results/special.csv
    rm -f $BASEDIR/output/results/$problem-$1.time
done
# Copyright 2002-2003 University of Guelph, All Rights Reserved
# Copyright 2002-2003 University of Guelph, All Rights Reserved
