diff --git a/run.sh b/run.sh index 271657f..b15392f 100755 --- a/run.sh +++ b/run.sh @@ -10,7 +10,24 @@ if [[ -z $TEST_FOLDER ]]; then TEST_FOLDER="test" fi +if [[ -z $SOLUTIONS_FILE ]]; then + SOLUTIONS_FILE=solucoes.txt +fi + +declare -A solutions +while read line; do + solutions[$(awk '{print $1}' <<< "$line")]=$(awk '{print $2}' <<< "$line") +done < "$SOLUTIONS_FILE" + for file in $(find "$TEST_FOLDER" -type f); do echo "Arquivo de teste: $file" - "$EXEC" < "$file" + res=$("$EXEC" -i -c < "$file" | awk '{print $4}') + optimal=${solutions[$(basename "$file")]} + echo "Resultado do programa: ${res}" + echo "Resultado ótimo: ${optimal}" + if [[ $res = $optimal ]]; then + echo "Resultado ótimo!" + else + echo "Diferença de $(bc <<< "${res} - ${optimal}")" + fi done diff --git a/sa.cpp b/sa.cpp index c2cebf8..14cfc81 100644 --- a/sa.cpp +++ b/sa.cpp @@ -27,7 +27,6 @@ auto sa::solution::simulated_annealing(int capacity, const std::vector