From 5cb792d1e4319a14d85cdc4f8cfbd9eeea3f3603 Mon Sep 17 00:00:00 2001 From: Hamed Gorjiara Date: Thu, 27 Dec 2018 16:33:14 -0800 Subject: [PATCH] scripts for learning --- common.sh | 4 ++++ hexiom/bench.sh | 3 ++- hexiom/learn.sh | 33 +++++++++++++++++++++++++++++++++ killerSudoku/bench.sh | 5 ++++- killerSudoku/learn.sh | 33 +++++++++++++++++++++++++++++++++ nqueens/bench.sh | 3 ++- nqueens/learn.sh | 33 +++++++++++++++++++++++++++++++++ sudoku-csolver/bench.sh | 5 ++++- sudoku-csolver/learn.sh | 33 +++++++++++++++++++++++++++++++++ 9 files changed, 148 insertions(+), 4 deletions(-) create mode 100755 hexiom/learn.sh create mode 100755 killerSudoku/learn.sh create mode 100755 nqueens/learn.sh create mode 100755 sudoku-csolver/learn.sh diff --git a/common.sh b/common.sh index b53fb395..18bd051e 100755 --- a/common.sh +++ b/common.sh @@ -4,3 +4,7 @@ OFILE=result.csv TEMP="temp.out" DUMPDIR="dumps" TIMEMAX=5000s +ROUND=15 +BUDGET=15 +TUNERCONF="onehottuner.conf binarytuner.conf unarytuner.conf" + diff --git a/hexiom/bench.sh b/hexiom/bench.sh index 6cbb7657..76750f54 100755 --- a/hexiom/bench.sh +++ b/hexiom/bench.sh @@ -38,7 +38,8 @@ for PAR in $PARAMETERS; do echo "DONE!" >>$TEMP echo "Program Execution Time: $DIFF" >>$TEMP mkdir -p $DUMPDIR - mv DUMP* $DUMPDIR + mv DUMP* "$PAR.dump" + mv "$PAR.dump" $DUMPDIR elif [ $2 = '--csolver' ]; then START=$(date +%s.%N) timeout $TIMEMAX ./run.sh csolverHexiom.py $PAR --csolver >> $TEMP diff --git a/hexiom/learn.sh b/hexiom/learn.sh new file mode 100755 index 00000000..b624784b --- /dev/null +++ b/hexiom/learn.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +#Terminate the script if even one command fails +set -e + + +#Variables +source ../common.sh +BIN=../../bin +BDIR=../Benchmarks/hexiom/learningset/ + +#Checking the number of +if [ "$#" -lt 1 ]; then + echo "Illegal number of argument" + echo "./learn.sh [LearningSet]" + exit 1 +fi +if [ "$1" -gt 2 ]; then + echo "Only 3 sets are available for learning. Parameter should be less than 3" + echo "./bench.sh [NUMBER] [--csolver/--dump]" + exit 1 +fi + + +declare -a LearningSet=("${BDIR}38.dump ${BDIR}41.dump ${BDIR}43.dump ${BDIR}44.dump ${BDIR}46.dump ${BDIR}47.dump ${BDIR}49.dump ${BDIR}50.dump" +"${BDIR}36.dump ${BDIR}41.dump ${BDIR}42.dump ${BDIR}44.dump ${BDIR}45.dump ${BDIR}47.dump ${BDIR}48.dump ${BDIR}50.dump" +"${BDIR}36.dump ${BDIR}38.dump ${BDIR}42.dump ${BDIR}43.dump ${BDIR}45.dump ${BDIR}46.dump ${BDIR}48.dump ${BDIR}49.dump") + +echo ${LearningSet[$1]} +cd $BIN +./run.sh serializestatictuner +./run.sh runmultituner $BUDGET $ROUND ${LearningSet[$1]} - $TUNERCONF + diff --git a/killerSudoku/bench.sh b/killerSudoku/bench.sh index b470a49e..c572fa4c 100755 --- a/killerSudoku/bench.sh +++ b/killerSudoku/bench.sh @@ -37,7 +37,10 @@ for PAR in $PROBLEMS; do echo "DONE!" >> $TEMP echo "Program Execution Time: $DIFF" >>$TEMP mkdir -p $DUMPDIR - mv DUMP* $DUMPDIR + filename=$(basename -- "$PAR") + filename="${filename%.*}" + mv DUMP* "$filename.dump" + mv "$filename.dump" $DUMPDIR elif [ $2 = '--csolver' ]; then START=$(date +%s.%N) timeout $TIMEMAX ./run.sh python killerSolver.py --problem $PAR --csolver >> $TEMP diff --git a/killerSudoku/learn.sh b/killerSudoku/learn.sh new file mode 100755 index 00000000..749cb0fc --- /dev/null +++ b/killerSudoku/learn.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +#Terminate the script if even one command fails +set -e + + +#Variables +source ../common.sh +BIN=../../bin +BDIR=../Benchmarks/sudoku-csolver/learningset/ + +#Checking the number of +if [ "$#" -lt 1 ]; then + echo "Illegal number of argument" + echo "./learn.sh [LearningSet]" + exit 1 +fi +if [ "$1" -gt 2 ]; then + echo "Only 3 sets are available for learning. Parameter should be less than 3" + echo "./bench.sh [NUMBER] [--csolver/--dump]" + exit 1 +fi + + +declare -a LearningSet=("${BDIR}2-25-5.dump ${BDIR}2-25.dump ${BDIR}36x36-591.dump ${BDIR}2-36-3.dump ${BDIR}2-36-4.dump ${BDIR}2-36.dump ${BDIR}4-16-2.dump ${BDIR}4-16.dump ${BDIR}5-16.dump" +"${BDIR}2-25-4.dump ${BDIR}2-25.dump ${BDIR}2-36-2.dump ${BDIR}2-36-4.dump ${BDIR}2-36-5.dump ${BDIR}4-16-2.dump ${BDIR}4-16-3.dump ${BDIR}5-16.dump ${BDIR}6-16.dump" +"${BDIR}2-25-4.dump ${BDIR}2-25-5.dump ${BDIR}2-36-2.dump ${BDIR}2-36-3.dump ${BDIR}2-36-5.dump ${BDIR}2-36.dump ${BDIR}4-16-3.dump ${BDIR}4-16.dump ${BDIR}6-16.dummp") + +echo ${LearningSet[$1]} +cd $BIN +./run.sh serializestatictuner +./run.sh runmultituner $BUDGET $ROUND ${LearningSet[$1]} - $TUNERCONF + diff --git a/nqueens/bench.sh b/nqueens/bench.sh index e3a3b225..1408e25f 100755 --- a/nqueens/bench.sh +++ b/nqueens/bench.sh @@ -37,7 +37,8 @@ for PAR in $PARAMETERS; do echo "DONE!" >> $TEMP echo "Program Execution Time: $DIFF" >>$TEMP mkdir -p $DUMPDIR - mv DUMP* $DUMPDIR + mv DUMP* "$PAR.dump" + mv "$PAR.dump" $DUMPDIR elif [ $2 = '--csolver' ]; then START=$(date +%s.%N) timeout $TIMEMAX ./run.sh nqueen $PAR --csolver >> $TEMP diff --git a/nqueens/learn.sh b/nqueens/learn.sh new file mode 100755 index 00000000..24afb95f --- /dev/null +++ b/nqueens/learn.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +#Terminate the script if even one command fails +set -e + + +#Variables +source ../common.sh +BIN=../../bin +BDIR=../Benchmarks/nqueens/learningset/ + +#Checking the number of +if [ "$#" -lt 1 ]; then + echo "Illegal number of argument" + echo "./learn.sh [LearningSet]" + exit 1 +fi +if [ "$1" -gt 2 ]; then + echo "Only 3 sets are available for learning. Parameter should be less than 3" + echo "./bench.sh [NUMBER] [--csolver/--dump]" + exit 1 +fi + + +declare -a LearningSet=("${BDIR}96.dump ${BDIR}112.dump ${BDIR}144.dump ${BDIR}160.dump ${BDIR}224.dump ${BDIR}256.dump ${BDIR}320.dump ${BDIR}352.dump" +"${BDIR}64.dump ${BDIR}112.dump ${BDIR}128.dump ${BDIR}160.dump ${BDIR}192.dump ${BDIR}256.dump ${BDIR}288.dump ${BDIR}352.dump ${BDIR}384.dump" +"${BDIR}64.dump ${BDIR}96.dump ${BDIR}128.dump ${BDIR}144.dump ${BDIR}192.dump ${BDIR}224.dump ${BDIR}288.dump ${BDIR}320.dump ${BDIR}384.dump") + +echo ${LearningSet[$1]} +cd $BIN +./run.sh serializestatictuner +./run.sh runmultituner $BUDGET $ROUND ${LearningSet[$1]} - $TUNERCONF + diff --git a/sudoku-csolver/bench.sh b/sudoku-csolver/bench.sh index ec396a8e..8e705099 100755 --- a/sudoku-csolver/bench.sh +++ b/sudoku-csolver/bench.sh @@ -37,7 +37,10 @@ for PAR in $PROBLEMS; do echo "DONE!" >> $TEMP echo "Program Execution Time: $DIFF" >>$TEMP mkdir -p $DUMPDIR - mv DUMP* $DUMPDIR + filename=$(basename -- "$PAR") + filename="${filename%.*}" + mv DUMP* "$filename.dump" + mv "$filename.dump" $DUMPDIR elif [ $2 = '--csolver' ]; then START=$(date +%s.%N) timeout $TIMEMAX ./run.sh python Sudoku.py --file $PAR --csolver >> $TEMP diff --git a/sudoku-csolver/learn.sh b/sudoku-csolver/learn.sh new file mode 100755 index 00000000..69bce2c5 --- /dev/null +++ b/sudoku-csolver/learn.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +#Terminate the script if even one command fails +set -e + + +#Variables +source ../common.sh +BIN=../../bin +BDIR=../Benchmarks/sudoku-csolver/learningset/ + +#Checking the number of +if [ "$#" -lt 1 ]; then + echo "Illegal number of argument" + echo "./learn.sh [LearningSet]" + exit 1 +fi +if [ "$1" -gt 2 ]; then + echo "Only 3 sets are available for learning. Parameter should be less than 3" + echo "./bench.sh [NUMBER] [--csolver/--dump]" + exit 1 +fi + + +declare -a LearningSet=("${BDIR}36x36-591.dump ${BDIR}36x36-592.dump ${BDIR}36x36-594.dump ${BDIR}36x36-595.dump ${BDIR}36x36-597.dump ${BDIR}36x36-598.dump ${BDIR}36x36-600.dump ${BDIR}36x36-892.dump ${BDIR}36x36-895.dump ${BDIR}36x36-896.dump ${BDIR}36x36-898.dump" +"${BDIR}36x36-590.dump ${BDIR}36x36-592.dump ${BDIR}36x36-593.dump ${BDIR}36x36-595.dump ${BDIR}36x36-596.dump ${BDIR}36x36-598.dump ${BDIR}36x36-599.dump ${BDIR}36x36-892.dump ${BDIR}36x36-893.dump ${BDIR}36x36-896.dump ${BDIR}36x36-897.dump" +"${BDIR}36x36-590.dump ${BDIR}36x36-591.dump ${BDIR}36x36-593.dump ${BDIR}36x36-596.dump ${BDIR}36x36-597.dump ${BDIR}36x36-599.dump ${BDIR}36x36-600.dump ${BDIR}36x36-893.dump ${BDIR}36x36-895.dump ${BDIR}36x36-897.dump ${BDIR}36x36-898.dump") + +echo ${LearningSet[$1]} +cd $BIN +./run.sh serializestatictuner +./run.sh runmultituner $BUDGET $ROUND ${LearningSet[$1]} - $TUNERCONF + -- 2.34.1