Compare commits

...

2 Commits

3 changed files with 18 additions and 3 deletions

View File

@ -3,7 +3,15 @@
#include "sa.hpp" #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 number_of_items = 0;
int capacity = 0; int capacity = 0;
@ -15,7 +23,7 @@ int main()
} }
sa::solution act = sa::solution::simulated_annealing(capacity, items, sa::solution act = sa::solution::simulated_annealing(capacity, items,
1000, 0.99); TEMP, ALPHA);
act.print_sol(); act.print_sol();
} }

7
run.sh Executable file
View File

@ -0,0 +1,7 @@
#!/usr/bin/env bash
IFS=$'\n'
for file in $(find test -type f); do
build/main.out < $file
done

2
sa.hpp
View File

@ -80,7 +80,6 @@ class solution {
for (auto i : items) { for (auto i : items) {
if (now + i > capacity) { if (now + i > capacity) {
print_box(box_now, items_stored); print_box(box_now, items_stored);
std::cout << '\n';
box_now++; box_now++;
now = i; now = i;
} else { } else {
@ -90,6 +89,7 @@ class solution {
} }
print_box(box_now, items_stored); print_box(box_now, items_stored);
std::cout << '\n';
} }
static auto simulated_annealing(int capacity, const std::vector<long long> &items, static auto simulated_annealing(int capacity, const std::vector<long long> &items,