summaryrefslogtreecommitdiff
path: root/test/graph/bitonicTSP.cpp.todo
diff options
context:
space:
mode:
authorGloria Mundi <gloria@gloria-mundi.eu>2025-11-19 02:20:56 +0100
committerGloria Mundi <gloria@gloria-mundi.eu>2025-11-19 02:20:56 +0100
commit17232918b51d27500af905dc3d3d82cd43d6ddf5 (patch)
tree1c5d52f03eead415cc53317008032fe84238c187 /test/graph/bitonicTSP.cpp.todo
parentbf4eda36d4c13be468236bf33baa2574e8692ca7 (diff)
parentcdeded176c18240579168ee8461c5101abb47e78 (diff)
merge mzuenni
Diffstat (limited to 'test/graph/bitonicTSP.cpp.todo')
-rw-r--r--test/graph/bitonicTSP.cpp.todo57
1 files changed, 57 insertions, 0 deletions
diff --git a/test/graph/bitonicTSP.cpp.todo b/test/graph/bitonicTSP.cpp.todo
new file mode 100644
index 0000000..9d6b77d
--- /dev/null
+++ b/test/graph/bitonicTSP.cpp.todo
@@ -0,0 +1,57 @@
+#include "../util.h"
+namespace got {
+#include <graph/bitonicTSP.cpp>
+}
+namespace expected {
+#include <graph/bitonicTSPsimple.cpp>
+}
+
+void stress_test() {
+ ll queries = 0;
+ for (int tries = 0; tries < 200'000; tries++) {
+ int n = Random::integer<int>(2, 30);
+
+ vector<vector<double>> dist(n);
+ for (auto& v : dist) v = Random::reals<double>(n, 0, 1e18);
+ auto eval = [&](const vector<int>& order) {
+ double res = 0;
+ for (int i = 0; i < n; i++) res += dist[order[i]][order[i+1]];
+ return res;
+ };
+
+
+ got::dist = dist;
+ expected::dist = dist;
+
+ auto got = eval(got::bitonicTSP());
+ auto expected = eval(expected::bitonicTSP());
+
+ std::cout << got << std::endl;
+ std::cout << expected << std::endl;
+ if (got != expected) cerr << "error" << FAIL;
+ queries += n;
+ }
+ cerr << "tested random queries: " << queries << endl;
+}
+
+//this is an easy graph...
+constexpr int N = 5'000;
+void performance_test() {
+ timer t;
+ got::dist = vector<vector<double>>(N);
+ for (auto& v : got::dist) v = Random::reals<double>(N, 0, 1e18);
+
+
+ t.start();
+ auto got = got::bitonicTSP();
+ t.stop();
+ hash_t hash = 0;
+ for (auto x : got) hash += x;
+ if (t.time > 500) cerr << "too slow: " << t.time << FAIL;
+ cerr << "tested performance: " << t.time << "ms (hash: " << hash << ")" << endl;
+}
+
+int main() {
+ stress_test();
+ if (!sanitize) performance_test();
+}