From 5f11d32bfefdd3858e0340462525feb036be07b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffan=20S=C3=B8lvsten?= Date: Wed, 3 Apr 2024 10:28:44 +0200 Subject: [PATCH 1/2] Update terminal-count heuristic based on data experiments It turns out, most of the improvements due to Repeated Transposition happen when doing so can remove 'shortcut (node)' requests, i.e. when there is a non-shortcutting (but rather idempotent) terminal. --- src/adiar/internal/algorithms/quantify.h | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/adiar/internal/algorithms/quantify.h b/src/adiar/internal/algorithms/quantify.h index 8fa14028d..4099d354c 100644 --- a/src/adiar/internal/algorithms/quantify.h +++ b/src/adiar/internal/algorithms/quantify.h @@ -1319,15 +1319,14 @@ namespace adiar::internal // --------------------------------------------------------------------------------------------- // Terminal Count Heuristics - const size_t false_weight = - 1 + Policy::collapse_to_terminal(typename Policy::pointer_type(false)); - - const size_t true_weight = - 1 + Policy::collapse_to_terminal(typename Policy::pointer_type(true)); + const size_t weight[2] = { + 1u + 9u * !Policy::collapse_to_terminal(typename Policy::pointer_type(false)), + 1u + 9u * !Policy::collapse_to_terminal(typename Policy::pointer_type(true)) + }; const double total_arcs = 2.0 * size; - const double weighted_terminals = false_weight * false_terminals + true_weight * true_terminals; - const size_t exponent = 21.0 * (weighted_terminals / total_arcs) + 0.4; + const double weighted_terminals = weight[false] * false_terminals + weight[true] * true_terminals; + const size_t exponent = 5.75 * (weighted_terminals / total_arcs) + 0.4; const typename Policy::label_type terminal_threshold = (1u << std::min(exponent, log2(2 * Policy::max_label))) - 1u; From 545f78d8d6ddf9d008115cdf0ca958da50dce7f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffan=20S=C3=B8lvsten?= Date: Wed, 3 Apr 2024 10:35:29 +0200 Subject: [PATCH 2/2] Bound 'quantify::transposition_max' to 1 by default --- src/adiar/exec_policy.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/adiar/exec_policy.h b/src/adiar/exec_policy.h index fd8cf0e05..53cce6cb3 100644 --- a/src/adiar/exec_policy.h +++ b/src/adiar/exec_policy.h @@ -192,7 +192,7 @@ namespace adiar public: /// \brief Default value construction. constexpr transposition_max() - : _value(std::numeric_limits::max()) + : _value(1) {} /// \brief Wrap an `unsigned char`