results_dir='./experiments/sampled_BK_10Rules_orderedNT_results_ruleOrderConstraint'  
input_files='./experiments/sampled_BK_orderedNT'

rm -r ${results_dir}
mkdir ${results_dir}



rm oneLineTotalTime.txt

rm oneLineAccuracy.txt
rm all_times.txt
rm all_accuracies.txt

rm hypothesis.pl
rm hypothesis0.txt


for (( sample_size=1; sample_size<10; sample_size++ ))
do

for (( i=0; i<=9; i++ ))
do
    echo "Dataset: sampledBK${sample_size}_${i}"
    cat ${input_files}/sampledBK${sample_size}_${i}.pl > partialBK.lp
    for (( fold_index=1; fold_index<=10; fold_index++ ))
    do 
    echo "Fold: ${fold_index}"
	  yap -L -- example_convertor -- ${fold_index} > ex.lp
	  python genH_fixNTbound.pl	#yap -L -- run.pl -- ${input_files}/sampledBK${sample_size}_${i}.pl > ${results_dir}/${sample_size}_${i}.pl
	  cat hypothesis0.txt >> ${results_dir}/${sample_size}-$i-${fold_index}.txt
	  cat hypothesis.pl >> ${results_dir}/${sample_size}-$i-${fold_index}.txt
	  yap -L -- test.pl -- ${fold_index} > testing_result.txt
	  cat testing_result.txt >> ${results_dir}/${sample_size}-$i-${fold_index}.txt
	  cat oneAccuracy.txt >> oneLineAccuracy.txt
	  cat oneTotalTime.txt >> oneLineTotalTime.txt
    done
# no seperation of folds from different samples -- each samplesize has one line, and they are averaged all together
done
cat oneLineAccuracy.txt >> all_accuracies.txt
cat oneLineTotalTime.txt >> all_times.txt
rm oneLineAccuracy.txt
rm oneLineTotalTime.txt
echo -e "\n" >> all_accuracies.txt
echo -e "\n" >> all_times.txt
done

matlab -nojvm -nodisplay -nodesktop -nosplash -logfile < average_time.m
matlab -nojvm -nodisplay -nodesktop -nosplash -logfile < average_accuracy.m

cp all_times.txt ${results_dir}/
cp Time_asp.gp ${results_dir}/

cp all_accuracies.txt ${results_dir}/
cp Acc_asp.gp ${results_dir}/

