Upgrade the script
This commit is contained in:
parent
d3871084e6
commit
6c7ba28320
19
run.sh
19
run.sh
@ -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
1
sa.cpp
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user