Upgrade the script

This commit is contained in:
Segcolt 2024-10-13 11:41:05 -03:00
parent d3871084e6
commit 6c7ba28320
2 changed files with 18 additions and 2 deletions

19
run.sh
View File

@ -10,7 +10,24 @@ if [[ -z $TEST_FOLDER ]]; then
TEST_FOLDER="test" TEST_FOLDER="test"
fi 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 for file in $(find "$TEST_FOLDER" -type f); do
echo "Arquivo de teste: $file" 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 done

1
sa.cpp
View File

@ -27,7 +27,6 @@ auto sa::solution::simulated_annealing(int capacity, const std::vector<long long
temp *= alpha; temp *= alpha;
if (prev.fitness < best.fitness) { if (prev.fitness < best.fitness) {
std::cout << prev.fitness << ' ' << best.fitness << '\n';
best = prev; best = prev;
} }
} }