# Usage:   ./experiment.sh input_dir output_dir matrix_var_file BASE
# Typical: ./experiment.sh EXPERIMENTS SOLUTIONS A.var testmodel

MATRIX_FILE=`basename $3 .var`
MATRIX_PATH=`dirname  $3`
MATRIX_SIZE=`cat $MATRIX_PATH/$MATRIX_FILE.size`
EXPER_FILE_EXTN=.exp

process_var $3 $MATRIX_SIZE;
#for  IN_FILE in $1/*$EXPER_FILE_EXTN;
for  IN_FILE in $1/$4$EXPER_FILE_EXTN;
do   OUT_FILE=`basename $IN_FILE $EXPER_FILE_EXTN`;
     echo Processing: $IN_FILE  "-->"  $2/$OUT_FILE.res;
     var2pwbsolve.pl $IN_FILE;
     echo pwbsolve $MATRIX_SIZE 100 1000 1 1e-15 $2/$OUT_FILE.soln;
     #./pwbsolve $MATRIX_SIZE 100 1000 3 1e-25 $2/$OUT_FILE.res > $2/$OUT_FILE.soln;
     #pwbsolve $MATRIX_SIZE 100 150 1 1e-15 $2/$OUT_FILE.res > $2/$OUT_FILE.soln;
     # leila's example seems to converge optimally at 150, then go haywire!
     pwbsolve $MATRIX_SIZE 100 150 1 1e-15 dummy > $2/$OUT_FILE.soln;
done
# Tidy up
#rm pwbsolve.dia;
#rm pwbsolve.off;
#rm pwbsolve.dia.var;
#rm pwbsolve.off.var;
