diff --git a/main.cpp b/main.cpp index e96472a..b045062 100644 --- a/main.cpp +++ b/main.cpp @@ -3,7 +3,15 @@ #include "sa.hpp" -int main() +#ifndef TEMP +#define TEMP 1000 +#endif + +#ifndef ALPHA +#define ALPHA 0.99 +#endif + +int main(int argc, char *argv[]) { int number_of_items = 0; int capacity = 0; @@ -15,7 +23,7 @@ int main() } sa::solution act = sa::solution::simulated_annealing(capacity, items, - 1000, 0.99); + TEMP, ALPHA); act.print_sol(); } diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..374d83c --- /dev/null +++ b/run.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +IFS=$'\n' + +for file in $(find test -type f); do + build/main.out < $file +done diff --git a/sa.hpp b/sa.hpp index 6189ee1..a9dd6cc 100644 --- a/sa.hpp +++ b/sa.hpp @@ -80,7 +80,6 @@ class solution { for (auto i : items) { if (now + i > capacity) { print_box(box_now, items_stored); - std::cout << '\n'; box_now++; now = i; } else { @@ -90,6 +89,7 @@ class solution { } print_box(box_now, items_stored); + std::cout << '\n'; } static auto simulated_annealing(int capacity, const std::vector &items,