From af6fb42e7a5690c84bf86a6a214f9b90985dd073 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffan=20S=C3=B8lvsten?= Date: Tue, 12 May 2026 12:05:21 +0200 Subject: [PATCH 1/8] Make 'replace(ptr, lvl)' terminal-safe The terminal-unsafe version is still available as 'unsafe_replace(ptr, lvl)' --- src/adiar/internal/data_types/convert.h | 4 +- src/adiar/internal/data_types/ptr.h | 13 ++++++- src/adiar/internal/data_types/uid.h | 14 +++++-- tests/adiar/internal/data_types/ptr.test.cpp | 40 ++++++++++++++++---- 4 files changed, 57 insertions(+), 14 deletions(-) diff --git a/src/adiar/internal/data_types/convert.h b/src/adiar/internal/data_types/convert.h index aebd8599e..db601385a 100644 --- a/src/adiar/internal/data_types/convert.h +++ b/src/adiar/internal/data_types/convert.h @@ -51,7 +51,7 @@ namespace adiar::internal } ////////////////////////////////////////////////////////////////////////////////////////////////// - /// \brief Combine two arcs into a single node with a custom label + /// \brief Combine two arcs into a single node with a custom label. ////////////////////////////////////////////////////////////////////////////////////////////////// inline node node_of(const node::label_type label, const arc& low, const arc& high) @@ -72,7 +72,7 @@ namespace adiar::internal adiar_assert(essential(low.source()) == low.source() && essential(high.source()) == low.source()); - return node(node::uid_type(replace(low.source(), label)), low.target(), high.target()); + return node(node::uid_type(unsafe_replace(low.source(), label)), low.target(), high.target()); } } diff --git a/src/adiar/internal/data_types/ptr.h b/src/adiar/internal/data_types/ptr.h index 25999bccc..5c86e63c3 100644 --- a/src/adiar/internal/data_types/ptr.h +++ b/src/adiar/internal/data_types/ptr.h @@ -337,7 +337,7 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////////////////////////// // befriend label modifying functions that need access to protected values. friend ptr_uint64 - replace(const ptr_uint64& p, const level_type new_level); + unsafe_replace(const ptr_uint64& p, const level_type new_level); friend ptr_uint64 essential_replace(const ptr_uint64& p, const level_type new_level); @@ -864,7 +864,7 @@ namespace adiar::internal /// \pre `p.is_node()` ////////////////////////////////////////////////////////////////////////////////////////////////// inline ptr_uint64 - replace(const ptr_uint64& p, const ptr_uint64::level_type new_level) + unsafe_replace(const ptr_uint64& p, const ptr_uint64::level_type new_level) { adiar_assert(p.is_node()); adiar_assert(new_level <= ptr_uint64::max_label); @@ -879,6 +879,15 @@ namespace adiar::internal return non_labels_bits | labels_bits; } + ////////////////////////////////////////////////////////////////////////////////////////////////// + /// \brief Replaces the level with the one given. + ////////////////////////////////////////////////////////////////////////////////////////////////// + inline ptr_uint64 + replace(const ptr_uint64& p, const ptr_uint64::level_type new_level) + { + return p.is_node() ? unsafe_replace(p, new_level) : p; + } + ////////////////////////////////////////////////////////////////////////////////////////////////// /// \brief Combination of `essential(p)` and `replace(p, new_level)`. ////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/adiar/internal/data_types/uid.h b/src/adiar/internal/data_types/uid.h index ff5c33f12..40fbb229c 100644 --- a/src/adiar/internal/data_types/uid.h +++ b/src/adiar/internal/data_types/uid.h @@ -213,6 +213,16 @@ namespace adiar::internal ////////////////////////////////////////////////////////////////////////////////////////////////// template inline Uid + unsafe_replace(const Uid& u, const typename Uid::level_type new_level) + { + return Uid::unsafe(unsafe_replace(static_cast(u), new_level)); + } + + ////////////////////////////////////////////////////////////////////////////////////////////////// + /// \brief Replaces the level with the one given. + ////////////////////////////////////////////////////////////////////////////////////////////////// + template + inline Uid replace(const Uid& u, const typename Uid::level_type new_level) { return Uid::unsafe(replace(static_cast(u), new_level)); @@ -220,14 +230,12 @@ namespace adiar::internal ////////////////////////////////////////////////////////////////////////////////////////////////// /// \brief Replaces the level with the one given. - /// - /// \pre `u.is_node()` ////////////////////////////////////////////////////////////////////////////////////////////////// template inline Uid essential_replace(const Uid& u, const typename Uid::level_type new_level) { - return replace(u, new_level); + return Uid::unsafe(replace(static_cast(u), new_level)); } ////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/tests/adiar/internal/data_types/ptr.test.cpp b/tests/adiar/internal/data_types/ptr.test.cpp index 73eda773f..8344a49a8 100644 --- a/tests/adiar/internal/data_types/ptr.test.cpp +++ b/tests/adiar/internal/data_types/ptr.test.cpp @@ -808,44 +808,70 @@ go_bandit([]() { }); }); - describe("replace(...)", [&]() { + describe("unsafe_replace(...)", [&]() { it("shifts x0 -> x1", [&]() { const ptr_uint64 in(0, 0); - const ptr_uint64 out = replace(in, 1); + const ptr_uint64 out = unsafe_replace(in, 1); AssertThat(out, Is().EqualTo(ptr_uint64(1, 0))); }); it("doubles x3 -> x6", [&]() { const ptr_uint64 in(3, 0); - const ptr_uint64 out = replace(in, 6); + const ptr_uint64 out = unsafe_replace(in, 6); AssertThat(out, Is().EqualTo(ptr_uint64(6, 0))); }); it("squares x3 -> x9", [&]() { const ptr_uint64 in(3, 0); - const ptr_uint64 out = replace(in, 9); + const ptr_uint64 out = unsafe_replace(in, 9); AssertThat(out, Is().EqualTo(ptr_uint64(9, 0))); }); it("preserves 'id' when replacing variable", [&]() { const ptr_uint64 in(0, 42); - const ptr_uint64 out = replace(in, 2); + const ptr_uint64 out = unsafe_replace(in, 2); AssertThat(out, Is().EqualTo(ptr_uint64(2, 42))); }); it("preserves 'out_idx' when replacing variable", [&]() { const ptr_uint64 in(42, 0, true); - const ptr_uint64 out = replace(in, 21); + const ptr_uint64 out = unsafe_replace(in, 21); AssertThat(out, Is().EqualTo(ptr_uint64(21, 0, true))); }); it("preserves 'flag' when replacing variable", [&]() { const ptr_uint64 in = flag(ptr_uint64(21, 0)); - const ptr_uint64 out = replace(in, 42); + const ptr_uint64 out = unsafe_replace(in, 42); AssertThat(out, Is().EqualTo(flag(ptr_uint64(42, 0)))); }); }); + describe("replace(...)", [&]() { + it("halves x42 -> x21", [&]() { + const ptr_uint64 in(42, 0); + const ptr_uint64 out = replace(in, 21); + AssertThat(out, Is().EqualTo(ptr_uint64(21, 0))); + }); + + it("preserves 'F' terminal as-is", [&]() { + const ptr_uint64 in(false); + const ptr_uint64 out = replace(in, 42); + AssertThat(out, Is().EqualTo(ptr_uint64(false))); + }); + + it("preserves 'T' terminal as-is", [&]() { + const ptr_uint64 in(true); + const ptr_uint64 out = replace(in, 8); + AssertThat(out, Is().EqualTo(ptr_uint64(true))); + }); + + it("preserves 'nil' as-is", [&]() { + const ptr_uint64 in = ptr_uint64::nil(); + const ptr_uint64 out = replace(in, 8); + AssertThat(out, Is().EqualTo(ptr_uint64::nil())); + }); + }); + describe("essential_replace(...)", [&]() { it("does nothing to 'nil'", [&]() { const ptr_uint64 in = ptr_uint64::nil(); From 0437d12be8bfefdd1c52d6dc7bd160d64cfed78f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffan=20S=C3=B8lvsten?= Date: Tue, 12 May 2026 12:25:22 +0200 Subject: [PATCH 2/8] Add missing documentation for lifted functions to node --- src/adiar/internal/data_types/node.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/adiar/internal/data_types/node.h b/src/adiar/internal/data_types/node.h index 95b3f9555..2b97e18df 100644 --- a/src/adiar/internal/data_types/node.h +++ b/src/adiar/internal/data_types/node.h @@ -520,6 +520,10 @@ namespace adiar::internal } /* ========================================== TERMINAL ======================================== */ + + ////////////////////////////////////////////////////////////////////////////////////////////////// + /// \brief Negates node `n` and its children if the `negate` flag is set to true. + ////////////////////////////////////////////////////////////////////////////////////////////////// inline node cnot(const node& n, const bool negate) { @@ -531,6 +535,10 @@ namespace adiar::internal } /* =========================================== LEVELS ========================================= */ + + ////////////////////////////////////////////////////////////////////////////////////////////////// + /// \brief Shift the level of the node and its children by `levels` amount. + ////////////////////////////////////////////////////////////////////////////////////////////////// inline node shift_replace(const node& n, const node::signed_label_type levels) { From a3db9475b153b882d9e4e4e81952d06d5ae9cbda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffan=20S=C3=B8lvsten?= Date: Tue, 12 May 2026 12:37:45 +0200 Subject: [PATCH 3/8] Add 'level_type' to 'node' In general, the word 'label' is soon-to-be deprecated in --- src/adiar/internal/data_types/node.h | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/adiar/internal/data_types/node.h b/src/adiar/internal/data_types/node.h index 2b97e18df..49c431fd3 100644 --- a/src/adiar/internal/data_types/node.h +++ b/src/adiar/internal/data_types/node.h @@ -54,6 +54,11 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////////////////////////// using terminal_type = pointer_type::terminal_type; + //////////////////////////////////////////////////////////////////////////////////////////////// + /// \brief Type of this node's variable level. + //////////////////////////////////////////////////////////////////////////////////////////////// + using level_type = pointer_type::level_type; + //////////////////////////////////////////////////////////////////////////////////////////////// /// \brief Type of this node's variable label. //////////////////////////////////////////////////////////////////////////////////////////////// @@ -62,7 +67,12 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////////////////////////// /// \brief The maximal possible value for a unique identifier's label. //////////////////////////////////////////////////////////////////////////////////////////////// - static constexpr label_type max_label = pointer_type::max_label; + static constexpr level_type max_label = pointer_type::max_label; + + //////////////////////////////////////////////////////////////////////////////////////////////// + /// \brief Type for a difference of levels. + //////////////////////////////////////////////////////////////////////////////////////////////// + using signed_level_type = pointer_type::signed_level_type; //////////////////////////////////////////////////////////////////////////////////////////////// /// \brief Type for a difference of levels. @@ -226,7 +236,7 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////////////////////////// /// \brief Construct *internal* node `((label, id), low, high)`. //////////////////////////////////////////////////////////////////////////////////////////////// - node(const label_type label, const id_type id, const pointer_type& l, const pointer_type& h) + node(const level_type label, const id_type id, const pointer_type& l, const pointer_type& h) : _uid(label, id) , _children{ l, h } { @@ -240,7 +250,7 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////////////////////////// /// \brief Construct *internal* node `((label, id), low, high)`. //////////////////////////////////////////////////////////////////////////////////////////////// - node(const label_type label, const id_type id, const node& l, const pointer_type& h) + node(const level_type label, const id_type id, const node& l, const pointer_type& h) : node(label, id, l.uid(), h) { adiar_assert(outdegree == 2, "Constructor is for binary node only."); @@ -249,7 +259,7 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////////////////////////// /// \brief Construct *internal* node `((label, id), low, high)`. //////////////////////////////////////////////////////////////////////////////////////////////// - node(const label_type label, const id_type id, const pointer_type& l, const node& h) + node(const level_type label, const id_type id, const pointer_type& l, const node& h) : node(label, id, l, h.uid()) { adiar_assert(outdegree == 2, "Constructor is for binary node only."); @@ -258,7 +268,7 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////////////////////////// /// \brief Construct *internal* node `((label, id), low, high)`. //////////////////////////////////////////////////////////////////////////////////////////////// - node(const label_type label, const id_type id, const node& l, const node& h) + node(const level_type label, const id_type id, const node& l, const node& h) : node(label, id, l.uid(), h.uid()) { adiar_assert(outdegree == 2, "Constructor is for binary node only."); @@ -270,7 +280,7 @@ namespace adiar::internal /// \pre `is_terminal()` evaluates to `false`. //////////////////////////////////////////////////////////////////////////////////////////////// // TODO: Rename to `level()` when introducing variable ordering - inline label_type + inline level_type label() const { adiar_assert(!is_terminal()); @@ -540,7 +550,7 @@ namespace adiar::internal /// \brief Shift the level of the node and its children by `levels` amount. ////////////////////////////////////////////////////////////////////////////////////////////////// inline node - shift_replace(const node& n, const node::signed_label_type levels) + shift_replace(const node& n, const node::signed_level_type levels) { const node::uid_type n_uid(shift_replace(n.uid().as_ptr(), levels)); const node::pointer_type n_low(shift_replace(n.low(), levels)); From 6bc8666c030e4fd73c40ce83b891474ba706b772 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffan=20S=C3=B8lvsten?= Date: Tue, 12 May 2026 12:41:15 +0200 Subject: [PATCH 4/8] Move 'replace(...)' of data types with maps to their respective types --- src/adiar/internal/algorithms/replace.h | 30 +--------------- src/adiar/internal/data_types/node.h | 10 ++++++ src/adiar/internal/data_types/ptr.h | 11 ++++++ src/adiar/internal/data_types/uid.h | 11 ++++++ tests/adiar/internal/data_types/node.test.cpp | 34 +++++++++++++++++++ tests/adiar/internal/data_types/ptr.test.cpp | 30 +++++++++++++++- 6 files changed, 96 insertions(+), 30 deletions(-) diff --git a/src/adiar/internal/algorithms/replace.h b/src/adiar/internal/algorithms/replace.h index 81531020b..a5bc9f761 100644 --- a/src/adiar/internal/algorithms/replace.h +++ b/src/adiar/internal/algorithms/replace.h @@ -31,34 +31,6 @@ namespace adiar::internal template using replace_func = function; - ////////////////////////////////////////////////////////////////////////////////////////////////// - /// \brief Replaces the level of a single pointer with the one provided by the map `m`. - /// - /// \details All other information, e.g. level-identifier, terminal value, and taint flag, are - /// preserved as-is. - ////////////////////////////////////////////////////////////////////////////////////////////////// - inline ptr_uint64 - __replace(const ptr_uint64& p, const replace_func& m) - { - return p.is_node() ? replace(p, m(p.level())) : p; - } - - ////////////////////////////////////////////////////////////////////////////////////////////////// - inline uid_uint64 - __replace(const uid_uint64& u, const replace_func& m) - { - return uid_uint64::unsafe(__replace(u.as_ptr(), m)); - } - - ////////////////////////////////////////////////////////////////////////////////////////////////// - /// \brief Replaces the level of a single node and its children pointers. - ////////////////////////////////////////////////////////////////////////////////////////////////// - inline node - __replace(const node& n, const replace_func& m) - { - return { __replace(n.uid(), m), __replace(n.low(), m), __replace(n.high(), m) }; - } - ////////////////////////////////////////////////////////////////////////////////////////////////// /// \brief Infer the replace type. ////////////////////////////////////////////////////////////////////////////////////////////////// @@ -190,7 +162,7 @@ namespace adiar::internal { // Copy over nodes (in "reverse" to still follow the same order on disk) node_ifstream in_nodes(dd); - while (in_nodes.can_pull()) { out.unsafe_push(__replace(in_nodes.pull(), m)); } + while (in_nodes.can_pull()) { out.unsafe_push(replace(in_nodes.pull(), m)); } } { // Copy over levels (also in "reverse") level_info_ifstream in_levels(dd); diff --git a/src/adiar/internal/data_types/node.h b/src/adiar/internal/data_types/node.h index 49c431fd3..acdac9c8d 100644 --- a/src/adiar/internal/data_types/node.h +++ b/src/adiar/internal/data_types/node.h @@ -4,6 +4,7 @@ #include #include +#include #include #include #include @@ -546,6 +547,15 @@ namespace adiar::internal /* =========================================== LEVELS ========================================= */ + ////////////////////////////////////////////////////////////////////////////////////////////////// + /// \brief Replaces the levels of the node and its children as provided by the given map function. + ////////////////////////////////////////////////////////////////////////////////////////////////// + inline node + replace(const node& n, const function& m) + { + return { replace(n.uid(), m), replace(n.low(), m), replace(n.high(), m) }; + } + ////////////////////////////////////////////////////////////////////////////////////////////////// /// \brief Shift the level of the node and its children by `levels` amount. ////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/adiar/internal/data_types/ptr.h b/src/adiar/internal/data_types/ptr.h index 5c86e63c3..0af45c1fe 100644 --- a/src/adiar/internal/data_types/ptr.h +++ b/src/adiar/internal/data_types/ptr.h @@ -6,6 +6,7 @@ #include #include +#include #include namespace adiar::internal @@ -888,6 +889,16 @@ namespace adiar::internal return p.is_node() ? unsafe_replace(p, new_level) : p; } + + ////////////////////////////////////////////////////////////////////////////////////////////////// + /// \brief Replaces the level with the one provided by the map function. + ////////////////////////////////////////////////////////////////////////////////////////////////// + inline ptr_uint64 + replace(const ptr_uint64& p, const function m) + { + return p.is_node() ? unsafe_replace(p, m(p.level())) : p; + } + ////////////////////////////////////////////////////////////////////////////////////////////////// /// \brief Combination of `essential(p)` and `replace(p, new_level)`. ////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/adiar/internal/data_types/uid.h b/src/adiar/internal/data_types/uid.h index 40fbb229c..3ee310ab7 100644 --- a/src/adiar/internal/data_types/uid.h +++ b/src/adiar/internal/data_types/uid.h @@ -3,6 +3,7 @@ #include +#include #include #include @@ -228,6 +229,16 @@ namespace adiar::internal return Uid::unsafe(replace(static_cast(u), new_level)); } + ////////////////////////////////////////////////////////////////////////////////////////////////// + /// \brief Replaces the level with the one provided by the map function. + ////////////////////////////////////////////////////////////////////////////////////////////////// + template + inline Uid + replace(const Uid& u, const function m) + { + return Uid::unsafe(replace(static_cast(u), m)); + } + ////////////////////////////////////////////////////////////////////////////////////////////////// /// \brief Replaces the level with the one given. ////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/tests/adiar/internal/data_types/node.test.cpp b/tests/adiar/internal/data_types/node.test.cpp index d31b8774d..a522909a7 100644 --- a/tests/adiar/internal/data_types/node.test.cpp +++ b/tests/adiar/internal/data_types/node.test.cpp @@ -460,6 +460,40 @@ go_bandit([]() { }); }); + describe("replace(const node&, function)", [&]() { + const function m = [](int x) { return 2*x; }; + + it("doubles levels of node and its children", [&]() { + const node in = node(0, 1, node::pointer_type(1, 2), node::pointer_type(2, 3)); + const node out = replace(in, m); + + AssertThat(out.uid(), Is().EqualTo(node::uid_type(0, 1))); + AssertThat(out.low(), Is().EqualTo(node::pointer_type(2, 2))); + AssertThat(out.high(), Is().EqualTo(node::pointer_type(4, 3))); + }); + + it("leaves terminal children as-is", [&]() { + const node in = node(2, 4, terminal_F, terminal_T); + const node out = replace(in, m); + + AssertThat(out.uid(), Is().EqualTo(node::uid_type(4, 4))); + AssertThat(out.low(), Is().EqualTo(node::pointer_type(false))); + AssertThat(out.high(), Is().EqualTo(node::pointer_type(true))); + }); + + it("leaves 'F' terminal node as-is", [&]() { + const node in = node(false); + const node out = replace(in, m); + AssertThat(in, Is().EqualTo(out)); + }); + + it("leaves 'T' terminal node as-is", [&]() { + const node in = node(true); + const node out = replace(in, m); + AssertThat(in, Is().EqualTo(out)); + }); + }); + describe("shift_replace(const node&, ...)", [&]() { it("leaves node as-is [levels = 0]", [&]() { const node in = node(0, 42, terminal_F, terminal_T); diff --git a/tests/adiar/internal/data_types/ptr.test.cpp b/tests/adiar/internal/data_types/ptr.test.cpp index 8344a49a8..e8e1c8af1 100644 --- a/tests/adiar/internal/data_types/ptr.test.cpp +++ b/tests/adiar/internal/data_types/ptr.test.cpp @@ -846,7 +846,7 @@ go_bandit([]() { }); }); - describe("replace(...)", [&]() { + describe("replace(ptr_uint64, int)", [&]() { it("halves x42 -> x21", [&]() { const ptr_uint64 in(42, 0); const ptr_uint64 out = replace(in, 21); @@ -872,6 +872,34 @@ go_bandit([]() { }); }); + describe("replace(ptr_uint64, function)", [&]() { + const function m = [](int x) { return x / 2; }; + + it("halves x42 -> x21", [&]() { + const ptr_uint64 in(42, 0); + const ptr_uint64 out = replace(in, m); + AssertThat(out, Is().EqualTo(ptr_uint64(21, 0))); + }); + + it("preserves 'F' terminal as-is", [&]() { + const ptr_uint64 in(false); + const ptr_uint64 out = replace(in, m); + AssertThat(out, Is().EqualTo(ptr_uint64(false))); + }); + + it("preserves 'T' terminal as-is", [&]() { + const ptr_uint64 in(true); + const ptr_uint64 out = replace(in, m); + AssertThat(out, Is().EqualTo(ptr_uint64(true))); + }); + + it("preserves 'nil' as-is", [&]() { + const ptr_uint64 in = ptr_uint64::nil(); + const ptr_uint64 out = replace(in, m); + AssertThat(out, Is().EqualTo(ptr_uint64::nil())); + }); + }); + describe("essential_replace(...)", [&]() { it("does nothing to 'nil'", [&]() { const ptr_uint64 in = ptr_uint64::nil(); From 4df8a001b78c1402e68123380c328410709ebdb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffan=20S=C3=B8lvsten?= Date: Tue, 12 May 2026 13:46:01 +0200 Subject: [PATCH 5/8] Rename replace sub-algorithms and move monotone Reduce policy inside its algorithm --- src/adiar/internal/algorithms/replace.h | 56 +++++++++++++------------ 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/src/adiar/internal/algorithms/replace.h b/src/adiar/internal/algorithms/replace.h index a5bc9f761..1462e08ba 100644 --- a/src/adiar/internal/algorithms/replace.h +++ b/src/adiar/internal/algorithms/replace.h @@ -125,7 +125,7 @@ namespace adiar::internal ////////////////////////////////////////////////////////////////////////////////////////////////// template inline typename Policy::dd_type - __replace__shift_return(const typename Policy::dd_type& dd, const replace_func& m) + replace__shift(const typename Policy::dd_type& dd, const replace_func& m) { adiar_assert(!dd->is_terminal()); @@ -143,7 +143,7 @@ namespace adiar::internal ////////////////////////////////////////////////////////////////////////////////////////////////// template inline typename Policy::dd_type - __replace__monotonic_scan(const typename Policy::dd_type& dd, const replace_func& m) + replace__monotone(const typename Policy::dd_type& dd, const replace_func& m) { adiar_assert(!dd->is_terminal()); @@ -176,32 +176,34 @@ namespace adiar::internal } ////////////////////////////////////////////////////////////////////////////////////////////////// - template - class replace_reduce_policy : public Policy - { - private: - const replace_func& _m; - - public: - replace_reduce_policy(const replace_func& m) - : _m(m) - {} - - constexpr inline typename Policy::label_type - map_level(typename Policy::label_type x) const - { - return this->_m(x); - } - }; - + /// \brief Replace the level of all nodes as part of the bottom-up reduce sweep. + /// + /// \remark This requires that the mapping, `m`, is *monotonic*. ////////////////////////////////////////////////////////////////////////////////////////////////// template inline typename Policy::dd_type - __replace__monotonic_reduce(const exec_policy& ep, - const typename Policy::__dd_type& __dd, - const replace_func& m) + replace__monotone(const exec_policy& ep, + const typename Policy::__dd_type& __dd, + const replace_func& m) { - replace_reduce_policy policy(m); + class reduce_policy : public Policy + { + private: + const replace_func& _m; + + public: + reduce_policy(const replace_func& m) + : _m(m) + {} + + constexpr inline typename Policy::label_type + map_level(typename Policy::label_type x) const + { + return this->_m(x); + } + }; + + reduce_policy policy(m); return reduce(ep, policy, std::move(__dd)); } @@ -249,13 +251,13 @@ namespace adiar::internal #ifdef ADIAR_STATS stats_replace.monotonic_scans += 1u; #endif - return __replace__monotonic_scan(dd, m); + return replace__monotone(dd, m); case replace_type::Shift: #ifdef ADIAR_STATS stats_replace.shift_returns += 1u; #endif - return __replace__shift_return(dd, m); + return replace__shift(dd, m); case replace_type::Identity: #ifdef ADIAR_STATS @@ -304,7 +306,7 @@ namespace adiar::internal #ifdef ADIAR_STATS stats_replace.monotonic_reduces += 1u; #endif - return __replace__monotonic_reduce(ep, std::move(__dd), m); + return replace__monotone(ep, std::move(__dd), m); case replace_type::Identity: #ifdef ADIAR_STATS From f6865aff0f5b7bb77b0004245fbea5d3776221fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffan=20S=C3=B8lvsten?= Date: Tue, 12 May 2026 13:46:20 +0200 Subject: [PATCH 6/8] Restructure comments on replace sub-algorithms --- src/adiar/internal/algorithms/replace.h | 100 +++++++++++++++++++++++- 1 file changed, 96 insertions(+), 4 deletions(-) diff --git a/src/adiar/internal/algorithms/replace.h b/src/adiar/internal/algorithms/replace.h index 1462e08ba..283ffa347 100644 --- a/src/adiar/internal/algorithms/replace.h +++ b/src/adiar/internal/algorithms/replace.h @@ -23,7 +23,7 @@ namespace adiar::internal extern statistics::replace_t stats_replace; ////////////////////////////////////////////////////////////////////////////////////////////////// - // Helper Functions + // Types ////////////////////////////////////////////////////////////////////////////////////////////////// /// \brief A total mapping function. @@ -31,6 +31,9 @@ namespace adiar::internal template using replace_func = function; + ////////////////////////////////////////////////////////////////////////////////////////////////// + // Inference of the most precise replacement-type. + ////////////////////////////////////////////////////////////////////////////////////////////////// /// \brief Infer the replace type. ////////////////////////////////////////////////////////////////////////////////////////////////// @@ -116,7 +119,17 @@ namespace adiar::internal } ////////////////////////////////////////////////////////////////////////////////////////////////// - // Algorithms + // Algorithms: `Shift` + // + // If the decision diagram is already fully reduced and the variable ordering is a mere `Shift`, + // i.e. the levels are offset by the same constant amount, then we can reuse the original file by + // merely deferring the level replacement until it is read later. This saves an expensive O(N/B) + // copy operation and disk space otherwise done for the `Monotone` case below. + /* + // a a | x -> x+c + // / \ => / \ + // b c b c | y -> y+c + */ ////////////////////////////////////////////////////////////////////////////////////////////////// /// \brief Replace the level in constant time @@ -136,6 +149,18 @@ namespace adiar::internal dd.file_ptr(), dd.is_negated(), dd.shift() + (shifted_topvar - topvar)); } + ////////////////////////////////////////////////////////////////////////////////////////////////// + // Algorithms: `Monotone` + // + // If the variable ordering is monotone, i.e. the levels still follow the same relative ordering, + // then we can apply the level replacement node-for-node or as part of the reduce algorithm (which + // has to be run anyways). + /* + // a a' | x -> x' + // / \ => / \ + // b c b' c' | y -> y' + */ + ////////////////////////////////////////////////////////////////////////////////////////////////// /// \brief Replace the level of all nodes in a single linear scan. /// @@ -208,10 +233,77 @@ namespace adiar::internal } ////////////////////////////////////////////////////////////////////////////////////////////////// - // TODO: Nested Sweeping for non-monotonic reorderings. + // Algorithms: `Jump_Down` (+ `Swap_Adjacent`) + // + // Top-down 2-ary product construction which works as a `prod2u` extended with logic in + // `intercut` to move levels down. + /* + // ____ O ____ __ O __ | ... + // / \ / \ + // _a_ _b_ / \ | x -> y + // / \ / \ => / \ + // c c' d d' (c,c') (d,d') | ... + // / \ / \ / \ / \ / \ / \ + // | | | \ | | | \ (e,e') (f,f') (g,g') (h,h') | y + // | | | | | | | | / \ / \ / \ / \ + // e f e' f' g h g' h' e e' f f' g g' h h' | ... + */ + // The most basic version assumes the target level is empty. This can be (thereby also supporting + // `Swap_Adjacent`) by doubling levels in the levelized priority queue; input and untouched levels + // are even whereas target levels are odd. + // + // This sweep is guaranteed to preserve the reducedness of the input! That is, if one does not + // care about the output being *sorted*, then one can use the fast `reduce` operation. + + // TODO + + ////////////////////////////////////////////////////////////////////////////////////////////////// + // Algorithms: `Jump_Up` + // + // Bottom-up 2-ary product construction that incorporates `intercut` inside of the bottom-up + // `reduce` sweep. + /* + // + // e _ e _ | ... + // / \ / \ + // / \ (!) \ | x + // / \ / \ \ + // d f (a,g) (b,g) f | ... + // / \ => / + // c \ (a,b) | y -> x + // / \ \ / \ + // a b g a b | ... + */ + // This procedure *can* create duplicate nodes. Hence, one has to still do one (or two?) sorting + // steps to remove duplicate nodes. + // + // To be able to send a variable to a level that is occupied in the input, we again do the + // doubling trick above inside of the levelized priority queue. + + // TODO + + ////////////////////////////////////////////////////////////////////////////////////////////////// + // Algorithms: `Non-Monotone` (+ `Swap`) + // + // Starting from the bottom with *nested sweeping*, we accumulate the results of multiple + // `Jump_Downs`. This is essentially an *insertion sort* on the levels. Here, we can abuse the + // invariant, that the nested `Jump_Down` is always moving levels down to an empty one. + /* + // . . . . . _._ | x -> y + // / \ / \ / \ + // . | ==(z)=> ==(y)=> . . ==(x)=> . . | y -> z + // / \/ / \ / \ + // . . . . . . | z -> x + */ + // The main weakness of this operation is if something has to be moved up, i.e. multiple + // `Jump_Down` operations are used to effectively create a single `Jump_Up`. To mitigate this, we + // want to preface the nested sweep with one or more `Jump_Up` and `Adjacent_Swap` operations. + // Furthermore, we can incorporate the `Jump_Up` logic inside the Outer Reduce. + + // TODO ////////////////////////////////////////////////////////////////////////////////////////////////// - // "Public" interface + // Public interface ////////////////////////////////////////////////////////////////////////////////////////////////// /// \brief Replace variables based on the given (total) map. From a5056ba359d3be87f4e5d3eb59c4c97c0acb8686 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffan=20S=C3=B8lvsten?= Date: Tue, 12 May 2026 14:57:30 +0200 Subject: [PATCH 7/8] Fix typo in prod2u explanatory diagram --- src/adiar/internal/algorithms/prod2u.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/adiar/internal/algorithms/prod2u.h b/src/adiar/internal/algorithms/prod2u.h index 40e634d83..6fa98c457 100644 --- a/src/adiar/internal/algorithms/prod2u.h +++ b/src/adiar/internal/algorithms/prod2u.h @@ -29,7 +29,7 @@ namespace adiar::internal // / \ / \ // (a) (b) / \ // / \ X / \ => / \ - // a0 a1 b1 b2 (a0,b0) (a1,b1) + // a0 a1 b0 b1 (a0,b0) (a1,b1) */ // Examples of uses are `internal::quantify`. ////////////////////////////////////////////////////////////////////////////////////////////////// From 672eef0f75489685605fad6fe888654ee57f577a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffan=20S=C3=B8lvsten?= Date: Tue, 12 May 2026 16:03:25 +0200 Subject: [PATCH 8/8] Remove label from internal representation Until now, we have always assumed the identity order. That is, we have always assumed that 'label' = 'level'. This paves the way for variable reordering. The only thing that remains is 'max_label'; assuming the user are using variables 0, 1, ..., n this is reasonable since the 'ptr_uint64' representation bounds the size of 'n'. --- src/adiar/bdd/evaluate.cpp | 14 +- src/adiar/bdd/if_then_else.cpp | 38 +++--- src/adiar/bdd/relprod.cpp | 10 +- src/adiar/builder.h | 4 +- src/adiar/domain.h | 2 +- src/adiar/internal/algorithms/build.h | 46 +++---- src/adiar/internal/algorithms/convert.h | 10 +- src/adiar/internal/algorithms/dot.h | 10 +- src/adiar/internal/algorithms/intercut.h | 72 +++++----- .../internal/algorithms/nested_sweeping.h | 86 ++++++------ src/adiar/internal/algorithms/optmin.h | 8 +- src/adiar/internal/algorithms/pred.cpp | 12 +- src/adiar/internal/algorithms/pred.h | 2 +- src/adiar/internal/algorithms/prod2b.h | 38 +++--- src/adiar/internal/algorithms/prod2u.h | 30 ++-- src/adiar/internal/algorithms/quantify.h | 86 ++++++------ src/adiar/internal/algorithms/reduce.h | 46 +++---- src/adiar/internal/algorithms/replace.h | 32 ++--- src/adiar/internal/algorithms/select.h | 4 +- .../internal/data_structures/level_merger.h | 2 +- .../levelized_priority_queue.h | 128 +++++++++--------- src/adiar/internal/data_types/arc.h | 8 +- src/adiar/internal/data_types/convert.h | 6 +- src/adiar/internal/data_types/level_info.h | 21 +-- src/adiar/internal/data_types/node.h | 54 +++----- src/adiar/internal/data_types/ptr.h | 68 ++++------ src/adiar/internal/data_types/request.h | 24 ++-- src/adiar/internal/data_types/uid.h | 8 +- src/adiar/internal/dd.h | 44 +++++- src/adiar/internal/dd_func.h | 2 +- src/adiar/internal/io/levelized_ifstream.h | 4 +- src/adiar/internal/io/levelized_raccess.h | 24 ++-- src/adiar/internal/io/narc_ifstream.h | 4 +- src/adiar/internal/io/narc_raccess.h | 6 +- src/adiar/internal/io/node_ifstream.h | 6 +- src/adiar/internal/io/node_ofstream.h | 8 +- src/adiar/internal/io/node_raccess.h | 6 +- src/adiar/internal/util.h | 13 +- src/adiar/zdd/change.cpp | 2 +- src/adiar/zdd/complement.cpp | 2 +- src/adiar/zdd/contains.cpp | 4 +- src/adiar/zdd/elem.cpp | 4 +- src/adiar/zdd/expand.cpp | 2 +- src/adiar/zdd/pred.cpp | 4 +- src/adiar/zdd/subset.cpp | 12 +- tests/adiar/bdd/count.test.cpp | 2 +- tests/adiar/domain.test.cpp | 34 ++--- .../algorithms/nested_sweeping.test.cpp | 44 +++--- .../levelized_priority_queue.test.cpp | 52 +++---- tests/adiar/internal/data_types/arc.test.cpp | 16 +-- .../internal/data_types/convert.test.cpp | 18 +-- .../internal/data_types/level_info.test.cpp | 11 +- tests/adiar/internal/data_types/node.test.cpp | 36 ++--- tests/adiar/internal/data_types/ptr.test.cpp | 50 +++---- tests/adiar/zdd/project.test.cpp | 4 +- 55 files changed, 630 insertions(+), 653 deletions(-) diff --git a/src/adiar/bdd/evaluate.cpp b/src/adiar/bdd/evaluate.cpp index 06b0d4129..ba3ecc4cf 100644 --- a/src/adiar/bdd/evaluate.cpp +++ b/src/adiar/bdd/evaluate.cpp @@ -30,7 +30,7 @@ namespace adiar inline bdd::pointer_type visit(const bdd::node_type& n) { - const bool a = af(n.label()); + const bool a = af(n.level()); return a ? n.high() : n.low(); } @@ -77,7 +77,7 @@ namespace adiar inline bdd::pointer_type visit(const bdd::node_type& n) { - const bdd::label_type level = n.label(); + const bdd::level_type level = n.level(); while (_next_pair.first < level) { const optional> p = _generator(); @@ -148,16 +148,17 @@ namespace adiar visit(const bdd::node_type& n) { // Add skipped levels - while (this->_next_domain && this->_next_domain.value() <= n.label()) { + while (this->_next_domain && this->_next_domain.value() <= n.level()) { const bdd::label_type next_domain = this->_next_domain.value(); - if (next_domain != n.label()) { + if (next_domain != n.level()) { this->_stack.push({ next_domain, !Visitor::default_direction }); } this->_next_domain = this->_generator(); } // Update with this level const bdd::pointer_type next = this->_visitor.visit(n); - this->_stack.push({ n.label(), next == n.low() }); + const bdd::level_type level = n.level(); + this->_stack.push({ level, next == n.low() }); return next; } @@ -206,7 +207,8 @@ namespace adiar visit(const bdd::node_type& n) { const bdd::pointer_type next = this->_visitor.visit(n); - this->_consumer({ n.label(), next == n.high() }); + const bdd::level_type level = n.level(); + this->_consumer({ level, next == n.high() }); return next; } diff --git a/src/adiar/bdd/if_then_else.cpp b/src/adiar/bdd/if_then_else.cpp index 2361eb5d0..5521ccf34 100644 --- a/src/adiar/bdd/if_then_else.cpp +++ b/src/adiar/bdd/if_then_else.cpp @@ -116,13 +116,13 @@ namespace adiar inline bool ite_must_forward(internal::node v, internal::node::pointer_type t, - internal::node::label_type out_label, + internal::node::level_type out_level, internal::node::pointer_type t_seek) { return // is it a node at this level? t.is_node() - && t.label() == out_label + && t.level() == out_level // and we should be seeing it later && t_seek < t // and we haven't by accident just run into it anyway @@ -132,11 +132,11 @@ namespace adiar inline void ite_init_request(internal::node_ifstream<>& in_nodes, internal::node& v, - const internal::node::label_type out_label, + const internal::node::level_type out_level, internal::node::pointer_type& low, internal::node::pointer_type& high) { - if (v.label() == out_label) { + if (v.level() == out_level) { low = v.low(); high = v.high(); @@ -220,18 +220,18 @@ namespace adiar // Process root and create initial recursion requests { - const bdd::label_type out_label = first(v_if.uid(), v_then.uid(), v_else.uid()).label(); + const bdd::level_type out_level = first(v_if.uid(), v_then.uid(), v_else.uid()).level(); bdd::pointer_type low_if, low_then, low_else, high_if, high_then, high_else; - ite_init_request(in_nodes_if, v_if, out_label, low_if, high_if); - ite_init_request(in_nodes_then, v_then, out_label, low_then, high_then); - ite_init_request(in_nodes_else, v_else, out_label, low_else, high_else); + ite_init_request(in_nodes_if, v_if, out_level, low_if, high_if); + ite_init_request(in_nodes_then, v_then, out_level, low_then, high_then); + ite_init_request(in_nodes_else, v_else, out_level, low_else, high_else); - const bdd::node_type::uid_type out_uid(out_label, 0); + const bdd::node_type::uid_type out_uid(out_level, 0); __ite_resolve_request(pq_1, aw, out_uid.as_ptr(false), low_if, low_then, low_else); __ite_resolve_request(pq_1, aw, out_uid.as_ptr(true), high_if, high_then, high_else); - aw.push(internal::level_info(out_label, 1)); + aw.push(internal::level_info(out_level, 1)); } // Process all nodes in topological order of both BDDs @@ -239,7 +239,7 @@ namespace adiar // Set up next level pq_1.setup_next_level(); - const bdd::label_type out_label = pq_1.current_level(); + const bdd::level_type out_level = pq_1.current_level(); bdd::id_type out_id = 0; // Update max 1-level cut @@ -290,9 +290,9 @@ namespace adiar while (v_else.uid() < t_seek && in_nodes_else.can_pull()) { v_else = in_nodes_else.pull(); } // Forward information across the level - if (ite_must_forward(v_if, req.target[0], out_label, t_seek) - || ite_must_forward(v_then, req.target[1], out_label, t_seek) - || ite_must_forward(v_else, req.target[2], out_label, t_seek)) { + if (ite_must_forward(v_if, req.target[0], out_level, t_seek) + || ite_must_forward(v_then, req.target[1], out_level, t_seek) + || ite_must_forward(v_else, req.target[2], out_level, t_seek)) { // An element should be forwarded, if it was not already forwarded (t_seek <= t_x), if it // isn't the last one to seek (t_x < t_third), and if we actually are holding it. const bool forward_if = @@ -358,7 +358,7 @@ namespace adiar // Recreate nodes from priority queue carries bdd::pointer_type low_if, low_then, low_else, high_if, high_then, high_else; - if (req.target[0].is_terminal() || out_label < req.target[0].label()) { + if (req.target[0].is_terminal() || out_level < req.target[0].level()) { low_if = high_if = req.target[0]; } else { low_if = req.target[0] == v_if.uid() ? v_if.low() : req.node_carry[0][false]; @@ -366,7 +366,7 @@ namespace adiar } if (req.target[1].is_nil() || req.target[1].is_terminal() - || out_label < req.target[1].label()) { + || out_level < req.target[1].level()) { low_then = high_then = req.target[1]; } else if (req.target[1] == v_then.uid()) { low_then = v_then.low(); @@ -380,7 +380,7 @@ namespace adiar } if (req.target[2].is_nil() || req.target[2].is_terminal() - || out_label < req.target[2].label()) { + || out_level < req.target[2].level()) { low_else = high_else = req.target[2]; } else if (req.target[2] == v_else.uid()) { low_else = v_else.low(); @@ -395,7 +395,7 @@ namespace adiar // Resolve request adiar_assert(out_id < bdd::max_id, "Has run out of ids"); - const bdd::node_type::uid_type out_uid(out_label, out_id++); + const bdd::node_type::uid_type out_uid(out_level, out_id++); __ite_resolve_request(pq_1, aw, out_uid.as_ptr(false), low_if, low_then, low_else); __ite_resolve_request(pq_1, aw, out_uid.as_ptr(true), high_if, high_then, high_else); @@ -422,7 +422,7 @@ namespace adiar } // Push meta data about this level - aw.push(internal::level_info(out_label, out_id)); + aw.push(internal::level_info(out_level, out_id)); } return __bdd(out_arcs, ep); diff --git a/src/adiar/bdd/relprod.cpp b/src/adiar/bdd/relprod.cpp index abdb12624..b021fdb30 100644 --- a/src/adiar/bdd/relprod.cpp +++ b/src/adiar/bdd/relprod.cpp @@ -33,10 +33,10 @@ namespace adiar public: void - setup_next_level(const bdd::label_type next_level) + setup_next_level(const bdd::level_type next_level) { using result_type = typename LevelPredicate::result_type; - constexpr bool is_total_map = is_convertible; + constexpr bool is_total_map = is_convertible; if constexpr (is_total_map) { this->_prune_level = this->_pred(next_level); @@ -272,10 +272,10 @@ namespace adiar //////////////////////////////////////////////////////////////////////////////////////////////// /// \brief Variable remapping of. //////////////////////////////////////////////////////////////////////////////////////////////// - inline bdd::label_type - map_level(bdd::label_type x) const + inline bdd::level_type + map_level(bdd::level_type x) const { - const optional new_x = this->_m(x); + const optional new_x = this->_m(x); return new_x.has_value() ? new_x.value() : bdd::max_label + 1; } diff --git a/src/adiar/builder.h b/src/adiar/builder.h index ec5a0c7a3..a682c5d0a 100644 --- a/src/adiar/builder.h +++ b/src/adiar/builder.h @@ -250,10 +250,10 @@ namespace adiar } if (label > Policy::max_label) { throw invalid_argument("Nodes must have a valid label"); } if (label > current_label) { throw invalid_argument("Nodes must be added bottom-up"); } - if (low.uid.is_node() && low.uid.label() <= label) { + if (low.uid.is_node() && low.uid.level() <= label) { throw invalid_argument("Low child must point to a node with higher label"); } - if (high.uid.is_node() && high.uid.label() <= label) { + if (high.uid.is_node() && high.uid.level() <= label) { throw invalid_argument("High child must point to a node with higher label"); } diff --git a/src/adiar/domain.h b/src/adiar/domain.h index 019801b6d..1e67c2664 100644 --- a/src/adiar/domain.h +++ b/src/adiar/domain.h @@ -29,7 +29,7 @@ namespace adiar ////////////////////////////////////////////////////////////////////////////////////////////////// /// \brief The variable type of a domain variable. ////////////////////////////////////////////////////////////////////////////////////////////////// - using domain_var = internal::node::label_type; + using domain_var = internal::node::level_type; ////////////////////////////////////////////////////////////////////////////////////////////////// /// \brief The maximum supported domain variable. diff --git a/src/adiar/internal/algorithms/build.h b/src/adiar/internal/algorithms/build.h index f4186022e..78153fd44 100644 --- a/src/adiar/internal/algorithms/build.h +++ b/src/adiar/internal/algorithms/build.h @@ -38,20 +38,20 @@ namespace adiar::internal ////////////////////////////////////////////////////////////////////////////// template inline shared_levelized_file - build_ithvar(typename DdPolicy::label_type label) + build_ithvar(typename DdPolicy::level_type level) { using node_type = typename DdPolicy::node_type; using pointer_type = typename node_type::pointer_type; - if (node_type::max_label < label) { - throw invalid_argument("Cannot represent that large a label"); + if (node_type::max_label < level) { + throw invalid_argument("Cannot represent that large a level"); } shared_levelized_file nf; { node_ofstream nw(nf); - nw.unsafe_push(node(label, pointer_type::max_id, pointer_type(false), pointer_type(true))); - nw.unsafe_push(level_info(label, 1u)); + nw.unsafe_push(node(level, pointer_type::max_id, pointer_type(false), pointer_type(true))); + nw.unsafe_push(level_info(level, 1u)); nw.unsafe_set_canonical(true); } @@ -65,9 +65,9 @@ namespace adiar::internal inline typename Policy::dd_type build_chain(const Policy& policy, const Generator& vars) { - using label_type = typename Policy::label_type; + using level_type = typename Policy::level_type; - optional> next = vars(); + optional> next = vars(); if (!next) { return build_terminal(Policy::init_terminal); } @@ -84,16 +84,16 @@ namespace adiar::internal adiar_assert(root.is_terminal()); do { - const label_type next_var = next.value().first; - const label_type next_negated = next.value().second; + const level_type next_var = next.value().first; + const level_type next_negated = next.value().second; // Fail if generator is increasing. - if (!root.is_terminal() && root.label() < next_var) { - throw invalid_argument("Labels not given in decreasing order"); + if (!root.is_terminal() && root.level() < next_var) { + throw invalid_argument("Levels not given in decreasing order"); } // Skip value if generator provides the same (legal) value twice. - if (!root.is_terminal() && root.label() == next_var) { + if (!root.is_terminal() && root.level() == next_var) { next = vars(); continue; } @@ -104,14 +104,14 @@ namespace adiar::internal continue; } - // TODO: throw exception for too large labels + // TODO: throw exception for too large levels // Create node on chain. using node_type = typename Policy::node_type; const node_type n = policy.make_node(next_var, root, next_negated); - adiar_assert(n.label() == next_var, "Policy ought to make a node for this level node"); + adiar_assert(n.level() == next_var, "Policy ought to make a node for this level node"); adiar_assert(n.id() == node_type::max_id, "Policy ought to make a canonical node"); max_internal_cut = std::max(max_internal_cut, n.low().is_node() + n.high().is_node()); @@ -140,7 +140,7 @@ namespace adiar::internal root = n.uid(); - // Get next label + // Get next level next = vars(); } while (next); @@ -183,13 +183,13 @@ namespace adiar::internal static constexpr bool init_terminal = InitTerminal; constexpr bool - skip(const typename DdPolicy::label_type&) const + skip(const typename DdPolicy::level_type&) const { return false; } inline typename DdPolicy::node_type - make_node(const typename DdPolicy::label_type& l, + make_node(const typename DdPolicy::level_type& l, const typename DdPolicy::pointer_type& r, const bool /*negated*/) const { @@ -208,13 +208,13 @@ namespace adiar::internal static constexpr bool init_terminal = InitTerminal; constexpr bool - skip(const typename DdPolicy::label_type&) const + skip(const typename DdPolicy::level_type&) const { return false; } inline typename DdPolicy::node_type - make_node(const typename DdPolicy::label_type& l, + make_node(const typename DdPolicy::level_type& l, const typename DdPolicy::pointer_type& r, const bool /*negated*/) const { @@ -234,13 +234,13 @@ namespace adiar::internal static constexpr bool init_terminal = InitTerminal; constexpr bool - skip(const typename DdPolicy::label_type&) const + skip(const typename DdPolicy::level_type&) const { return false; } inline typename DdPolicy::node_type - make_node(const typename DdPolicy::label_type& l, + make_node(const typename DdPolicy::level_type& l, const typename DdPolicy::pointer_type& r, const bool /*negated*/) const { @@ -259,7 +259,7 @@ namespace adiar::internal const Generator& _gen; public: - using value_type = pair; + using value_type = pair; using result_type = optional; private: @@ -270,7 +270,7 @@ namespace adiar::internal } inline value_type - map(const typename DdPolicy::label_type& x) const + map(const typename DdPolicy::level_type& x) const { return make_pair(x, negate); } diff --git a/src/adiar/internal/algorithms/convert.h b/src/adiar/internal/algorithms/convert.h index cd4e3884e..369466652 100644 --- a/src/adiar/internal/algorithms/convert.h +++ b/src/adiar/internal/algorithms/convert.h @@ -29,10 +29,10 @@ namespace adiar::internal using node_type = typename from_policy::node_type; using __dd_type = typename to_policy::__dd_type; - using label_type = typename to_policy::label_type; + using level_type = typename to_policy::level_type; using id_type = typename to_policy::id_type; - static constexpr label_type max_label = to_policy::max_label; + static constexpr level_type max_label = to_policy::max_label; static constexpr id_type max_id = to_policy::max_id; @@ -46,7 +46,7 @@ namespace adiar::internal public: static typename to_policy::dd_type - on_empty_labels(const typename from_policy::dd_type& dd) + on_empty_levels(const typename from_policy::dd_type& dd) { adiar_assert(dd_isterminal(dd)); return typename to_policy::dd_type(dd.file_ptr(), dd.is_negated(), 0); @@ -55,7 +55,7 @@ namespace adiar::internal static typename to_policy::dd_type on_terminal_input(const bool terminal_value, const typename from_policy::dd_type& /*dd*/, - const internal_vector& dom) + const internal_vector& dom) { adiar_assert(dom.size() > 0, "Emptiness check is before terminal check"); @@ -78,7 +78,7 @@ namespace adiar::internal nw.unsafe_push(next_node); nw.unsafe_push(level_info(*iter, 1u)); } else { - // If we kill the resulting node once, then we will also do it for all the other labels we + // If we kill the resulting node once, then we will also do it for all the other levels we // still are missing. has_output = false; break; diff --git a/src/adiar/internal/algorithms/dot.h b/src/adiar/internal/algorithms/dot.h index dbebc6232..7c2d0a1d3 100644 --- a/src/adiar/internal/algorithms/dot.h +++ b/src/adiar/internal/algorithms/dot.h @@ -48,7 +48,7 @@ namespace adiar::internal while (ns.can_pull()) { const node n = ns.pull(); - out << "\tn" << n.uid()._raw << " [label=" << n.label(); + out << "\tn" << n.uid()._raw << " [label=" << n.level(); if (include_id) { out << ", " << n.id(); } out << ">, style=rounded];\n"; } @@ -91,7 +91,7 @@ namespace adiar::internal out << "\t{ rank=same; " << "n" << current_node.uid()._raw << " "; - while (ns.can_pull() && current_node.label() == ns.peek().label()) { + while (ns.can_pull() && current_node.level() == ns.peek().level()) { out << "n" << ns.pull().uid()._raw << " "; } out << "}" @@ -158,8 +158,8 @@ namespace adiar::internal while (as.can_pull_internal()) { const arc a = as.pull_internal(); out << "\t" - << "n" << a.target().label() << "_" << a.target().id() << " -> " - << "n" << a.source().label() << "_" << a.source().id() + << "n" << a.target().level() << "_" << a.target().id() << " -> " + << "n" << a.source().level() << "_" << a.source().id() << " [style=" << (a.out_idx() ? "solid" : "dashed") << ", color=blue];" << std::endl; } @@ -171,7 +171,7 @@ namespace adiar::internal while (as.can_pull_terminal()) { const arc a = as.pull_terminal(); out << "\t" - << "n" << a.source().label() << "_" << a.source().id() << " -> " + << "n" << a.source().level() << "_" << a.source().id() << " -> " << "s" << a.target().value() << " [style=" << (a.out_idx() ? "solid" : "dashed") << ", color=red];" << std::endl; } diff --git a/src/adiar/internal/algorithms/intercut.h b/src/adiar/internal/algorithms/intercut.h index fadff942c..7d5517785 100644 --- a/src/adiar/internal/algorithms/intercut.h +++ b/src/adiar/internal/algorithms/intercut.h @@ -75,8 +75,8 @@ namespace adiar::internal // Helper functions template bool - cut_terminal(const typename Policy::label_type curr_level, - const typename Policy::label_type cut_level, + cut_terminal(const typename Policy::level_type curr_level, + const typename Policy::level_type cut_level, const bool terminal_value) { return curr_level < cut_level && cut_level <= Policy::max_label @@ -96,8 +96,8 @@ namespace adiar::internal pq_t& pq, const typename Policy::pointer_type source, const typename Policy::pointer_type target, - const typename Policy::label_type curr_level, - const typename Policy::label_type next_cut) + const typename Policy::level_type curr_level, + const typename Policy::level_type next_cut) { if (target.is_terminal() && !cut_terminal(curr_level, next_cut, target.value())) { aw.push_terminal(arc(source, target)); @@ -118,8 +118,8 @@ namespace adiar::internal pq_t& /*pq*/, const ptr_uint64 source, const ptr_uint64 target, - const ptr_uint64::label_type /*curr_level*/, - const ptr_uint64::label_type /*next_cut*/) + const ptr_uint64::level_type /*curr_level*/, + const ptr_uint64::level_type /*next_cut*/) { aw.push_internal(arc(source, target)); } @@ -129,19 +129,19 @@ namespace adiar::internal inline void intercut_in__pq(arc_ofstream& aw, PriorityQueue& pq, - const typename Policy::label_type out_label, + const typename Policy::level_type out_level, const typename Policy::pointer_type target, const typename Policy::pointer_type out_target, - const typename Policy::label_type l) + const typename Policy::level_type l) { - adiar_assert(out_label <= out_target.level(), + adiar_assert(out_level <= out_target.level(), "should forward/output a node on this level or ahead."); - while (pq.can_pull() && pq.top().level() == out_label && pq.top().target[0] == target) { + while (pq.can_pull() && pq.top().level() == out_level && pq.top().target[0] == target) { const typename Policy::pointer_type parent = pq.pull().data.source; if (OutPolicy::ignore_nil && parent.is_nil()) { continue; } - OutPolicy::forward(aw, pq, parent, out_target, out_label, l); + OutPolicy::forward(aw, pq, parent, out_target, out_level, l); } } @@ -149,23 +149,23 @@ namespace adiar::internal typename Policy::__dd_type __intercut(const exec_policy& ep, const typename Policy::dd_type& dd, - const generator& xs, + const generator& xs, const size_t pq_memory, const size_t max_pq_size) { node_ifstream<> in_nodes(dd); node n = in_nodes.pull(); - // Copy the labels into a B-sized vector. This way, we can read it twice: once for the levels in + // Copy the levels into a B-sized vector. This way, we can read it twice: once for the levels in // the priority queue and secondly for a lookahead of where to cut next. // // Alternatively, we could also hack it by wrapping `xs` with a side-effect of updating a // variable in this scope. But, the resulting code complexity does not seem worth it. - internal_vector hit_levels(dd::max_label); + internal_vector hit_levels(dd::max_label); for (auto x = xs(); x; x = xs()) { hit_levels.push_back(x.value()); } - typename internal_vector::iterator ls = hit_levels.begin(); - if (ls == hit_levels.end()) { return Policy::on_empty_labels(dd); } + typename internal_vector::iterator ls = hit_levels.begin(); + if (ls == hit_levels.end()) { return Policy::on_empty_levels(dd); } if (n.is_terminal()) { return Policy::on_terminal_input(n.value(), dd, hit_levels); } @@ -186,21 +186,21 @@ namespace adiar::internal // Set up next level intercut_pq.setup_next_level(); - const typename Policy::label_type out_label = intercut_pq.current_level(); + const typename Policy::level_type out_level = intercut_pq.current_level(); typename Policy::id_type out_id = 0; // Derive whether this level needs to be cut and what is the next level. Note, that `ls` is // always kept ahead of the current level (until it is empty). - const bool hit_level = ls != hit_levels.end() && out_label == *ls; + const bool hit_level = ls != hit_levels.end() && out_level == *ls; if (hit_level) { ++ls; } - const typename Policy::label_type next_hit = + const typename Policy::level_type next_hit = ls == hit_levels.end() ? with_level::no_level : *ls; // Update max 1-level cut out_arcs->max_1level_cut = std::max(out_arcs->max_1level_cut, intercut_pq.size()); // Resolve requests with targets at this level - while (!intercut_pq.empty_level() && intercut_pq.peek().target[0].level() == out_label) { + while (!intercut_pq.empty_level() && intercut_pq.peek().target[0].level() == out_level) { while (n.uid() < intercut_pq.top().target[0]) { n = in_nodes.pull(); } adiar_assert(n.uid() == intercut_pq.top().target[0], "should always find desired node"); @@ -211,51 +211,51 @@ namespace adiar::internal const intercut_rec_skipto rs = std::get(r); if (rs.tgt.is_terminal() && intercut_pq.top().data.source.is_nil() - && !cut_terminal(out_label, next_hit, rs.tgt.value())) { + && !cut_terminal(out_level, next_hit, rs.tgt.value())) { return Policy::terminal(rs.tgt.value()); } // TODO: The 'rs.tgt.is_terminal() && cut_terminal(...)' case can be handled even better - // with 'Policy::on_terminal_input' but where the label file are only of - // the remaining labels. + // with 'Policy::on_terminal_input' but where the level file are only of + // the remaining levels. intercut_in__pq>( - aw, intercut_pq, out_label, n.uid(), rs.tgt, next_hit); + aw, intercut_pq, out_level, n.uid(), rs.tgt, next_hit); } else { const intercut_rec_output ro = std::get(r); - const node::uid_type out_uid(out_label, out_id++); + const node::uid_type out_uid(out_level, out_id++); intercut_out__pq::forward( - aw, intercut_pq, out_uid.as_ptr(false), ro.low, out_label, next_hit); + aw, intercut_pq, out_uid.as_ptr(false), ro.low, out_level, next_hit); intercut_out__pq::forward( - aw, intercut_pq, out_uid.as_ptr(true), ro.high, out_label, next_hit); + aw, intercut_pq, out_uid.as_ptr(true), ro.high, out_level, next_hit); intercut_in__pq( - aw, intercut_pq, out_label, n.uid(), out_uid, next_hit); + aw, intercut_pq, out_level, n.uid(), out_uid, next_hit); } } // Resolve requests with targets beyond this level, i.e. edges that should be cut. while (!intercut_pq.empty_level()) { - adiar_assert(out_label <= next_hit, - "the last iteration in this case is for the very last label to cut on"); + adiar_assert(out_level <= next_hit, + "the last iteration in this case is for the very last level to cut on"); const intercut_request request = intercut_pq.top(); const intercut_rec_output ro = Policy::hit_cut(request.target[0]); - const node::uid_type out_uid(out_label, out_id++); + const node::uid_type out_uid(out_level, out_id++); intercut_out__pq::forward( - aw, intercut_pq, out_uid.as_ptr(false), ro.low, out_label, next_hit); + aw, intercut_pq, out_uid.as_ptr(false), ro.low, out_level, next_hit); intercut_out__pq::forward( - aw, intercut_pq, out_uid.as_ptr(true), ro.high, out_label, next_hit); + aw, intercut_pq, out_uid.as_ptr(true), ro.high, out_level, next_hit); intercut_in__pq( - aw, intercut_pq, out_label, request.target[0], out_uid, next_hit); + aw, intercut_pq, out_level, request.target[0], out_uid, next_hit); } // Update meta data - if (out_id > 0) { aw.push(level_info(out_label, out_id)); } + if (out_id > 0) { aw.push(level_info(out_level, out_id)); } } return typename Policy::__dd_type(out_arcs, ep); @@ -275,7 +275,7 @@ namespace adiar::internal typename Policy::__dd_type intercut(const exec_policy& ep, const typename Policy::dd_type& dd, - const generator& xs) + const generator& xs) { // Compute amount of memory available for auxiliary data structures after having opened all // streams. diff --git a/src/adiar/internal/algorithms/nested_sweeping.h b/src/adiar/internal/algorithms/nested_sweeping.h index ef68f101a..d4f6ef0c4 100644 --- a/src/adiar/internal/algorithms/nested_sweeping.h +++ b/src/adiar/internal/algorithms/nested_sweeping.h @@ -45,8 +45,8 @@ namespace adiar::internal template void __reduce_level__fast(ArcStream& arcs, - const typename Policy::label_type in_label, - const typename Policy::label_type out_label, + const typename Policy::level_type in_level, + const typename Policy::level_type out_level, PriorityQueue& pq, node_ofstream& out, [[maybe_unused]] statistics::reduce_t& stats = internal::stats_reduce) @@ -64,7 +64,7 @@ namespace adiar::internal typename Policy::id_type out_id = Policy::max_id; while (pq.can_pull() - || (arcs.can_pull_terminal() && arcs.peek_terminal().source().label() == in_label)) { + || (arcs.can_pull_terminal() && arcs.peek_terminal().source().level() == in_level)) { // TODO (MDD / QMDD): // Use __reduce_get_next node_type::outdegree times to create a node_type::children_type. const arc e_high = __reduce_get_next(pq, arcs); @@ -79,7 +79,7 @@ namespace adiar::internal // Output node adiar_assert(out_id > 0, "Should still have more ids left"); const typename Policy::node_type out_node( - out_label, out_id--, e_low.target(), e_high.target()); + out_level, out_id--, e_low.target(), e_high.target()); out.unsafe_push(out_node); // Forward resulting node to parents @@ -105,7 +105,7 @@ namespace adiar::internal // very much have been wrong). if (out_id != Policy::max_id) { const size_t width = Policy::max_id - out_id; - out.unsafe_push(level_info(out_label, width)); + out.unsafe_push(level_info(out_level, width)); if (width > 1u) { out.unsafe_set_sorted(false); } } @@ -118,13 +118,13 @@ namespace adiar::internal template void __reduce_level__fast(ArcStream& arcs, - const typename Policy::label_type label, + const typename Policy::level_type level, PriorityQueue& pq, node_ofstream& out, statistics::reduce_t& stats = internal::stats_reduce) { return __reduce_level__fast( - arcs, label, label, pq, out, stats); + arcs, level, level, pq, out, stats); } //////////////////////////////////////////////////////////////////////////////////////////////// @@ -165,8 +165,8 @@ namespace adiar::internal using sorter_t = sorter; //////////////////////////////////////////////////////////////////////////////////////////// - static constexpr typename value_type::label_type no_level = - static_cast(-1); + static constexpr typename value_type::level_type no_level = + static_cast(-1); static constexpr size_t data_structures = sorter_t::data_structures; @@ -343,10 +343,10 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////////////////////// /// \brief Level of the deepest source //////////////////////////////////////////////////////////////////////////////////////////// - typename value_type::label_type + typename value_type::level_type deepest_source() { - return _max_source.is_nil() ? no_level : _max_source.label(); + return _max_source.is_nil() ? no_level : _max_source.level(); } }; @@ -400,7 +400,7 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////////////////////// /// \brief Type of a level. //////////////////////////////////////////////////////////////////////////////////////////// - using level_type = typename value_type::pointer_type::label_type; + using level_type = typename value_type::pointer_type::level_type; //////////////////////////////////////////////////////////////////////////////////////////// /// \brief The level of the next inner sweep; @@ -413,7 +413,7 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////////////////////// /// \brief Value to reflect 'out of levels'. //////////////////////////////////////////////////////////////////////////////////////////// - static constexpr level_type no_label = OuterPriorityQueue::no_label; + static constexpr level_type no_level = OuterPriorityQueue::no_level; public: //////////////////////////////////////////////////////////////////////////////////////////// @@ -516,7 +516,7 @@ namespace adiar::internal void push(const reduce_arc& a) { - if (a.source().is_nil() || (a.source().label() < _next_inner && a.target().is_node())) { + if (a.source().is_nil() || (a.source().level() < _next_inner && a.target().is_node())) { #ifdef ADIAR_STATS nested_sweeping::stats.inner_down.requests.preserving += 1u; #endif @@ -544,7 +544,7 @@ namespace adiar::internal void push(const typename OuterRoots::value_type& e) { - adiar_assert(e.data.source.is_nil() || e.data.source.label() < _next_inner); + adiar_assert(e.data.source.is_nil() || e.data.source.level() < _next_inner); // TODO: Ask Policy whether `e` is `modifying`. const bool modifying = e.targets() > 1; @@ -586,7 +586,7 @@ namespace adiar::internal /// given `stop_level`). //////////////////////////////////////////////////////////////////////////////////////////// void - setup_next_level(level_type stop_level = no_label) + setup_next_level(level_type stop_level = no_level) { _outer_pq.setup_next_level(stop_level); adiar_assert(_next_inner <= _outer_pq.current_level(), @@ -611,7 +611,7 @@ namespace adiar::internal class inner_iterator { public: - using level_type = typename Policy::pointer_type::label_type; + using level_type = typename Policy::pointer_type::level_type; public: //////////////////////////////////////////////////////////////////////// @@ -689,7 +689,7 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////////////////////// /// \brief Type of the elements in the priority queue / sorter. //////////////////////////////////////////////////////////////////////////////////////////// - using level_type = typename value_type::pointer_type::label_type; + using level_type = typename value_type::pointer_type::level_type; private: //////////////////////////////////////////////////////////////////////////////////////////// @@ -713,7 +713,7 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////////////////////// /// \brief Value to reflect 'out of levels'. //////////////////////////////////////////////////////////////////////////////////////////// - static constexpr level_type no_label = InnerPriorityQueue::no_label; + static constexpr level_type no_level = InnerPriorityQueue::no_level; public: //////////////////////////////////////////////////////////////////////////////////////////// @@ -735,7 +735,7 @@ namespace adiar::internal } //////////////////////////////////////////////////////////////////////////////////////////// - /// \brief The label of the current level. + /// \brief The current level. //////////////////////////////////////////////////////////////////////////////////////////// level_type current_level() const @@ -753,7 +753,7 @@ namespace adiar::internal } //////////////////////////////////////////////////////////////////////////////////////////// - /// \brief The label of the next (possibly empty) level. + /// \brief The next (possibly empty) level. //////////////////////////////////////////////////////////////////////////////////////////// level_type next_level() /*const*/ @@ -784,7 +784,7 @@ namespace adiar::internal /// given `stop_level`). //////////////////////////////////////////////////////////////////////////////////////////// void - setup_next_level(level_type stop_level = no_label) + setup_next_level(level_type stop_level = no_level) { if (_outer_roots.can_pull()) { stop_level = std::min(stop_level, _outer_roots.top().level()); @@ -1113,7 +1113,7 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////////////////////// /// \brief Type of the elements in the priority queue / sorter. //////////////////////////////////////////////////////////////////////////////////////////// - using level_type = typename value_type::pointer_type::label_type; + using level_type = typename value_type::pointer_type::level_type; private: //////////////////////////////////////////////////////////////////////////////////////////// @@ -1136,7 +1136,7 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////////////////////// /// \brief Value to reflect 'out of levels'. //////////////////////////////////////////////////////////////////////////////////////////// - static constexpr level_type no_label = InnerPriorityQueue::no_label; + static constexpr level_type no_level = InnerPriorityQueue::no_level; public: //////////////////////////////////////////////////////////////////////////////////////////// @@ -1158,7 +1158,7 @@ namespace adiar::internal } //////////////////////////////////////////////////////////////////////////////////////////// - /// \brief The label of the current level. + /// \brief The current level. //////////////////////////////////////////////////////////////////////////////////////////// level_type current_level() const @@ -1176,7 +1176,7 @@ namespace adiar::internal } //////////////////////////////////////////////////////////////////////////////////////////// - /// \brief The label of the next (possibly empty) level. + /// \brief The next (possibly empty) level. //////////////////////////////////////////////////////////////////////////////////////////// level_type next_level() /*const*/ @@ -1217,7 +1217,7 @@ namespace adiar::internal /// given `stop_level`). //////////////////////////////////////////////////////////////////////////////////////////// void - setup_next_level(level_type stop_level = no_label) + setup_next_level(level_type stop_level = no_level) { _inner_pq.setup_next_level(stop_level); } @@ -1472,7 +1472,7 @@ namespace adiar::internal "If there is a level, then there should also be something for it."); const level_info inner_level_info = inner_levels.pull(); - const typename Policy::label_type level = inner_level_info.level(); + const typename Policy::level_type level = inner_level_info.level(); adiar_assert(!decorated_pq.has_current_level() || level == decorated_pq.current_level(), "level and priority queue should be in sync"); @@ -1632,7 +1632,7 @@ namespace adiar::internal const size_t outer_pq_roots_max, const size_t inner_memory) { - using level_type = typename Policy::label_type; + using level_type = typename Policy::level_type; using reduced_t = typename Policy::dd_type; using unreduced_t = typename Policy::__dd_type; using request_t = typename Policy::request_t; @@ -1837,7 +1837,7 @@ namespace adiar::internal // Support creating nodes on this level. while ((outer_arcs.can_pull_terminal() - && outer_arcs.peek_terminal().source().label() == outer_level.level()) + && outer_arcs.peek_terminal().source().level() == outer_level.level()) || outer_pq.can_pull()) { const arc e_high = __reduce_get_next(outer_pq, outer_arcs); @@ -2020,35 +2020,35 @@ namespace adiar::internal // Set up next level in Outer PQ if (!outer_pq.empty() || !outer_roots.empty()) { adiar_assert(!outer_arcs.can_pull_terminal() - || outer_arcs.peek_terminal().source().label() < outer_level.level(), - "All terminal arcs for 'label' should be processed"); + || outer_arcs.peek_terminal().source().level() < outer_level.level(), + "All terminal arcs for 'level' should be processed"); adiar_assert(!outer_arcs.can_pull_internal() - || outer_arcs.peek_internal().target().label() < outer_level.level(), - "All internal arcs for 'label' should be processed"); + || outer_arcs.peek_internal().target().level() < outer_level.level(), + "All internal arcs for 'level' should be processed"); adiar_assert(outer_pq.empty() || !outer_pq.can_pull(), - "All forwarded arcs for 'label' should be processed"); + "All forwarded arcs for 'level' should be processed"); const size_t terminal_stop_level = outer_arcs.can_pull_terminal() - ? outer_arcs.peek_terminal().source().label() - : OuterPriorityQueue::no_label; + ? outer_arcs.peek_terminal().source().level() + : OuterPriorityQueue::no_level; const size_t outer_roots_stop_level = - !outer_roots.empty() ? outer_roots.deepest_source() : OuterPriorityQueue::no_label; + !outer_roots.empty() ? outer_roots.deepest_source() : OuterPriorityQueue::no_level; - adiar_assert(terminal_stop_level != OuterPriorityQueue::no_label - || outer_roots_stop_level != OuterPriorityQueue::no_label + adiar_assert(terminal_stop_level != OuterPriorityQueue::no_level + || outer_roots_stop_level != OuterPriorityQueue::no_level || !outer_pq.empty(), "There must be some (known) level ready to be forwarded to."); - const size_t stop_level = terminal_stop_level == OuterPriorityQueue::no_label + const size_t stop_level = terminal_stop_level == OuterPriorityQueue::no_level ? outer_roots_stop_level - : outer_roots_stop_level == OuterPriorityQueue::no_label + : outer_roots_stop_level == OuterPriorityQueue::no_level ? terminal_stop_level : std::max(terminal_stop_level, outer_roots_stop_level); - adiar_assert(stop_level != OuterPriorityQueue::no_label || !outer_pq.empty(), + adiar_assert(stop_level != OuterPriorityQueue::no_level || !outer_pq.empty(), "There must be some (known) level ready to be forwarded to."); outer_pq.setup_next_level(stop_level); diff --git a/src/adiar/internal/algorithms/optmin.h b/src/adiar/internal/algorithms/optmin.h index ccd5e5f2d..450ba0d9d 100644 --- a/src/adiar/internal/algorithms/optmin.h +++ b/src/adiar/internal/algorithms/optmin.h @@ -100,8 +100,8 @@ namespace adiar::internal while (!optmin_pq.empty()) { optmin_pq.setup_next_level(); - typename Policy::label_type label = optmin_pq.current_level(); - double c = policy.cost_fn(label); + typename Policy::level_type level = optmin_pq.current_level(); + double c = policy.cost_fn(level); while (!optmin_pq.empty_level()) { // Merge requests for the next target, finding the request with the @@ -178,12 +178,12 @@ namespace adiar::internal { arc_ifstream ns(best_parent_graph); arc next = { min_so_far_end, node::pointer_type(true) }; - policy.out(min_so_far_end.label(), min_so_far_end.out_idx()); + policy.out(min_so_far_end.level(), min_so_far_end.out_idx()); while (ns.can_pull_internal()) { arc n = ns.pull_internal(); if (n.target() == essential(next.source())) { next = n; - policy.out(next.source().label(), next.source().out_idx()); + policy.out(next.source().level(), next.source().out_idx()); } } } diff --git a/src/adiar/internal/algorithms/pred.cpp b/src/adiar/internal/algorithms/pred.cpp index 99154d0b9..959ecc9e7 100644 --- a/src/adiar/internal/algorithms/pred.cpp +++ b/src/adiar/internal/algorithms/pred.cpp @@ -51,7 +51,7 @@ namespace adiar::internal {} void - next_level(ptr_uint64::label_type /* level */) + next_level(ptr_uint64::level_type /* level */) { // Ignore input, since only used with the isomorphism_policy below. curr_level_size = in_meta_1.pull().width(); curr_level_processed = 0; @@ -77,7 +77,7 @@ namespace adiar::internal /// \pre To use this operation, the following should be satisfied. /// - The number of nodes are the same /// - The number of levels are the same - /// - The label and size of each level are the same + /// - The level and size of each level are the same ////////////////////////////////////////////////////////////////////////////////////////////////// // TODO (Decision Diagrams with other kinds of pointers): // template @@ -113,7 +113,7 @@ namespace adiar::internal #ifdef ADIAR_STATS stats_equality.slow_check.exit_on_root += 1u; #endif - adiar_assert(v1.label() == v2.label(), "Levels match per the precondition"); + adiar_assert(v1.level() == v2.level(), "Levels match per the precondition"); return v1.low() == v2.low() && v1.high() == v2.high(); } @@ -135,7 +135,7 @@ namespace adiar::internal } // Do they NOT point to a node with the same level? - if (rp[0].label() != rp[1].label()) { + if (rp[0].level() != rp[1].level()) { #ifdef ADIAR_STATS stats_equality.slow_check.exit_on_children += 1u; #endif @@ -236,7 +236,7 @@ namespace adiar::internal return false; } - // Are they trivially not the same, since the labels or the size of each level does not match? + // Are they trivially not the same, since the levels or the size of each level does not match? { // Create new scope to garbage collect the two meta_ifstreams early level_info_ifstream<> in_meta_a(a); level_info_ifstream<> in_meta_b(b); @@ -253,7 +253,7 @@ namespace adiar::internal } // TODO: Use 'fast_isomorphism_check' when there is only one node per level. In this case, we - // can just ignore the id (and only focus on the label and terminal values). + // can just ignore the id (and only focus on the level and terminal values). // Compare their content to discern whether there exists an isomorphism between them. if (a->is_canonical() && b->is_canonical() && a_negated == b_negated) { diff --git a/src/adiar/internal/algorithms/pred.h b/src/adiar/internal/algorithms/pred.h index 75fec6775..897d795bd 100644 --- a/src/adiar/internal/algorithms/pred.h +++ b/src/adiar/internal/algorithms/pred.h @@ -125,7 +125,7 @@ namespace adiar::internal // Forward information across the level if (req.empty_carry() && req.target[0].is_node() && req.target[1].is_node() - && req.target[0].label() == req.target[1].label() + && req.target[0].level() == req.target[1].level() && (v0.uid() != req.target[0] || v1.uid() != req.target[1])) { const typename Policy::children_type children = (req.target[0] == v0.uid() ? v0 : v1).children(); diff --git a/src/adiar/internal/algorithms/prod2b.h b/src/adiar/internal/algorithms/prod2b.h index ee5817d85..84bc66e5d 100644 --- a/src/adiar/internal/algorithms/prod2b.h +++ b/src/adiar/internal/algorithms/prod2b.h @@ -104,7 +104,7 @@ namespace adiar::internal const arc out_arc = { source, policy(target[0], target[1]) }; aw.push_terminal(out_arc); } else { - adiar_assert(source.label() < std::min(target[0], target[1]).label(), + adiar_assert(source.level() < std::min(target[0], target[1]).level(), "should always push recursion for 'later' level"); pq.push({ target, {}, { source } }); @@ -248,15 +248,15 @@ namespace adiar::internal const typename DdPolicy::node_type& v1) { if (r.target[0].is_terminal() || r.target[1].is_terminal() - || r.target[0].label() != r.target[1].label()) { + || r.target[0].level() != r.target[1].level()) { adiar_assert(r.target[0] != r.target[1], "Cannot have mismatching levels and be equal"); - // t.target[0].label() < r.target[1].label() || r.target[1].is_terminal() ? + // t.target[0].level() < r.target[1].level() || r.target[1].is_terminal() ? const typename DdPolicy::children_type pair_0 = r.target[0] < r.target[1] ? v0.children() : DdPolicy::reduction_rule_inv(r.target[0]); - // r.target[1].label() < r.target[0].label() || r.target[0].is_terminal() ? + // r.target[1].level() < r.target[0].level() || r.target[0].is_terminal() ? const typename DdPolicy::children_type pair_1 = r.target[1] < r.target[0] ? v1.children() : DdPolicy::reduction_rule_inv(r.target[1]); @@ -308,11 +308,11 @@ namespace adiar::internal // Set up level prod_pq.setup_next_level(); - typename Policy::label_type out_label = prod_pq.current_level(); + typename Policy::level_type out_level = prod_pq.current_level(); typename Policy::id_type out_id = 0; - policy.setup_next_level(out_label); - in_nodes_ra.setup_next_level(out_label); + policy.setup_next_level(out_level); + in_nodes_ra.setup_next_level(out_level); // Update maximum 1-level cut out_arcs->max_1level_cut = std::max(out_arcs->max_1level_cut, prod_pq.size()); @@ -322,7 +322,7 @@ namespace adiar::internal const prod2b_request<0> req = prod_pq.top(); // Seek request partially in stream - if (req.target[pq_idx].is_node() && req.target[pq_idx].label() == out_label) { + if (req.target[pq_idx].is_node() && req.target[pq_idx].level() == out_level) { while (v_pq.uid() < req.target[pq_idx] && in_nodes_pq.can_pull()) { v_pq = in_nodes_pq.pull(); } @@ -331,11 +331,11 @@ namespace adiar::internal } // Recreate/Obtain children of req.target (possibly of suppressed node) - const typename Policy::children_type children_pq = req.target[pq_idx].level() == out_label + const typename Policy::children_type children_pq = req.target[pq_idx].level() == out_level ? v_pq.children() : Policy::reduction_rule_inv(req.target[pq_idx]); - const typename Policy::children_type children_ra = req.target[ra_idx].level() == out_label + const typename Policy::children_type children_ra = req.target[ra_idx].level() == out_level ? in_nodes_ra.at(req.target[ra_idx]).children() : Policy::reduction_rule_inv(req.target[ra_idx]); @@ -354,7 +354,7 @@ namespace adiar::internal const prod2b_rec_output r = std::get(rec_res); adiar_assert(out_id < Policy::max_id, "Has run out of ids"); - const node::uid_type out_uid(out_label, out_id++); + const node::uid_type out_uid(out_level, out_id++); __prod2b_recurse_out(prod_pq, aw, policy, out_uid.as_ptr(false), r.low); __prod2b_recurse_out(prod_pq, aw, policy, out_uid.as_ptr(true), r.high); @@ -381,7 +381,7 @@ namespace adiar::internal } // Update meta information - if (Policy::no_skip || out_id > 0) { aw.push(level_info(out_label, out_id)); } + if (Policy::no_skip || out_id > 0) { aw.push(level_info(out_level, out_id)); } } // Ensure the edge case, where the in-going edge from nil to the root pair @@ -434,10 +434,10 @@ namespace adiar::internal // Set up next level prod_pq_1.setup_next_level(); - const typename Policy::label_type out_label = prod_pq_1.current_level(); + const typename Policy::level_type out_level = prod_pq_1.current_level(); typename Policy::id_type out_id = 0; - policy.setup_next_level(out_label); + policy.setup_next_level(out_level); // Update max 1-level cut out_arcs->max_1level_cut = std::max(out_arcs->max_1level_cut, prod_pq_1.size()); @@ -457,9 +457,9 @@ namespace adiar::internal req = prod_pq_2.top(); } - adiar_assert(req.target[0].is_terminal() || out_label <= req.target[0].label(), + adiar_assert(req.target[0].is_terminal() || out_level <= req.target[0].level(), "Request should never level-wise be behind current position"); - adiar_assert(req.target[1].is_terminal() || out_label <= req.target[1].label(), + adiar_assert(req.target[1].is_terminal() || out_level <= req.target[1].level(), "Request should never level-wise be behind current position"); // Seek request partially in stream @@ -471,7 +471,7 @@ namespace adiar::internal // Forward information across the level if (req.empty_carry() && req.target[0].is_node() && req.target[1].is_node() - && req.target[0].label() == req.target[1].label() + && req.target[0].level() == req.target[1].level() && (v0.uid() != req.target[0] || v1.uid() != req.target[1])) { const typename Policy::children_type children = (req.target[0] == v0.uid() ? v0 : v1).children(); @@ -503,7 +503,7 @@ namespace adiar::internal const prod2b_rec_output r = std::get(rec_res); adiar_assert(out_id < Policy::max_id, "Has run out of ids"); - const node::uid_type out_uid(out_label, out_id++); + const node::uid_type out_uid(out_level, out_id++); __prod2b_recurse_out(prod_pq_1, aw, policy, out_uid.as_ptr(false), r.low); __prod2b_recurse_out(prod_pq_1, aw, policy, out_uid.as_ptr(true), r.high); @@ -530,7 +530,7 @@ namespace adiar::internal } // Push meta data about this level - if (Policy::no_skip || out_id > 0) { aw.push(level_info(out_label, out_id)); } + if (Policy::no_skip || out_id > 0) { aw.push(level_info(out_level, out_id)); } } // Ensure the edge case, where the in-going edge from nil to the root pair does not dominate the diff --git a/src/adiar/internal/algorithms/prod2u.h b/src/adiar/internal/algorithms/prod2u.h index 6fa98c457..46ba5ba51 100644 --- a/src/adiar/internal/algorithms/prod2u.h +++ b/src/adiar/internal/algorithms/prod2u.h @@ -282,12 +282,12 @@ namespace adiar::internal while (!pq.empty()) { // Set up level pq.setup_next_level(); - const typename Policy::label_type out_label = pq.current_level(); + const typename Policy::level_type out_level = pq.current_level(); typename Policy::id_type out_id = 0; - in_nodes.setup_next_level(out_label); + in_nodes.setup_next_level(out_level); - const bool split = policy.split(out_label); + const bool split = policy.split(out_level); while (!pq.empty_level()) { prod2u_request<0> req = pq.top(); @@ -297,13 +297,13 @@ namespace adiar::internal #endif // Obtain of first to-be seen node - adiar_assert(req.target.first().level() == out_label, + adiar_assert(req.target.first().level() == out_level, "Level of requests always ought to match the one currently processed"); const typename Policy::children_type children_fst = in_nodes.at(req.target.first()).children(); - const typename Policy::children_type children_snd = req.target.second().level() == out_label + const typename Policy::children_type children_snd = req.target.second().level() == out_level ? in_nodes.at(req.target.second()).children() : Policy::reduction_rule_inv(req.target.second()); @@ -339,7 +339,7 @@ namespace adiar::internal // The variable should stay: proceed as in the Product Construction by simulating both // possibilities in parallel. - const node::uid_type out_uid(out_label, out_id++); + const node::uid_type out_uid(out_level, out_id++); prod2u_request<0>::target_t rec0 = __prod2u_resolve_request(children_fst[false], children_snd[false]); @@ -355,7 +355,7 @@ namespace adiar::internal } // Update meta information - if (out_id > 0) { aw.push(level_info(out_label, out_id)); } + if (out_id > 0) { aw.push(level_info(out_level, out_id)); } out_arcs->max_1level_cut = std::max(out_arcs->max_1level_cut, pq.size()); } @@ -408,10 +408,10 @@ namespace adiar::internal // Set up level pq_1.setup_next_level(); - const typename Policy::label_type out_label = pq_1.current_level(); + const typename Policy::level_type out_level = pq_1.current_level(); typename Policy::id_type out_id = 0; - const bool split = policy.split(out_label); + const bool split = policy.split(out_level); while (!pq_1.empty_level() || !pq_2.empty()) { // Merge requests from pq_1 and pq_2 @@ -433,7 +433,7 @@ namespace adiar::internal // Forward information of node t1 across the level if needed if (req.empty_carry() && req.target.second().is_node() - && req.target.first().label() == req.target.second().label()) { + && req.target.first().level() == req.target.second().level()) { do { #ifdef ADIAR_STATS stats_prod2u.pq.pq_2_elems += 1u; @@ -443,7 +443,7 @@ namespace adiar::internal continue; } - adiar_assert(req.target.first().label() == out_label, + adiar_assert(req.target.first().level() == out_level, "Level of requests always ought to match the one currently processed"); #ifdef ADIAR_STATS @@ -455,7 +455,7 @@ namespace adiar::internal const node::children_type children_fst = req.empty_carry() ? v.children() : req.node_carry[0]; - const node::children_type children_snd = req.target.second().level() == out_label + const node::children_type children_snd = req.target.second().level() == out_level ? v.children() : Policy::reduction_rule_inv(req.target.second()); @@ -493,7 +493,7 @@ namespace adiar::internal // The variable should stay: proceed as in the Product Construction by simulating both // possibilities in parallel. - const node::uid_type out_uid(out_label, out_id++); + const node::uid_type out_uid(out_level, out_id++); prod2u_request<0>::target_t rec0 = __prod2u_resolve_request(children_fst[false], children_snd[false]); @@ -509,7 +509,7 @@ namespace adiar::internal } // Update meta information - if (out_id > 0) { aw.push(level_info(out_label, out_id)); } + if (out_id > 0) { aw.push(level_info(out_level, out_id)); } out_arcs->max_1level_cut = std::max(out_arcs->max_1level_cut, pq_1.size()); } @@ -854,7 +854,7 @@ namespace adiar::internal /// to-be split level. Hence, we can provide an always-false predicate that can be /// optimized by the compiler. ////////////////////////////////////////////////////////////////////////////////////////////////// - constexpr bool split(typename Policy::label_type /*level*/) const + constexpr bool split(typename Policy::level_type /*level*/) const { return false; } diff --git a/src/adiar/internal/algorithms/quantify.h b/src/adiar/internal/algorithms/quantify.h index 3f8e9979e..0bcfeb1c3 100644 --- a/src/adiar/internal/algorithms/quantify.h +++ b/src/adiar/internal/algorithms/quantify.h @@ -53,11 +53,11 @@ namespace adiar::internal class single_quantify_policy : public Policy { private: - const typename Policy::label_type _level; + const typename Policy::level_type _level; public: //////////////////////////////////////////////////////////////////////////////////////////////// - single_quantify_policy(typename Policy::label_type level) + single_quantify_policy(typename Policy::level_type level) : _level(level) {} @@ -65,7 +65,7 @@ namespace adiar::internal /// \brief Start product construction at the desired level. //////////////////////////////////////////////////////////////////////////////////////////////// inline bool - split(typename Policy::label_type level) const + split(typename Policy::level_type level) const { return this->_level == level; } @@ -78,7 +78,7 @@ namespace adiar::internal typename Policy::__dd_type quantify(const exec_policy& ep, const typename Policy::dd_type& in, - const typename Policy::label_type label) + const typename Policy::level_type level) { #ifdef ADIAR_STATS stats_quantify.runs += 1u; @@ -86,7 +86,7 @@ namespace adiar::internal // ------------------------------------------------------------------------- // Case: Terminal / Disjunct Levels - if (dd_isterminal(in) || !has_level(in, label)) { + if (dd_isterminal(in) || !has_level(in, level)) { #ifdef ADIAR_STATS stats_quantify.skipped += 1u; #endif @@ -99,7 +99,7 @@ namespace adiar::internal stats_quantify.singleton_sweeps += 1u; #endif - single_quantify_policy policy(label); + single_quantify_policy policy(level); return __prod2u(ep, in, policy); } @@ -121,10 +121,10 @@ namespace adiar::internal {} //////////////////////////////////////////////////////////////////////////////////////////////// - /// \brief What the labels should be mapped to (themselves). + /// \brief What the levels should be mapped to (themselves). //////////////////////////////////////////////////////////////////////////////////////////////// - constexpr inline typename Policy::label_type - map_level(typename Policy::label_type x) const + constexpr inline typename Policy::level_type + map_level(typename Policy::level_type x) const { return x; } @@ -186,7 +186,7 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////////////////////////// /// \brief Predicate for whether a level should be swept on (or not). //////////////////////////////////////////////////////////////////////////////////////////////// - using pred_t = predicate; + using pred_t = predicate; private: //////////////////////////////////////////////////////////////////////////////////////////////// @@ -208,7 +208,7 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////////////////////////// void - setup_level(typename Policy::label_type level) + setup_level(typename Policy::level_type level) { _pred_result = _pred(level) == Policy::quantify_onset; } @@ -256,7 +256,7 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////////////////////////// /// \brief Predicate for whether a level should be swept on (or not). //////////////////////////////////////////////////////////////////////////////////////////////// - using pred_t = predicate; + using pred_t = predicate; private: //////////////////////////////////////////////////////////////////////////////////////////////// @@ -275,7 +275,7 @@ namespace adiar::internal /// \brief Whether the predicate wants to sweep on the given level. //////////////////////////////////////////////////////////////////////////////////////////////// bool - has_sweep(const typename Policy::label_type x) + has_sweep(const typename Policy::level_type x) { return _pred(x) == Policy::quantify_onset; } @@ -311,7 +311,7 @@ namespace adiar::internal struct var_data { /// \brief The to-be quantified variable. - typename Policy::label_type level; + typename Policy::level_type level; /// \brief Number of nodes below this level (not inclusive) size_t nodes_below; @@ -347,7 +347,7 @@ namespace adiar::internal template inline quantify__pred_profile __quantify__pred_profile(const typename Policy::dd_type& dd, - const predicate& pred) + const predicate& pred) { // TODO: tighten 'shallow' to only be above shallowest widest level (inclusive) // TODO: tighten 'deep' to not be 'shallow' @@ -369,7 +369,7 @@ namespace adiar::internal nodes_below -= li.width(); - if (pred(li.label()) == Policy::quantify_onset) { + if (pred(li.level()) == Policy::quantify_onset) { res.quant_all_vars += 1u; res.quant_all_size += li.width(); res.quant_deep_vars += nodes_below < shallow_threshold; @@ -404,14 +404,14 @@ namespace adiar::internal // - initial '__quantify__get_deepest' should not terminate early but // determine whether any variable may "survive". template - inline typename Policy::label_type + inline typename Policy::level_type __quantify__get_deepest(const typename Policy::dd_type& dd, - const predicate& pred) + const predicate& pred) { level_info_ifstream lis(dd); while (lis.can_pull()) { - const typename Policy::label_type l = lis.pull().label(); + const typename Policy::level_type l = lis.pull().level(); if (pred(l) == Policy::quantify_onset) { return l; } } return Policy::max_label + 1; @@ -424,7 +424,7 @@ namespace adiar::internal typename Policy::__dd_type quantify(const exec_policy& ep, typename Policy::dd_type dd, - const predicate& pred) + const predicate& pred) { #ifdef ADIAR_STATS stats_quantify.runs += 1u; @@ -453,17 +453,17 @@ namespace adiar::internal case exec_policy::quantify::Singleton: { // ------------------------------------------------------------------------------------------- // Case: Repeated single variable quantification - typename Policy::label_type label = pred_profile.deepest_var.level; + typename Policy::level_type level = pred_profile.deepest_var.level; - while (label <= Policy::max_label) { - dd = quantify(ep, dd, label); + while (level <= Policy::max_label) { + dd = quantify(ep, dd, level); #ifdef ADIAR_STATS // HACK: Undo the += 1 in the nested call stats_quantify.runs -= 1u; #endif if (dd_isterminal(dd)) { return dd; } - label = __quantify__get_deepest(dd, pred); + level = __quantify__get_deepest(dd, pred); } return dd; } @@ -496,7 +496,7 @@ namespace adiar::internal typename Policy::__dd_type quantify(const exec_policy& ep, typename Policy::__dd_type&& __dd, - const predicate& pred) + const predicate& pred) { switch (ep.template get()) { case exec_policy::quantify::Singleton: { @@ -544,7 +544,7 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////////////////////////// /// \brief Generator of the levels to sweep on (or not to sweep on) in descending order. //////////////////////////////////////////////////////////////////////////////////////////////// - using generator_t = generator; + using generator_t = generator; private: //////////////////////////////////////////////////////////////////////////////////////////////// @@ -555,7 +555,7 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////////////////////////// /// \brief Buffer for to hold onto the generated next level. //////////////////////////////////////////////////////////////////////////////////////////////// - optional _next_level; + optional _next_level; public: //////////////////////////////////////////////////////////////////////////////////////////////// @@ -570,7 +570,7 @@ namespace adiar::internal /// \brief Whether the generator wants to do a Nested Sweep on the given level. //////////////////////////////////////////////////////////////////////////////////////////////// bool - has_sweep(const typename Policy::label_type x) + has_sweep(const typename Policy::level_type x) { return x == next_level(x) ? Policy::quantify_onset : !Policy::quantify_onset; } @@ -588,8 +588,8 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////////////////////////// /// \brief The next level to start a Nested Sweep. //////////////////////////////////////////////////////////////////////////////////////////////// - typename Policy::label_type - next_level(const typename Policy::label_type l) + typename Policy::level_type + next_level(const typename Policy::level_type l) { while (_next_level.has_value() && l < _next_level.value()) { _next_level = _lvls(); } return _next_level.value_or(Policy::max_label + 1); @@ -606,15 +606,15 @@ namespace adiar::internal // clean up // - Make return type 'optional' rather than larger than 'max_label' template - inline typename Policy::label_type + inline typename Policy::level_type __quantify__get_deepest(const typename Policy::dd_type& dd, - const typename Policy::label_type bot_level, - const optional top_level) + const typename Policy::level_type bot_level, + const optional top_level) { level_info_ifstream lis(dd); while (lis.can_pull()) { - const typename Policy::label_type l = lis.pull().label(); + const typename Policy::level_type l = lis.pull().level(); if ((!top_level || top_level.value() < l) && l < bot_level) { return l; } } return Policy::max_label + 1; @@ -635,7 +635,7 @@ namespace adiar::internal // ------------------------------------------------------------------------------------------- // Case: Repeated single variable quantification // TODO: correctly handle Policy::quantify_onset - optional on_level = lvls(); + optional on_level = lvls(); if (Policy::quantify_onset) { if (!on_level) { @@ -647,7 +647,7 @@ namespace adiar::internal // Quantify all but the last 'on_level'. Hence, look one ahead with // 'next_on_level' to see whether it is the last one. - optional next_on_level = lvls(); + optional next_on_level = lvls(); while (next_on_level) { dd = quantify(ep, dd, on_level.value()); #ifdef ADIAR_STATS @@ -669,9 +669,9 @@ namespace adiar::internal // TODO: only designed for 'OR' at this point in time if (!on_level) { return typename Policy::dd_type(dd->number_of_terminals[true] > 0); } - // Quantify everything below 'label' + // Quantify everything below 'level' for (;;) { - const typename Policy::label_type off_level = + const typename Policy::level_type off_level = __quantify__get_deepest(dd, Policy::max_label, on_level.value()); if (Policy::max_label < off_level) { break; } @@ -685,12 +685,12 @@ namespace adiar::internal } // Quantify everything strictly in between 'bot_level' and 'top_level' - optional bot_level = on_level; - optional top_level = lvls(); + optional bot_level = on_level; + optional top_level = lvls(); while (bot_level) { for (;;) { - const typename Policy::label_type off_level = + const typename Policy::level_type off_level = __quantify__get_deepest(dd, bot_level.value(), top_level); if (Policy::max_label < off_level) { break; } @@ -718,7 +718,7 @@ namespace adiar::internal // Obtain the bottom-most onset level that exists in the diagram. // TODO: Move into helper function. - optional transposition_level = lvls(); + optional transposition_level = lvls(); if (!transposition_level) { #ifdef ADIAR_STATS stats_quantify.skipped += 1u; @@ -728,7 +728,7 @@ namespace adiar::internal { level_info_ifstream in_meta(dd); - typename Policy::label_type dd_level = in_meta.pull().level(); + typename Policy::level_type dd_level = in_meta.pull().level(); for (;;) { // Go forward in the diagram's levels, until we are at or above diff --git a/src/adiar/internal/algorithms/reduce.h b/src/adiar/internal/algorithms/reduce.h index 4d9a4e795..6f0a62dcc 100644 --- a/src/adiar/internal/algorithms/reduce.h +++ b/src/adiar/internal/algorithms/reduce.h @@ -55,10 +55,10 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////////////////////////// /// \brief The level at which this nodes source belongs to. //////////////////////////////////////////////////////////////////////////////////////////////// - arc::label_type + arc::level_type level() const { - return source().label(); + return source().level(); } }; @@ -271,7 +271,7 @@ namespace adiar::internal const bool terminal_val); ////////////////////////////////////////////////////////////////////////////////////////////////// - /// \brief Reduce a single level (while also mapping it to a new label). + /// \brief Reduce a single level (while also mapping it to a new level). /// /// \returns width of output level ////////////////////////////////////////////////////////////////////////////////////////////////// @@ -281,8 +281,8 @@ namespace adiar::internal typename arc_ifstream_t> size_t __reduce_level(arc_ifstream_t& arcs, - const typename Policy::label_type in_label, - const typename Policy::label_type out_label, + const typename Policy::level_type in_level, + const typename Policy::level_type out_level, pq_t& reduce_pq, node_ofstream& out, const size_t sorters_memory, @@ -297,7 +297,7 @@ namespace adiar::internal sorter_t red2_mapping(sorters_memory, unreduced_width, 2); // Pull out all nodes from reduce_pq and terminal_arcs for this level - while ((arcs.can_pull_terminal() && arcs.peek_terminal().source().label() == in_label) + while ((arcs.can_pull_terminal() && arcs.peek_terminal().source().level() == in_level) || reduce_pq.can_pull()) { // TODO (MDD): // TODO (QMDD): @@ -307,7 +307,7 @@ namespace adiar::internal const arc e_low = __reduce_get_next(reduce_pq, arcs); const node n = node_of(e_low, e_high); - adiar_assert(n.label() == in_label, "Label is for desired level"); + adiar_assert(n.level() == in_level, "The extracted node is for this level"); // Apply Reduction rule 1 const typename Policy::pointer_type reduction_rule_ret = Policy::reduction_rule(n); @@ -345,7 +345,7 @@ namespace adiar::internal if (out_node.low() != unflag(next_node.low()) || out_node.high() != unflag(next_node.high())) { adiar_assert(0 <= out_id, "Should still have more ids left"); - out_node = node(out_label, out_id--, unflag(next_node.low()), unflag(next_node.high())); + out_node = node(out_level, out_id--, unflag(next_node.low()), unflag(next_node.high())); out.unsafe_push(out_node); __reduce_cut_add(next_node.low().is_flagged() ? tainted_1level_cut : local_1level_cut, @@ -363,7 +363,7 @@ namespace adiar::internal // Add number of nodes to level information, if any nodes were pushed to the output. const size_t reduced_width = Policy::max_id - out_id; - if (reduced_width > 0) { out.unsafe_push(level_info(out_label, reduced_width)); } + if (reduced_width > 0) { out.unsafe_push(level_info(out_level, reduced_width)); } // Sort mappings for Reduction rule 2 back in order of arcs.internal red2_mapping.sort(); @@ -433,7 +433,7 @@ namespace adiar::internal } ////////////////////////////////////////////////////////////////////////////////////////////////// - /// \brief Reduce a single level (without mapping it to a new label). + /// \brief Reduce a single level (without mapping it to a new level). /// /// \returns width of output level ////////////////////////////////////////////////////////////////////////////////////////////////// @@ -441,10 +441,10 @@ namespace adiar::internal template typename sorter_t, typename pq_t, typename arc_ifstream_t> - //[[deprecated("Use '__reduce_label' with a separate 'in_label' and 'out_label'")]] + //[[deprecated("Use '__reduce_level' with a separate 'in_level' and 'out_level'")]] size_t __reduce_level(arc_ifstream_t& arcs, - const typename Policy::label_type label, + const typename Policy::level_type level, pq_t& reduce_pq, node_ofstream& out, const size_t sorters_memory, @@ -452,7 +452,7 @@ namespace adiar::internal statistics::reduce_t& stats = stats_reduce) { return __reduce_level( - arcs, label, label, reduce_pq, out, sorters_memory, unreduced_width, stats); + arcs, level, level, reduce_pq, out, sorters_memory, unreduced_width, stats); } ////////////////////////////////////////////////////////////////////////////////////////////////// @@ -469,15 +469,15 @@ namespace adiar::internal if (!reduce_pq.empty()) { adiar_assert(!arcs.can_pull_terminal() || !reduce_pq.has_current_level() - || arcs.peek_terminal().source().label() < reduce_pq.current_level(), + || arcs.peek_terminal().source().level() < reduce_pq.current_level(), "All terminal arcs for 'current_level' should be processed"); adiar_assert(!arcs.can_pull_internal() || !reduce_pq.has_current_level() - || arcs.peek_internal().target().label() < reduce_pq.current_level(), + || arcs.peek_internal().target().level() < reduce_pq.current_level(), "All internal arcs for 'current_level' should be processed"); if (arcs.can_pull_terminal()) { - reduce_pq.setup_next_level(arcs.peek_terminal().source().label()); + reduce_pq.setup_next_level(arcs.peek_terminal().source().level()); } else { reduce_pq.setup_next_level(); } @@ -487,11 +487,11 @@ namespace adiar::internal // stored in another priority queue. adiar_assert(!arcs.can_pull_terminal() || !reduce_pq.has_current_level() - || arcs.peek_terminal().source().label() < reduce_pq.current_level(), + || arcs.peek_terminal().source().level() < reduce_pq.current_level(), "All terminal arcs for 'current_level' should be processed"); adiar_assert(!arcs.can_pull_internal() || !reduce_pq.has_current_level() - || arcs.peek_internal().target().label() < reduce_pq.current_level(), + || arcs.peek_internal().target().level() < reduce_pq.current_level(), "All internal arcs for 'current_level' should be processed"); } else if (!out.has_pushed()) { @@ -555,7 +555,7 @@ namespace adiar::internal out.unsafe_set_number_of_terminals(!terminal_val, terminal_val); __reduce_cut_add(out_file->max_1level_cut, 0u, !terminal_val, terminal_val); } else { - const typename Policy::label_type out_level = policy.map_level(e_low.source().level()); + const typename Policy::level_type out_level = policy.map_level(e_low.source().level()); out.unsafe_push(node(out_level, Policy::max_id, e_low.target(), e_high.target())); @@ -590,8 +590,8 @@ namespace adiar::internal adiar_assert(arcs.can_pull_terminal() || !reduce_pq.empty(), "If there is a level, then there should also be something for it."); const level_info current_level_info = levels.pull(); - const typename Policy::label_type in_level = current_level_info.level(); - const typename Policy::label_type out_level = policy.map_level(in_level); + const typename Policy::level_type in_level = current_level_info.level(); + const typename Policy::level_type out_level = policy.map_level(in_level); adiar_assert(!reduce_pq.has_current_level() || in_level == reduce_pq.current_level(), "level and priority queue should be in sync"); @@ -690,8 +690,8 @@ namespace adiar::internal class default_reduce_policy : public DdPolicy { public: - constexpr inline typename DdPolicy::label_type - map_level(typename DdPolicy::label_type x) const + constexpr inline typename DdPolicy::level_type + map_level(typename DdPolicy::level_type x) const { return x; } diff --git a/src/adiar/internal/algorithms/replace.h b/src/adiar/internal/algorithms/replace.h index 283ffa347..c969096f8 100644 --- a/src/adiar/internal/algorithms/replace.h +++ b/src/adiar/internal/algorithms/replace.h @@ -29,7 +29,7 @@ namespace adiar::internal /// \brief A total mapping function. ////////////////////////////////////////////////////////////////////////////////////////////////// template - using replace_func = function; + using replace_func = function; ////////////////////////////////////////////////////////////////////////////////////////////////// // Inference of the most precise replacement-type. @@ -41,12 +41,12 @@ namespace adiar::internal replace_type __replace__infer_type(LevelInfoStream& ls, const ReplaceFunction& m) { - using label_type = typename Policy::label_type; - using signed_label_type = typename Policy::signed_label_type; + using level_type = typename Policy::level_type; + using signed_level_type = typename Policy::signed_level_type; using result_type = typename ReplaceFunction::result_type; - constexpr bool is_total_map = is_same; - constexpr bool is_partial_map = is_same>; + constexpr bool is_total_map = is_same; + constexpr bool is_partial_map = is_same>; static_assert(is_total_map || is_partial_map); @@ -54,20 +54,20 @@ namespace adiar::internal bool shift = true; bool monotone = true; - label_type prev_before = Policy::max_label + 1; - label_type prev_after = Policy::max_label + 1; + level_type prev_before = Policy::max_label + 1; + level_type prev_after = Policy::max_label + 1; - signed_label_type prev_diff = 0; + signed_level_type prev_diff = 0; while (ls.can_pull()) { - const label_type next_before = ls.pull().level(); + const level_type next_before = ls.pull().level(); const result_type next_after_opt = m(next_before); if constexpr (is_partial_map) { if (!next_after_opt.has_value()) { continue; } } - label_type next_after; + level_type next_after; if constexpr (is_partial_map) { if (!next_after_opt.has_value()) { continue; } next_after = *next_after_opt; @@ -76,8 +76,8 @@ namespace adiar::internal } if (shift) { - const signed_label_type next_diff = - static_cast(next_before) - static_cast(next_after); + const signed_level_type next_diff = + static_cast(next_before) - static_cast(next_after); shift &= Policy::max_label < prev_before || prev_diff == next_diff; prev_diff = next_diff; @@ -142,8 +142,8 @@ namespace adiar::internal { adiar_assert(!dd->is_terminal()); - const typename Policy::signed_label_type topvar = dd_topvar(dd); - const typename Policy::signed_label_type shifted_topvar = m(topvar); + const typename Policy::signed_level_type topvar = dd_topvar(dd); + const typename Policy::signed_level_type shifted_topvar = m(topvar); return typename Policy::dd_type( dd.file_ptr(), dd.is_negated(), dd.shift() + (shifted_topvar - topvar)); @@ -221,8 +221,8 @@ namespace adiar::internal : _m(m) {} - constexpr inline typename Policy::label_type - map_level(typename Policy::label_type x) const + constexpr inline typename Policy::level_type + map_level(typename Policy::level_type x) const { return this->_m(x); } diff --git a/src/adiar/internal/algorithms/select.h b/src/adiar/internal/algorithms/select.h index 16aa5c382..4f4fcecc1 100644 --- a/src/adiar/internal/algorithms/select.h +++ b/src/adiar/internal/algorithms/select.h @@ -109,7 +109,7 @@ namespace adiar::internal // Set up next level pq.setup_next_level(); - const typename Policy::label_type level = pq.current_level(); + const typename Policy::level_type level = pq.current_level(); typename Policy::id_type level_size = 0; policy.setup_level(level); @@ -123,7 +123,7 @@ namespace adiar::internal const node n = ns.seek(pq.top().target[0]); adiar_assert(pq.top().target == n.uid()); - adiar_assert(n.uid().label() == level); + adiar_assert(n.uid().level() == level); const select_rec rec = policy.process(n); diff --git a/src/adiar/internal/data_structures/level_merger.h b/src/adiar/internal/data_structures/level_merger.h index d39127844..31ada3518 100644 --- a/src/adiar/internal/data_structures/level_merger.h +++ b/src/adiar/internal/data_structures/level_merger.h @@ -32,7 +32,7 @@ namespace adiar::internal class level_merger { public: - using value_type = dd::label_type; + using value_type = dd::level_type; using arg_type = std::variant>; private: diff --git a/src/adiar/internal/data_structures/levelized_priority_queue.h b/src/adiar/internal/data_structures/levelized_priority_queue.h index 27c5842b5..5ca7352c4 100644 --- a/src/adiar/internal/data_structures/levelized_priority_queue.h +++ b/src/adiar/internal/data_structures/levelized_priority_queue.h @@ -30,8 +30,8 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////////////////////////// template inline bool - level_cmp_lt(const ptr_uint64::label_type l1, - const ptr_uint64::label_type l2, + level_cmp_lt(const ptr_uint64::level_type l1, + const ptr_uint64::level_type l2, const LevelComp& level_comp) { return level_comp(l1, l2); @@ -42,8 +42,8 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////////////////////////// template inline bool - level_cmp_le(const ptr_uint64::label_type l1, - const ptr_uint64::label_type l2, + level_cmp_le(const ptr_uint64::level_type l1, + const ptr_uint64::level_type l2, const LevelComp& level_comp) { return level_comp(l1, l2) || l1 == l2; @@ -118,9 +118,6 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////////////////////////// static constexpr memory_mode mem_mode = MemoryMode; - //////////////////////////////////////////////////////////////////////////////////////////////// - // using level_type = TODO?; - public: //////////////////////////////////////////////////////////////////////////////////////////////// /// \brief Type of the sorter for each bucket. @@ -143,27 +140,31 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////////////////////////// static constexpr size_t buckets = LookAhead + 1; - //////////////////////////////////////////////////////////////////////////////////////////////// - /// \brief Index for no bucket. - //////////////////////////////////////////////////////////////////////////////////////////////// - static constexpr ptr_uint64::label_type out_of_buckets_idx = - static_cast(-1); - //////////////////////////////////////////////////////////////////////////////////////////////// /// \brief Total number of data structures in Levelized Priority Queue. //////////////////////////////////////////////////////////////////////////////////////////////// static constexpr size_t data_structures = buckets * sorter_t::data_structures + priority_queue_t::data_structures; + //////////////////////////////////////////////////////////////////////////////////////////////// + /// \brief The type of a levels. + //////////////////////////////////////////////////////////////////////////////////////////////// + using level_type = ptr_uint64::level_type; + + //////////////////////////////////////////////////////////////////////////////////////////////// + /// \brief Index for no bucket. + //////////////////////////////////////////////////////////////////////////////////////////////// + static constexpr level_type out_of_buckets_idx = static_cast(-1); + //////////////////////////////////////////////////////////////////////////////////////////////// /// \brief Value to reflect 'out of levels'. //////////////////////////////////////////////////////////////////////////////////////////////// - static constexpr ptr_uint64::label_type no_label = ptr_uint64::max_label + 1; + static constexpr level_type no_level = ptr_uint64::nil_level; private: static_assert(0 < LookAhead, "LookAhead must at least be of one level"); - static_assert(0 < ptr_uint64::max_label, "A larger LookAhead than max_label is wasteful"); + static_assert(LookAhead < ptr_uint64::max_label, "A larger LookAhead than max_label is wasteful"); static_assert(buckets < out_of_buckets_idx, "LookAhead must not be so large to also include '-1'"); @@ -173,7 +174,7 @@ namespace adiar::internal static_assert( ptr_uint64::max_label + 1 > ptr_uint64::max_label, - "'ptr_uint64::label_type' should leave a window of at least one above 'max_label'"); + "'level_type' should leave a window of at least one above 'max_label'"); private: static size_t @@ -239,7 +240,7 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////////////////////////// /// \brief Instantiation of the comparator between levels. //////////////////////////////////////////////////////////////////////////////////////////////// - ptr_uint64::label_type _current_level = no_label; + level_type _current_level = no_level; //////////////////////////////////////////////////////////////////////////////////////////////// /// \brief Instantiation of the comparator between levels. @@ -262,7 +263,7 @@ namespace adiar::internal const size_t _memory_given; //////////////////////////////////////////////////////////////////////////////////////////////// - /// \brief Memory used by the label merger. + /// \brief Memory used by the level merger. //////////////////////////////////////////////////////////////////////////////////////////////// const size_t _memory_occupied_by_merger = level_merger_t::memory_usage(); @@ -284,7 +285,7 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////////////////////////// /// \brief Level of each bucket. //////////////////////////////////////////////////////////////////////////////////////////////// - ptr_uint64::label_type _buckets_level[buckets]; + level_type _buckets_level[buckets]; //////////////////////////////////////////////////////////////////////////////////////////////// /// \brief Sorter for each bucket. @@ -294,12 +295,12 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////////////////////////// /// \brief Index of the currently read-from bucket (if any). //////////////////////////////////////////////////////////////////////////////////////////////// - ptr_uint64::label_type _front_bucket_idx = out_of_buckets_idx; + level_type _front_bucket_idx = out_of_buckets_idx; //////////////////////////////////////////////////////////////////////////////////////////////// /// \brief Index of the last available bucket (if any). //////////////////////////////////////////////////////////////////////////////////////////////// - ptr_uint64::label_type _back_bucket_idx = out_of_buckets_idx; + level_type _back_bucket_idx = out_of_buckets_idx; //////////////////////////////////////////////////////////////////////////////////////////////// /// \brief Next element to take out of the bucket (if any) @@ -413,7 +414,7 @@ namespace adiar::internal // Set up buckets until no levels are left or all buckets have been // instantiated. Notice, that _back_bucket_idx was initialised to -1. while (_back_bucket_idx + 1 < buckets && _level_merger.can_pull()) { - const ptr_uint64::label_type level = _level_merger.pull(); + const level_type level = _level_merger.pull(); adiar_assert(_front_bucket_idx == out_of_buckets_idx, "Front bucket not moved"); @@ -451,15 +452,15 @@ namespace adiar::internal bool has_current_level() const { - return _current_level != no_label; + return _current_level != no_level; } //////////////////////////////////////////////////////////////////////////////////////////////// - /// \brief The label of the current level. + /// \brief The current level. /// /// \pre `has_current_level() == true` //////////////////////////////////////////////////////////////////////////////////////////////// - ptr_uint64::label_type + level_type current_level() const { adiar_assert(has_current_level(), "Needs to have a 'current' level to read the level from"); @@ -477,11 +478,11 @@ namespace adiar::internal } //////////////////////////////////////////////////////////////////////////////////////////////// - /// \brief The label of the next (possibly empty) level. + /// \brief The next (possibly empty) level. /// /// \pre `has_next_level() == true` //////////////////////////////////////////////////////////////////////////////////////////////// - ptr_uint64::label_type + level_type next_level() const { return next_bucket_level(); @@ -504,7 +505,7 @@ namespace adiar::internal { adiar_assert(can_push(), "Should only push when there is a yet unvisited level."); - const ptr_uint64::label_type level = e.level(); + const level_type level = e.level(); adiar_assert(level_cmp_le(next_bucket_level(), level, _level_comparator), "Can only push element to next bucket or later."); @@ -518,9 +519,9 @@ namespace adiar::internal _actual_max_size = std::max(_actual_max_size, _size); #endif - ptr_uint64::label_type bucket_offset = 1u; + level_type bucket_offset = 1u; do { - const ptr_uint64::label_type bucket_idx = (_front_bucket_idx + bucket_offset++) % buckets; + const level_type bucket_idx = (_front_bucket_idx + bucket_offset++) % buckets; if (_buckets_level[bucket_idx] == level) { _buckets_sorter[bucket_idx]->push(e); @@ -548,26 +549,26 @@ namespace adiar::internal /// queue. //////////////////////////////////////////////////////////////////////////////////////////////// void - setup_next_level(ptr_uint64::label_type stop_level = no_label) + setup_next_level(level_type stop_level = no_level) { - adiar_assert(stop_level <= ptr_uint64::max_label || stop_level == no_label, + adiar_assert(stop_level <= ptr_uint64::max_label || stop_level == no_level, "The stop level should be a legal value (or not given)"); adiar_assert(!has_current_level() || empty_level(), "Level is empty before moving on to the next"); - adiar_assert(stop_level != no_label || !empty(), + adiar_assert(stop_level != no_level || !empty(), "Either a stop level is given or we have some non-empty level to forward to"); - const ptr_uint64::label_type overflow_level = + const level_type overflow_level = !_overflow_queue.empty() ? _overflow_queue.top().level() : stop_level; - stop_level = stop_level == no_label + stop_level = stop_level == no_level || level_cmp_lt(overflow_level, stop_level, _level_comparator) ? overflow_level : stop_level; - const bool has_stop_level = stop_level != no_label; + const bool has_stop_level = stop_level != no_level; adiar_assert(has_next_level(), "There should be a next level to go to"); @@ -780,13 +781,13 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////////////////////////// /// \brief Label of the next bucket. //////////////////////////////////////////////////////////////////////////////////////////////// - ptr_uint64::label_type + level_type next_bucket_level() const { adiar_assert(has_next_bucket(), "Cannot obtain level of non-existing next bucket"); - const ptr_uint64::label_type next_idx = (_front_bucket_idx + 1) % buckets; - const ptr_uint64::label_type next_level = _buckets_level[next_idx]; + const level_type next_idx = (_front_bucket_idx + 1) % buckets; + const level_type next_level = _buckets_level[next_idx]; return next_level; } @@ -803,7 +804,7 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////////////////////////// /// \brief Level of the front bucket. //////////////////////////////////////////////////////////////////////////////////////////////// - ptr_uint64::label_type + level_type front_bucket_level() const { return _buckets_level[_front_bucket_idx]; @@ -812,7 +813,7 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////////////////////////// /// \brief Level of the back bucket. //////////////////////////////////////////////////////////////////////////////////////////////// - ptr_uint64::label_type + level_type back_bucket_level() const { return _buckets_level[_back_bucket_idx]; @@ -830,7 +831,7 @@ namespace adiar::internal /// \see levelized_priority_queue::setup_next_level //////////////////////////////////////////////////////////////////////////////////////////////// inline void - forward_to_nonempty_bucket(const ptr_uint64::label_type stop_level, const bool has_stop_level) + forward_to_nonempty_bucket(const level_type stop_level, const bool has_stop_level) { do { adiar_assert(has_next_bucket(), "At least one more bucket can be forwarded to"); @@ -848,7 +849,7 @@ namespace adiar::internal // Replace the current read-only bucket, if there is one if (_level_merger.can_pull() && has_front_bucket()) { - const ptr_uint64::label_type next_level = _level_merger.pull(); + const level_type next_level = _level_merger.pull(); _buckets_level[_front_bucket_idx] = next_level; sorter_t::reset_unique( @@ -900,16 +901,16 @@ namespace adiar::internal /// \see levelized_priority_queue::setup_next_level //////////////////////////////////////////////////////////////////////////////////////////////// inline void - relabel_buckets(const ptr_uint64::label_type stop_level) + relabel_buckets(const level_type stop_level) { - adiar_assert(stop_level != no_label, "Relabelling of buckets require a valid 'stop_level'"); + adiar_assert(stop_level != no_level, "Relabelling of buckets require a valid 'stop_level'"); // Backup of start and end of circular array const size_t old_front_bucket_idx = _front_bucket_idx; const size_t old_back_bucket_idx = _back_bucket_idx; // Create a list of the new levels - ptr_uint64::label_type new_levels[buckets]; + level_type new_levels[buckets]; _back_bucket_idx = out_of_buckets_idx; // Copy over still relevant levels from current buckets @@ -1016,10 +1017,15 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////////////////////////// static constexpr size_t data_structures = priority_queue_t::data_structures; + //////////////////////////////////////////////////////////////////////////////////////////////// + /// \brief The type of a levels. + //////////////////////////////////////////////////////////////////////////////////////////////// + using level_type = ptr_uint64::level_type; + //////////////////////////////////////////////////////////////////////////////////////////////// /// \brief Value to reflect 'out of levels'. //////////////////////////////////////////////////////////////////////////////////////////////// - static constexpr ptr_uint64::label_type no_label = ptr_uint64::max_label + 1; + static constexpr level_type no_level = ptr_uint64::max_label + 1; public: static size_t @@ -1040,7 +1046,7 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////////////////////////// /// \brief Instantiation of the comparator between levels. //////////////////////////////////////////////////////////////////////////////////////////////// - ptr_uint64::label_type _current_level = no_label; + level_type _current_level = no_level; //////////////////////////////////////////////////////////////////////////////////////////////// /// \brief Instantiation of the comparator between levels. @@ -1124,15 +1130,15 @@ namespace adiar::internal bool has_current_level() const { - return _current_level != no_label; + return _current_level != no_level; } //////////////////////////////////////////////////////////////////////////////////////////////// - /// \brief The label of the current level. + /// \brief The current level. /// /// \pre `has_current_level() == true` //////////////////////////////////////////////////////////////////////////////////////////////// - ptr_uint64::label_type + level_type current_level() const { adiar_assert(has_current_level(), "Needs to have a 'current' level to read the level from"); @@ -1147,18 +1153,18 @@ namespace adiar::internal has_next_level() /*const*/ { if (_priority_queue.empty()) { return false; } - ptr_uint64::label_type next_label_from_queue = _priority_queue.top().level(); + level_type next_level_from_queue = _priority_queue.top().level(); return (has_current_level() - && level_cmp_lt(_current_level, next_label_from_queue, _level_comparator)) + && level_cmp_lt(_current_level, next_level_from_queue, _level_comparator)) || (!has_current_level() && !_priority_queue.empty()); } //////////////////////////////////////////////////////////////////////////////////////////////// - /// \brief The label of the next (possibly empty) level. + /// \brief The next (possibly empty) level. /// /// \pre `has_next_level() == true` //////////////////////////////////////////////////////////////////////////////////////////////// - ptr_uint64::label_type + level_type next_level() /*const*/ { return _priority_queue.top().level(); @@ -1196,15 +1202,15 @@ namespace adiar::internal /// queue. //////////////////////////////////////////////////////////////////////////////////////////////// void - setup_next_level(ptr_uint64::label_type stop_level = no_label) + setup_next_level(level_type stop_level = no_level) { - adiar_assert(stop_level <= ptr_uint64::max_label || stop_level == no_label, + adiar_assert(stop_level <= ptr_uint64::max_label || stop_level == no_level, "The stop level should be a legal value (or not given)"); adiar_assert(!has_current_level() || empty_level(), "Level is empty before moving on to the next"); - const bool has_stop_level = stop_level != no_label; + const bool has_stop_level = stop_level != no_level; adiar_assert(has_stop_level || !empty(), "Either a stop level is given or we have some non-empty level to forward to"); @@ -1220,7 +1226,7 @@ namespace adiar::internal // Edge Case: ------------------------------------------------------------------------------ : // The stop level is before the next level of the queue adiar_assert(has_next_level(), "There should be a next level to go to"); - ptr_uint64::label_type next_level_from_queue = next_level(); + level_type next_level_from_queue = next_level(); if (has_stop_level && level_cmp_le(stop_level, next_level_from_queue, _level_comparator)) { _current_level = stop_level; @@ -1360,7 +1366,7 @@ namespace adiar::internal LookAhead, mem_mode, LevelInputs, - std::less, + std::less, LevelSkip>; ////////////////////////////////////////////////////////////////////////////////////////////////// @@ -1377,7 +1383,7 @@ namespace adiar::internal LookAhead, mem_mode, LevelInputs, - std::greater, + std::greater, LevelSkip>; } diff --git a/src/adiar/internal/data_types/arc.h b/src/adiar/internal/data_types/arc.h index 914606a1f..a9a2dd53e 100644 --- a/src/adiar/internal/data_types/arc.h +++ b/src/adiar/internal/data_types/arc.h @@ -42,14 +42,14 @@ namespace adiar::internal using uid_type = __uid; //////////////////////////////////////////////////////////////////////////////////////////////// - /// \brief Type of variable label. + /// \brief Type of variable level. //////////////////////////////////////////////////////////////////////////////////////////////// - using label_type = pointer_type::label_type; + using level_type = pointer_type::level_type; //////////////////////////////////////////////////////////////////////////////////////////////// - /// \brief Type able to hold the label of a variable. + /// \brief Type able to hold the level of a variable. //////////////////////////////////////////////////////////////////////////////////////////////// - using signed_label_type = pointer_type::signed_label_type; + using signed_level_type = pointer_type::signed_level_type; //////////////////////////////////////////////////////////////////////////////////////////////// /// \brief Type of terminal values. diff --git a/src/adiar/internal/data_types/convert.h b/src/adiar/internal/data_types/convert.h index db601385a..034e68950 100644 --- a/src/adiar/internal/data_types/convert.h +++ b/src/adiar/internal/data_types/convert.h @@ -51,10 +51,10 @@ namespace adiar::internal } ////////////////////////////////////////////////////////////////////////////////////////////////// - /// \brief Combine two arcs into a single node with a custom label. + /// \brief Combine two arcs into a single node with a custom level. ////////////////////////////////////////////////////////////////////////////////////////////////// inline node - node_of(const node::label_type label, const arc& low, const arc& high) + node_of(const node::level_type level, const arc& low, const arc& high) { adiar_assert(essential(low.source()) == essential(high.source()), "Source are the same origin"); @@ -72,7 +72,7 @@ namespace adiar::internal adiar_assert(essential(low.source()) == low.source() && essential(high.source()) == low.source()); - return node(node::uid_type(unsafe_replace(low.source(), label)), low.target(), high.target()); + return node(node::uid_type(unsafe_replace(low.source(), level)), low.target(), high.target()); } } diff --git a/src/adiar/internal/data_types/level_info.h b/src/adiar/internal/data_types/level_info.h index 490f81fb6..4e95562b0 100644 --- a/src/adiar/internal/data_types/level_info.h +++ b/src/adiar/internal/data_types/level_info.h @@ -24,16 +24,6 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////////////////////////// using signed_level_type = ptr_uint64::signed_level_type; - //////////////////////////////////////////////////////////////////////////////////////////////// - /// \brief Type of a variable label. - //////////////////////////////////////////////////////////////////////////////////////////////// - using label_type = ptr_uint64::level_type; - - //////////////////////////////////////////////////////////////////////////////////////////////// - /// \brief Type of a difference between variable labels. - //////////////////////////////////////////////////////////////////////////////////////////////// - using signed_label_type = ptr_uint64::signed_level_type; - /* ========================================== VARIABLES ===================================== */ private: level_type _level; // cppcheck-suppress [uninitMemberVar] @@ -116,15 +106,6 @@ namespace adiar::internal return this->_level; } - //////////////////////////////////////////////////////////////////////////////////////////////// - /// \brief Obtain the label for a level. - //////////////////////////////////////////////////////////////////////////////////////////////// - level_type - label() const - { - return this->level(); - } - //////////////////////////////////////////////////////////////////////////////////////////////// /// \brief Obtain the width (i.e. number of nodes) of this level. //////////////////////////////////////////////////////////////////////////////////////////////// @@ -175,7 +156,7 @@ namespace adiar::internal std::stringstream stream; stream << "{ "; - stream << this->level() << " (x" << this->label() << ")"; + stream << this->level(); stream << " | "; stream << "width: " << this->width(); stream << " }"; diff --git a/src/adiar/internal/data_types/node.h b/src/adiar/internal/data_types/node.h index acdac9c8d..82fea9847 100644 --- a/src/adiar/internal/data_types/node.h +++ b/src/adiar/internal/data_types/node.h @@ -61,12 +61,7 @@ namespace adiar::internal using level_type = pointer_type::level_type; //////////////////////////////////////////////////////////////////////////////////////////////// - /// \brief Type of this node's variable label. - //////////////////////////////////////////////////////////////////////////////////////////////// - using label_type = pointer_type::label_type; - - //////////////////////////////////////////////////////////////////////////////////////////////// - /// \brief The maximal possible value for a unique identifier's label. + /// \brief The maximal possible value for a unique identifier's level. //////////////////////////////////////////////////////////////////////////////////////////////// static constexpr level_type max_label = pointer_type::max_label; @@ -75,11 +70,6 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////////////////////////// using signed_level_type = pointer_type::signed_level_type; - //////////////////////////////////////////////////////////////////////////////////////////////// - /// \brief Type for a difference of levels. - //////////////////////////////////////////////////////////////////////////////////////////////// - using signed_label_type = pointer_type::signed_label_type; - //////////////////////////////////////////////////////////////////////////////////////////////// /// \brief Type of this node's level identifier. //////////////////////////////////////////////////////////////////////////////////////////////// @@ -235,57 +225,53 @@ namespace adiar::internal {} //////////////////////////////////////////////////////////////////////////////////////////////// - /// \brief Construct *internal* node `((label, id), low, high)`. + /// \brief Construct *internal* node `((level, id), low, high)`. //////////////////////////////////////////////////////////////////////////////////////////////// - node(const level_type label, const id_type id, const pointer_type& l, const pointer_type& h) - : _uid(label, id) + node(const level_type level, const id_type id, const pointer_type& l, const pointer_type& h) + : _uid(level, id) , _children{ l, h } { adiar_assert(!l.is_nil(), "Cannot create a node with nil child"); - adiar_assert(l.is_terminal() || label < l.label(), "Node is not prior to given low child"); + adiar_assert(l.is_terminal() || level < l.level(), "Node is not prior to given low child"); adiar_assert(!h.is_nil(), "Cannot create a node with nil child"); - adiar_assert(h.is_terminal() || label < h.label(), "Node is not prior to given high child"); + adiar_assert(h.is_terminal() || level < h.level(), "Node is not prior to given high child"); } //////////////////////////////////////////////////////////////////////////////////////////////// - /// \brief Construct *internal* node `((label, id), low, high)`. + /// \brief Construct *internal* node `((level, id), low, high)`. //////////////////////////////////////////////////////////////////////////////////////////////// - node(const level_type label, const id_type id, const node& l, const pointer_type& h) - : node(label, id, l.uid(), h) + node(const level_type level, const id_type id, const node& l, const pointer_type& h) + : node(level, id, l.uid(), h) { adiar_assert(outdegree == 2, "Constructor is for binary node only."); } //////////////////////////////////////////////////////////////////////////////////////////////// - /// \brief Construct *internal* node `((label, id), low, high)`. + /// \brief Construct *internal* node `((level, id), low, high)`. //////////////////////////////////////////////////////////////////////////////////////////////// - node(const level_type label, const id_type id, const pointer_type& l, const node& h) - : node(label, id, l, h.uid()) + node(const level_type level, const id_type id, const pointer_type& l, const node& h) + : node(level, id, l, h.uid()) { adiar_assert(outdegree == 2, "Constructor is for binary node only."); } //////////////////////////////////////////////////////////////////////////////////////////////// - /// \brief Construct *internal* node `((label, id), low, high)`. + /// \brief Construct *internal* node `((level, id), low, high)`. //////////////////////////////////////////////////////////////////////////////////////////////// - node(const level_type label, const id_type id, const node& l, const node& h) - : node(label, id, l.uid(), h.uid()) + node(const level_type level, const id_type id, const node& l, const node& h) + : node(level, id, l.uid(), h.uid()) { adiar_assert(outdegree == 2, "Constructor is for binary node only."); } //////////////////////////////////////////////////////////////////////////////////////////////// - /// \brief Obtain the label of a node. - /// - /// \pre `is_terminal()` evaluates to `false`. + /// \brief Obtain the level of a node. //////////////////////////////////////////////////////////////////////////////////////////////// - // TODO: Rename to `level()` when introducing variable ordering inline level_type - label() const + level() const { - adiar_assert(!is_terminal()); - return uid().label(); + return uid().level(); } //////////////////////////////////////////////////////////////////////////////////////////////// @@ -323,7 +309,7 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////////////////////////// /// \brief The 'low' child (also known as the 'else' child), i.e. reflecting assigning `false` - /// to variable with the 'label'. + /// to variable with the 'level'. /// /// \details This is similar to writing `.child(false)`. /// @@ -339,7 +325,7 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////////////////////////// /// \brief The 'high' child (also known as the 'then' child), i.e. reflecting assigning `true` - /// to variable with the 'label'. + /// to variable with the 'level'. /// /// \details This is similar to writing `.child(true)`. /// diff --git a/src/adiar/internal/data_types/ptr.h b/src/adiar/internal/data_types/ptr.h index 0af45c1fe..7c8fc5009 100644 --- a/src/adiar/internal/data_types/ptr.h +++ b/src/adiar/internal/data_types/ptr.h @@ -19,7 +19,7 @@ namespace adiar::internal // TODO (ADD (64-bit)): // TODO (10+ TiB Decision Diagrams): // Create a new 'ptr_templ' class that does not compress all information into a single 64-bit - // unsigned integer. The 'label_type' and 'id_type' should be provided as template parameters + // unsigned integer. The 'level_type' and 'id_type' should be provided as template parameters // and the 'max_id' and 'max_label' should be derived based on // 'std::numeric_limits::max()'. // @@ -188,7 +188,7 @@ namespace adiar::internal /// \brief Type able to hold the node's level. //////////////////////////////////////////////////////////////////////////////////////////////// // TODO: - // Template with 'label bits' and derive with `std::conditional_type` the + // Template with 'level bits' and derive with `std::conditional_type` the // smallest type that can fit all the requested number of bits. using level_type = uint32_t; @@ -336,7 +336,7 @@ namespace adiar::internal /* ========================================== NODES ========================================= */ //////////////////////////////////////////////////////////////////////////////////////////////// - // befriend label modifying functions that need access to protected values. + // befriend level modifying functions that need access to protected values. friend ptr_uint64 unsafe_replace(const ptr_uint64& p, const level_type new_level); @@ -363,16 +363,6 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////////////////////////// public: - //////////////////////////////////////////////////////////////////////////////////////////////// - /// \brief Type able to hold the label of a variable. - //////////////////////////////////////////////////////////////////////////////////////////////// - using label_type = level_type; - - //////////////////////////////////////////////////////////////////////////////////////////////// - /// \brief Type able to hold the label of a variable. - //////////////////////////////////////////////////////////////////////////////////////////////// - using signed_label_type = signed_level_type; - //////////////////////////////////////////////////////////////////////////////////////////////// /// \brief Type of a level identifier. //////////////////////////////////////////////////////////////////////////////////////////////// @@ -426,40 +416,46 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////////////////////////// /// \brief The maximal possible value for a unique identifier's label. //////////////////////////////////////////////////////////////////////////////////////////////// - static constexpr label_type max_label = max_level - 2u; + static constexpr level_type max_label = max_level - 2u; static_assert(max_label < max_level); public: //////////////////////////////////////////////////////////////////////////////////////////////// - /// \brief Constructor for a pointer to an internal node (label, id) with weight 0. + /// \brief Constructor for a pointer to an internal node (level, id) with weight 0. //////////////////////////////////////////////////////////////////////////////////////////////// - constexpr ptr_uint64(const label_type label, const id_type id) - : _raw((static_cast(label) << level_shift) + constexpr ptr_uint64(const level_type level, const id_type id) + : _raw((static_cast(level) << level_shift) | (static_cast(id) << (data_shift + out_idx_bits))) { // TODO: Add Debug checks for non-constexpr context - // adiar_assert(label <= max_label, "Cannot represent given label"); - // adiar_assert(id <= max_id, "Cannot represent given id"); + // + // adiar_assert(level <= max_label, + // "Level exceeds 'max_label', i.e. the number of representable internal nodes"); + // + // adiar_assert(id <= max_id, "ID exceeds 'max_id'"); } //////////////////////////////////////////////////////////////////////////////////////////////// - /// \brief Constructor for a pointer to an internal node (label, id) with + /// \brief Constructor for a pointer to an internal node (level, id) with /// given weight. //////////////////////////////////////////////////////////////////////////////////////////////// - constexpr ptr_uint64(const label_type label, const id_type id, const out_idx_type out_idx) - : _raw((static_cast(label) << level_shift) + constexpr ptr_uint64(const level_type level, const id_type id, const out_idx_type out_idx) + : _raw((static_cast(level) << level_shift) | (static_cast(id) << (data_shift + out_idx_bits)) | (static_cast(out_idx) << data_shift)) { // TODO: Add Debug checks for non-constexpr context - // adiar_assert(label <= max_label, "Cannot represent given label"); + // adiar_assert(level <= max_label, + // "Level exceeds 'max_label', i.e. the number of representable internal nodes"); + // // adiar_assert(id <= max_id, "Cannot represent given id"); - // adiar_assert(out_idx <= max_out_idx, "Cannot represent given id"); + // + // adiar_assert(out_idx <= max_out_idx, "Cannot represent given idx"); } public: //////////////////////////////////////////////////////////////////////////////////////////////// - /// \brief Whether a pointer is for an internal node (label, id). + /// \brief Whether a pointer is for an internal node (level, id). //////////////////////////////////////////////////////////////////////////////////////////////// inline bool is_node() const @@ -475,19 +471,7 @@ namespace adiar::internal } //////////////////////////////////////////////////////////////////////////////////////////////// - /// \brief Extract the label from an internal node (label, id). - /// - /// \pre `is_node()` evaluates to `true.` - //////////////////////////////////////////////////////////////////////////////////////////////// - inline label_type - label() const - { - adiar_assert(is_node()); - return this->level(); - } - - //////////////////////////////////////////////////////////////////////////////////////////////// - /// \brief Extract the level identifier from an internal node (label, id). + /// \brief Extract the level identifier from an internal node (level, id). /// /// \pre `is_node()` evaluates to `true.` //////////////////////////////////////////////////////////////////////////////////////////////// @@ -870,14 +854,14 @@ namespace adiar::internal adiar_assert(p.is_node()); adiar_assert(new_level <= ptr_uint64::max_label); - constexpr ptr_uint64::raw_type non_labels_mask = + constexpr ptr_uint64::raw_type non_levels_mask = ~(static_cast(ptr_uint64::max_level) << ptr_uint64::level_shift); - const ptr_uint64::raw_type non_labels_bits = p._raw & non_labels_mask; - const ptr_uint64::raw_type labels_bits = static_cast(new_level) + const ptr_uint64::raw_type non_levels_bits = p._raw & non_levels_mask; + const ptr_uint64::raw_type levels_bits = static_cast(new_level) << ptr_uint64::level_shift; - return non_labels_bits | labels_bits; + return non_levels_bits | levels_bits; } ////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/adiar/internal/data_types/request.h b/src/adiar/internal/data_types/request.h index e41543c7f..fb0c1deaf 100644 --- a/src/adiar/internal/data_types/request.h +++ b/src/adiar/internal/data_types/request.h @@ -56,9 +56,9 @@ namespace adiar::internal static constexpr bool sorted_target = Sorted || cardinality == 1u; //////////////////////////////////////////////////////////////////////////////////////////////// - /// \brief Type of a variable label. + /// \brief Type for the requests level. //////////////////////////////////////////////////////////////////////////////////////////////// - using label_type = node::label_type; + using level_type = node::level_type; //////////////////////////////////////////////////////////////////////////////////////////////// /// \brief Type of a pointer. @@ -80,7 +80,7 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////////////////////////// /// \brief The level at which this request should be resolved. //////////////////////////////////////////////////////////////////////////////////////////////// - pointer_type::label_type + level_type level() const { return target.first().level(); @@ -418,10 +418,10 @@ namespace adiar::internal inline bool operator()(const Request& a, const Request& b) { - const typename Request::label_type label_a = a.target.first().label(); - const typename Request::label_type label_b = b.target.first().label(); + const typename Request::level_type level_a = a.target.first().level(); + const typename Request::level_type level_b = b.target.first().level(); - return label_a < label_b || (label_a == label_b && a.target < b.target); + return level_a < level_b || (level_a == level_b && a.target < b.target); } }; @@ -566,7 +566,7 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////////////////////////// /// \brief The level at which this request should be resolved. //////////////////////////////////////////////////////////////////////////////////////////////// - typename Request::label_type + typename Request::level_type level() const { if constexpr (Data::has_level) { return std::min(Request::level(), this->data.level); } @@ -617,8 +617,8 @@ namespace adiar::internal operator()(const Request& a, const Request& b) { if constexpr (Request::data_type::has_level) { - const typename Request::label_type a_level = a.level(); - const typename Request::label_type b_level = b.level(); + const typename Request::level_type a_level = a.level(); + const typename Request::level_type b_level = b.level(); if (a_level != b_level) return a_level < b_level; } if constexpr (Request::data_type::sort_on_tiebreak) { @@ -718,12 +718,12 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////////////////////////// /// \brief Level to be used if the level is invalid/non-existent. //////////////////////////////////////////////////////////////////////////////////////////////// - static constexpr node::label_type no_level = node::pointer_type::nil_level; + static constexpr node::level_type no_level = node::pointer_type::nil_level; //////////////////////////////////////////////////////////////////////////////////////////////// /// \brief Level at which something ought to happen. //////////////////////////////////////////////////////////////////////////////////////////////// - node::label_type level; + node::level_type level; //////////////////////////////////////////////////////////////////////////////////////////////// /// \brief String representation of the level data. @@ -776,7 +776,7 @@ namespace adiar::internal , with_level{ with_level::no_level } {} - with_parent_and_level(const node::pointer_type& source, node::label_type level) + with_parent_and_level(const node::pointer_type& source, node::level_type level) : with_parent{ source } , with_level{ level } {} diff --git a/src/adiar/internal/data_types/uid.h b/src/adiar/internal/data_types/uid.h index 3ee310ab7..d5bcfb686 100644 --- a/src/adiar/internal/data_types/uid.h +++ b/src/adiar/internal/data_types/uid.h @@ -123,11 +123,11 @@ namespace adiar::internal /* ========================================== NODES ========================================= */ public: //////////////////////////////////////////////////////////////////////////////////////////////// - /// \brief Constructor for a pointer to an internal node (label, id). + /// \brief Constructor for a pointer to an internal node (level, id). //////////////////////////////////////////////////////////////////////////////////////////////// - explicit __uid(const typename pointer_type::label_type label, + explicit __uid(const typename pointer_type::level_type level, const typename pointer_type::id_type id) - : pointer_type(label, id) + : pointer_type(level, id) {} // Remove anything related to out-index @@ -189,7 +189,7 @@ namespace adiar::internal as_ptr(const typename pointer_type::out_idx_type out_idx) const { adiar_assert(this->is_node()); - return pointer_type(this->label(), this->id(), out_idx); + return pointer_type(this->level(), this->id(), out_idx); } }; diff --git a/src/adiar/internal/dd.h b/src/adiar/internal/dd.h index 3efeb5315..2cba74e44 100644 --- a/src/adiar/internal/dd.h +++ b/src/adiar/internal/dd.h @@ -65,14 +65,24 @@ namespace adiar::internal using uid_type = node_type::uid_type; //////////////////////////////////////////////////////////////////////////////////////////////// - /// \brief Type of this node's variable label. + /// \brief Type of the level of nodes. + //////////////////////////////////////////////////////////////////////////////////////////////// + using level_type = node_type::level_type; + //////////////////////////////////////////////////////////////////////////////////////////////// - using label_type = node_type::label_type; + /// \brief Type for difference between node levels. + //////////////////////////////////////////////////////////////////////////////////////////////// + using signed_level_type = node_type::signed_level_type; + + //////////////////////////////////////////////////////////////////////////////////////////////// + /// \brief Type of variable labels. + //////////////////////////////////////////////////////////////////////////////////////////////// + using label_type = level_type; //////////////////////////////////////////////////////////////////////////////////////////////// /// \brief Type for difference between variable labels. //////////////////////////////////////////////////////////////////////////////////////////////// - using signed_label_type = node_type::signed_label_type; + using signed_label_type = signed_level_type; //////////////////////////////////////////////////////////////////////////////////////////////// /// \brief Type of nodes of this diagram. @@ -287,14 +297,24 @@ namespace adiar::internal using uid_type = node_type::uid_type; //////////////////////////////////////////////////////////////////////////////////////////////// - /// \brief Type of this node's variable label. + /// \brief Type of the level of nodes. + //////////////////////////////////////////////////////////////////////////////////////////////// + using level_type = node_type::level_type; + + //////////////////////////////////////////////////////////////////////////////////////////////// + /// \brief Type for difference between node levels. //////////////////////////////////////////////////////////////////////////////////////////////// - using label_type = node_type::label_type; + using signed_level_type = node_type::signed_level_type; + + //////////////////////////////////////////////////////////////////////////////////////////////// + /// \brief Type of variable labels. + //////////////////////////////////////////////////////////////////////////////////////////////// + using label_type = level_type; //////////////////////////////////////////////////////////////////////////////////////////////// /// \brief Type for difference between variable labels. //////////////////////////////////////////////////////////////////////////////////////////////// - using signed_label_type = node_type::signed_label_type; + using signed_label_type = signed_level_type; //////////////////////////////////////////////////////////////////////////////////////////////// /// \brief The maximal possible value for a unique identifier's label. @@ -551,6 +571,16 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////////////////////////// using children_type = typename node_type::children_type; + //////////////////////////////////////////////////////////////////////////////////////////////// + /// \brief Type of this node's variable label. + //////////////////////////////////////////////////////////////////////////////////////////////// + using level_type = typename dd_type::level_type; + + //////////////////////////////////////////////////////////////////////////////////////////////// + /// \brief Type for difference between variable labels. + //////////////////////////////////////////////////////////////////////////////////////////////// + using signed_level_type = typename dd_type::signed_level_type; + //////////////////////////////////////////////////////////////////////////////////////////////// /// \brief Type of this node's variable label. //////////////////////////////////////////////////////////////////////////////////////////////// @@ -559,7 +589,7 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////////////////////////// /// \brief Type for difference between variable labels. //////////////////////////////////////////////////////////////////////////////////////////////// - using signed_label_type = typename dd_type::label_type; + using signed_label_type = typename dd_type::signed_label_type; //////////////////////////////////////////////////////////////////////////////////////////////// /// \brief The maximal possible value for a unique identifier's label. diff --git a/src/adiar/internal/dd_func.h b/src/adiar/internal/dd_func.h index dfc485e3c..e4195bf32 100644 --- a/src/adiar/internal/dd_func.h +++ b/src/adiar/internal/dd_func.h @@ -149,7 +149,7 @@ namespace adiar::internal dd_support(const DD& dd, const consumer& cb) { level_info_ifstream<> info_ifstream(dd); - while (info_ifstream.can_pull()) { cb(info_ifstream.pull().label()); } + while (info_ifstream.can_pull()) { cb(info_ifstream.pull().level()); } } } diff --git a/src/adiar/internal/io/levelized_ifstream.h b/src/adiar/internal/io/levelized_ifstream.h index a7da7e62c..9df8ca92a 100644 --- a/src/adiar/internal/io/levelized_ifstream.h +++ b/src/adiar/internal/io/levelized_ifstream.h @@ -199,7 +199,7 @@ namespace adiar::internal /// \brief Construct attached to a file. /// /// \param shift_levels - /// Number of variable labels (and levels) to shift by. + /// Number of variable levels to shift by. //////////////////////////////////////////////////////////////////////////////////////////////// level_info_ifstream(const file& f, level_info::signed_level_type shift = 0) : _shift(shift) @@ -211,7 +211,7 @@ namespace adiar::internal /// \brief Construct attached to a file. /// /// \param shift_levels - /// Number of variable labels (and levels) to shift by. + /// Number of levels to shift by. //////////////////////////////////////////////////////////////////////////////////////////////// level_info_ifstream(const adiar::shared_ptr>& f, level_info::signed_level_type shift = 0) diff --git a/src/adiar/internal/io/levelized_raccess.h b/src/adiar/internal/io/levelized_raccess.h index b5e048791..d255dbca5 100644 --- a/src/adiar/internal/io/levelized_raccess.h +++ b/src/adiar/internal/io/levelized_raccess.h @@ -29,7 +29,7 @@ namespace adiar::internal using pointer_type = typename value_type::pointer_type; using uid_type = typename value_type::uid_type; - using signed_label_type = typename value_type::signed_label_type; + using signed_level_type = typename value_type::signed_level_type; using idx_type = typename value_type::id_type; public: @@ -64,7 +64,7 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////////////////////////// /// \brief Buffer with all elements of the current level. //////////////////////////////////////////////////////////////////////////////////////////////// - signed_label_type _curr_level = 0; + signed_level_type _curr_level = 0; //////////////////////////////////////////////////////////////////////////////////////////////// /// \brief Width of the current level. @@ -89,7 +89,7 @@ namespace adiar::internal template levelized_raccess(levelized_file& f, const bool negate = false, - const typename T::signed_label_type& shift = 0) + const typename T::signed_level_type& shift = 0) : _ifstream(f, negate, shift) , _max_width(f.width) , _level_buffer(f.width) @@ -104,7 +104,7 @@ namespace adiar::internal template levelized_raccess(const levelized_file& f, const bool negate = false, - const typename T::signed_label_type shift = 0) + const typename T::signed_level_type shift = 0) : _ifstream(f, negate, shift) , _max_width(f.width) , _level_buffer(f.width) @@ -119,7 +119,7 @@ namespace adiar::internal template levelized_raccess(const shared_ptr>& f, const bool negate = false, - const typename T::signed_label_type shift = 0) + const typename T::signed_level_type shift = 0) : _ifstream(f, negate, shift) , _max_width(f->width) , _level_buffer(f->width) @@ -163,10 +163,10 @@ namespace adiar::internal /// /// \pre `has_next_level() == true` //////////////////////////////////////////////////////////////////////////////////////////////// - signed_label_type + signed_level_type next_level() { - return _ifstream.peek().uid().label(); + return _ifstream.peek().uid().level(); } //////////////////////////////////////////////////////////////////////////////////////////////// @@ -178,7 +178,7 @@ namespace adiar::internal /// \pre `has_current_level() == false` or `current_level() < level` //////////////////////////////////////////////////////////////////////////////////////////////// void - setup_next_level(const signed_label_type level) + setup_next_level(const signed_level_type level) { adiar_assert(!has_current_level() || current_level() < level); @@ -192,13 +192,13 @@ namespace adiar::internal // Skip all levels not of interest while (_ifstream.can_pull() - && static_cast(_ifstream.peek().uid().label()) < level) { + && static_cast(_ifstream.peek().uid().level()) < level) { _ifstream.pull(); } // Copy over all elements from the requested level while (_ifstream.can_pull() - && static_cast(_ifstream.peek().uid().label()) == level) { + && static_cast(_ifstream.peek().uid().level()) == level) { _level_buffer[_curr_width++] = _ifstream.pull(); } } @@ -223,9 +223,9 @@ namespace adiar::internal } //////////////////////////////////////////////////////////////////////////////////////////////// - /// \brief The label of the current level. + /// \brief The current level. //////////////////////////////////////////////////////////////////////////////////////////////// - signed_label_type + signed_level_type current_level() const { return _curr_level; diff --git a/src/adiar/internal/io/narc_ifstream.h b/src/adiar/internal/io/narc_ifstream.h index c9ac7a418..ac184dfef 100644 --- a/src/adiar/internal/io/narc_ifstream.h +++ b/src/adiar/internal/io/narc_ifstream.h @@ -67,7 +67,7 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////////////////////////// narc_ifstream(levelized_file& file, [[maybe_unused]] const bool negate = false, - [[maybe_unused]] const node::signed_label_type level_shift = 0) + [[maybe_unused]] const node::signed_level_type level_shift = 0) : _ifstream(/*need to sort before attach*/) { adiar_assert(negate == false); @@ -80,7 +80,7 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////////////////////////// narc_ifstream(const shared_ptr>& file, [[maybe_unused]] const bool negate = false, - [[maybe_unused]] const node::signed_label_type level_shift = 0) + [[maybe_unused]] const node::signed_level_type level_shift = 0) : _ifstream(/*need to sort before attach*/) { adiar_assert(negate == false); diff --git a/src/adiar/internal/io/narc_raccess.h b/src/adiar/internal/io/narc_raccess.h index ec072a1cd..ae48887a3 100644 --- a/src/adiar/internal/io/narc_raccess.h +++ b/src/adiar/internal/io/narc_raccess.h @@ -36,7 +36,7 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////////////////////////// narc_raccess(levelized_file& f, const bool negate = false, - [[maybe_unused]] const arc::signed_label_type shift = 0) + [[maybe_unused]] const arc::signed_level_type shift = 0) : parent_type(f, negate) { // adiar_assert(f.indexable); @@ -51,7 +51,7 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////////////////////////// narc_raccess(const shared_ptr>& f, const bool negate = false, - [[maybe_unused]] const arc::signed_label_type shift = 0) + [[maybe_unused]] const arc::signed_level_type shift = 0) : parent_type(f, negate) { // adiar_assert(f->indexable); @@ -85,7 +85,7 @@ namespace adiar::internal const value_type& at(pointer_type u) const { - adiar_assert(static_cast(u.label()) == current_level()); + adiar_assert(static_cast(u.level()) == current_level()); return parent_type::at(static_cast(u.id())); } }; diff --git a/src/adiar/internal/io/node_ifstream.h b/src/adiar/internal/io/node_ifstream.h index ab597feab..f4bdc5539 100644 --- a/src/adiar/internal/io/node_ifstream.h +++ b/src/adiar/internal/io/node_ifstream.h @@ -31,7 +31,7 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////////////////////////// /// \brief Number of levels with which an element ought to be shifted. //////////////////////////////////////////////////////////////////////////////////////////////// - node::signed_label_type _shift = 0; + node::signed_level_type _shift = 0; public: //////////////////////////////////////////////////////////////////////////////////////////////// @@ -44,7 +44,7 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////////////////////////// node_ifstream(const levelized_file& file, bool negate = false, - node::signed_label_type shift = 0) + node::signed_level_type shift = 0) : parent_type(file) , _negate(negate) , _shift(shift) @@ -55,7 +55,7 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////////////////////////// node_ifstream(const shared_ptr>& file, bool negate = false, - node::signed_label_type shift = 0) + node::signed_level_type shift = 0) : parent_type(file) , _negate(negate) , _shift(shift) diff --git a/src/adiar/internal/io/node_ofstream.h b/src/adiar/internal/io/node_ofstream.h index 125ad22b2..adf161e06 100644 --- a/src/adiar/internal/io/node_ofstream.h +++ b/src/adiar/internal/io/node_ofstream.h @@ -140,7 +140,7 @@ namespace adiar::internal if (_latest_node != dummy()) { // Output level information of the final level if (!_latest_node.is_terminal()) { - unsafe_push(level_info(_latest_node.label(), _level_size)); + unsafe_push(level_info(_latest_node.level(), _level_size)); } _level_size = 0u; // TODO: remove? @@ -202,7 +202,7 @@ namespace adiar::internal adiar_assert(!_latest_node.is_terminal(), "Cannot push after having pushed a terminal"); - const bool new_level = !first_push && _latest_node.label() != n.label(); + const bool new_level = !first_push && _latest_node.level() != n.level(); // ------------------------------------------------------------------------------------------- // Terminal edge-case @@ -232,7 +232,7 @@ namespace adiar::internal // Commit prior level when starting to push the next one if (new_level) { // Update level information with the level just finished - unsafe_push(level_info(_latest_node.label(), _level_size)); + unsafe_push(level_info(_latest_node.level(), _level_size)); _level_size = 0u; // Update 1-level cut information @@ -240,7 +240,7 @@ namespace adiar::internal std::max(_max_1level_short_internal, _curr_1level_short_internal); _curr_1level_short_internal = 0u; - _long_internal_ptr = node::uid_type(_latest_node.label(), node::max_id); + _long_internal_ptr = node::uid_type(_latest_node.level(), node::max_id); } // Update cut of the current level diff --git a/src/adiar/internal/io/node_raccess.h b/src/adiar/internal/io/node_raccess.h index 62470d5b9..06d08c25f 100644 --- a/src/adiar/internal/io/node_raccess.h +++ b/src/adiar/internal/io/node_raccess.h @@ -38,7 +38,7 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////////////////////////// node_raccess(const levelized_file& f, const bool negate = false, - const node::signed_label_type level_shift = 0) + const node::signed_level_type level_shift = 0) : parent_type(f, negate, level_shift) { adiar_assert(f.indexable); @@ -51,7 +51,7 @@ namespace adiar::internal //////////////////////////////////////////////////////////////////////////////////////////////// node_raccess(const shared_ptr>& f, const bool negate = false, - const node::signed_label_type level_shift = 0) + const node::signed_level_type level_shift = 0) : parent_type(f, negate, level_shift) { adiar_assert(f->indexable); @@ -86,7 +86,7 @@ namespace adiar::internal at(pointer_type p) const { adiar_assert(!p.is_nil()); - adiar_assert(static_cast(p.label()) == this->current_level()); + adiar_assert(static_cast(p.level()) == this->current_level()); const idx_type idx = this->current_width() - ((pointer_type::max_id + 1u) - p.id()); return parent_type::at(idx); diff --git a/src/adiar/internal/util.h b/src/adiar/internal/util.h index 2037237e5..5b7c53d81 100644 --- a/src/adiar/internal/util.h +++ b/src/adiar/internal/util.h @@ -23,7 +23,7 @@ namespace adiar::internal /// \brief Template to hide how to obtain the level from a data type. ////////////////////////////////////////////////////////////////////////////////////////////////// template - inline ptr_uint64::label_type + inline ptr_uint64::level_type level_of(const T& t) { if constexpr (is_integral) { @@ -42,10 +42,10 @@ namespace adiar::internal /// \see level_ifstream_t, generator ////////////////////////////////////////////////////////////////////////////////////////////////// template - generator + generator make_generator__levels(LevelStream& ls) { - return [&ls]() mutable -> optional { + return [&ls]() mutable -> optional { if (!ls.can_pull()) { return {}; } return level_of(ls.pull()); }; @@ -77,20 +77,19 @@ namespace adiar::internal ////////////////////////////////////////////////////////////////////////////////////////////////// /// \brief Whether a certain level exists in a file. ////////////////////////////////////////////////////////////////////////////////////////////////// - // TODO: Move to dd_func? template bool - has_level(const DD& d, const typename DD::label_type x) + has_level(const DD& d, const typename DD::level_type x) { level_info_ifstream<> in_meta(d); while (in_meta.can_pull()) { level_info m = in_meta.pull(); // Are we already past where it should be? - if (x < m.label()) { return false; } + if (x < m.level()) { return false; } // Did we find it? - if (m.label() == x) { return true; } + if (m.level() == x) { return true; } } return false; } diff --git a/src/adiar/zdd/change.cpp b/src/adiar/zdd/change.cpp index 0b33d8fea..4683dcfcf 100644 --- a/src/adiar/zdd/change.cpp +++ b/src/adiar/zdd/change.cpp @@ -23,7 +23,7 @@ namespace adiar public: static zdd - on_empty_labels(const zdd& dd) + on_empty_levels(const zdd& dd) { return dd; } diff --git a/src/adiar/zdd/complement.cpp b/src/adiar/zdd/complement.cpp index 266d83a0e..97f9089d7 100644 --- a/src/adiar/zdd/complement.cpp +++ b/src/adiar/zdd/complement.cpp @@ -49,7 +49,7 @@ namespace adiar public: static zdd - on_empty_labels(const zdd& dd) + on_empty_levels(const zdd& dd) { return dd; } diff --git a/src/adiar/zdd/contains.cpp b/src/adiar/zdd/contains.cpp index 3fafee225..baf4b6fb8 100644 --- a/src/adiar/zdd/contains.cpp +++ b/src/adiar/zdd/contains.cpp @@ -30,7 +30,7 @@ namespace adiar inline zdd::pointer_type visit(const zdd::node_type& n) { - visited_label = n.label(); + visited_label = n.level(); const zdd::pointer_type next_ptr = l.has_value() && l.value() == visited_label ? n.high() : n.low(); @@ -45,7 +45,7 @@ namespace adiar // Will we miss the next to-be visited level? if (next_ptr.is_node() && l.has_value() && visited_label < l.value() - && l.value() < next_ptr.label()) { + && l.value() < next_ptr.level()) { return zdd::pointer_type::nil(); } } diff --git a/src/adiar/zdd/elem.cpp b/src/adiar/zdd/elem.cpp index 3659b355b..ee5899195 100644 --- a/src/adiar/zdd/elem.cpp +++ b/src/adiar/zdd/elem.cpp @@ -44,7 +44,7 @@ namespace adiar adiar_assert(!n.high().is_terminal() || n.high().value(), "high terminals are never false"); const zdd::pointer_type next = _visitor.visit(n); - if (__zdd_Xelem__output(n, next)) { _consumer(n.label()); } + if (__zdd_Xelem__output(n, next)) { _consumer(n.level()); } return next; } @@ -98,7 +98,7 @@ namespace adiar adiar_assert(!n.high().is_terminal() || n.high().value(), "high terminals are never false"); const zdd::pointer_type next = _visitor.visit(n); - if (__zdd_Xelem__output(n, next)) { _stack.push(n.label()); } + if (__zdd_Xelem__output(n, next)) { _stack.push(n.level()); } return next; } diff --git a/src/adiar/zdd/expand.cpp b/src/adiar/zdd/expand.cpp index 55c55e6d5..2afdca9c4 100644 --- a/src/adiar/zdd/expand.cpp +++ b/src/adiar/zdd/expand.cpp @@ -23,7 +23,7 @@ namespace adiar public: static zdd - on_empty_labels(const zdd& dd) + on_empty_levels(const zdd& dd) { return dd; } diff --git a/src/adiar/zdd/pred.cpp b/src/adiar/zdd/pred.cpp index 102126805..54e104377 100644 --- a/src/adiar/zdd/pred.cpp +++ b/src/adiar/zdd/pred.cpp @@ -162,7 +162,7 @@ namespace adiar static bool resolve_singletons(const zdd::node_type& v1, const zdd::node_type& v2) { - return v1.label() == v2.label() && v1.low() <= v2.low() && v1.high() <= v2.high(); + return v1.level() == v2.level() && v1.low() <= v2.low() && v1.high() <= v2.high(); } public: @@ -246,7 +246,7 @@ namespace adiar static bool resolve_singletons(const zdd::node_type& v1, const zdd::node_type& v2) { - return v1.label() != v2.label() || v1.low() != v2.low() || v1.high() != v2.high(); + return v1.level() != v2.level() || v1.low() != v2.low() || v1.high() != v2.high(); } public: diff --git a/src/adiar/zdd/subset.cpp b/src/adiar/zdd/subset.cpp index febcf282d..5108a9f94 100644 --- a/src/adiar/zdd/subset.cpp +++ b/src/adiar/zdd/subset.cpp @@ -20,7 +20,7 @@ namespace adiar optional l_excl = make_optional(); /// We will rememeber how far the algorithm in substitution.h has got - zdd::label_type alg_level = 0; + zdd::level_type alg_level = 0; /// Remember whether the current level is affected bool l_matches = false; @@ -71,7 +71,7 @@ namespace adiar } /// \brief Get the current level (including the current algorithm level) - zdd::label_type + zdd::level_type level_incl() const { adiar_assert(has_level_incl()); @@ -86,7 +86,7 @@ namespace adiar } /// \brief Get the next level (excluding the current one) - zdd::label_type + zdd::level_type level_excl() const { adiar_assert(has_level_excl()); @@ -204,7 +204,7 @@ namespace adiar { if (AssignmentPolicy::current_matches()) { if (AssignmentPolicy::has_level_excl()) { - if (n.high().is_terminal() || n.high().label() > AssignmentPolicy::level_excl()) { + if (n.high().is_terminal() || n.high().level() > AssignmentPolicy::level_excl()) { return zdd::pointer_type(false); } } @@ -216,12 +216,12 @@ namespace adiar // If recursion goes past the intended level, then it is replaced with // the false terminal. const zdd::pointer_type low = - n.low().is_terminal() || n.low().label() > AssignmentPolicy::level_incl() + n.low().is_terminal() || n.low().level() > AssignmentPolicy::level_incl() ? zdd::pointer_type(false) : n.low(); // If this applies to high, then the node should be skipped entirely. - if (n.high().is_terminal() || n.high().label() > AssignmentPolicy::level_incl()) { + if (n.high().is_terminal() || n.high().level() > AssignmentPolicy::level_incl()) { return low; } return zdd::node_type(n.uid(), low, n.high()); diff --git a/tests/adiar/bdd/count.test.cpp b/tests/adiar/bdd/count.test.cpp index a623fefe0..fe696eb8d 100644 --- a/tests/adiar/bdd/count.test.cpp +++ b/tests/adiar/bdd/count.test.cpp @@ -276,7 +276,7 @@ go_bandit([]() { describe("bdd_satcount(f) [non-empty dom]", [&]() { shared_file dom; { - ofstream lw(dom); + ofstream lw(dom); lw << 0 << 1 << 2 << 3 << 4 << 5 << 6; } domain_set(dom); diff --git a/tests/adiar/domain.test.cpp b/tests/adiar/domain.test.cpp index 848c6db95..b5e1a1c86 100644 --- a/tests/adiar/domain.test.cpp +++ b/tests/adiar/domain.test.cpp @@ -13,10 +13,10 @@ go_bandit([]() { describe("domain_isset(), domain_set(...), domain_unset()", []() { it("has domain after 'domain_set(file)'", []() { - shared_file dom; + shared_file dom; { // Garbage collect writer to free write-lock - ofstream lw(dom); + ofstream lw(dom); lw << 1 << 2 << 3; } @@ -51,7 +51,7 @@ go_bandit([]() { AssertThat(domain_isset(), Is().True()); - ifstream ls(domain_get()); + ifstream ls(domain_get()); AssertThat(ls.can_pull(), Is().False()); }); @@ -62,7 +62,7 @@ go_bandit([]() { AssertThat(domain_isset(), Is().True()); - ifstream ls(domain_get()); + ifstream ls(domain_get()); AssertThat(ls.can_pull(), Is().True()); AssertThat(ls.pull(), Is().EqualTo(0u)); @@ -76,7 +76,7 @@ go_bandit([]() { AssertThat(domain_isset(), Is().True()); - ifstream ls(domain_get()); + ifstream ls(domain_get()); AssertThat(ls.can_pull(), Is().True()); AssertThat(ls.pull(), Is().EqualTo(0u)); @@ -109,7 +109,7 @@ go_bandit([]() { { AssertThat(domain_isset(), Is().True()); - ifstream ls(domain_get()); + ifstream ls(domain_get()); AssertThat(ls.can_pull(), Is().True()); AssertThat(ls.pull(), Is().EqualTo(0u)); @@ -127,7 +127,7 @@ go_bandit([]() { { AssertThat(domain_isset(), Is().True()); - ifstream ls(domain_get()); + ifstream ls(domain_get()); AssertThat(ls.can_pull(), Is().True()); AssertThat(ls.pull(), Is().EqualTo(0u)); @@ -156,7 +156,7 @@ go_bandit([]() { domain_set(gen); AssertThat(domain_isset(), Is().True()); - ifstream ls(domain_get()); + ifstream ls(domain_get()); AssertThat(ls.can_pull(), Is().True()); AssertThat(ls.pull(), Is().EqualTo(1u)); @@ -188,7 +188,7 @@ go_bandit([]() { AssertThat(domain_isset(), Is().True()); - ifstream ls(domain_get()); + ifstream ls(domain_get()); AssertThat(ls.can_pull(), Is().True()); AssertThat(ls.pull(), Is().EqualTo(0u)); @@ -217,7 +217,7 @@ go_bandit([]() { { // Check for xs AssertThat(domain_isset(), Is().True()); - ifstream ls(domain_get()); + ifstream ls(domain_get()); AssertThat(ls.can_pull(), Is().True()); AssertThat(ls.pull(), Is().EqualTo(2u)); @@ -237,7 +237,7 @@ go_bandit([]() { { // Check for ys AssertThat(domain_isset(), Is().True()); - ifstream ls(domain_get()); + ifstream ls(domain_get()); AssertThat(ls.can_pull(), Is().True()); AssertThat(ls.pull(), Is().EqualTo(0u)); @@ -252,10 +252,10 @@ go_bandit([]() { it("gives back the given domain file", []() { domain_unset(); - shared_file dom; + shared_file dom; { // Garbage collect writer to free write-lock - ofstream lw(dom); + ofstream lw(dom); lw << 1 << 2 << 3; } @@ -268,10 +268,10 @@ go_bandit([]() { it("can overwrite with another domain file", []() { domain_unset(); - shared_file dom1; + shared_file dom1; { // Garbage collect writer to free write-lock - ofstream lw(dom1); + ofstream lw(dom1); lw << 1 << 2 << 3; } @@ -280,10 +280,10 @@ go_bandit([]() { AssertThat(domain_isset(), Is().True()); AssertThat(domain_get(), Is().EqualTo(dom1)); - shared_file dom2; + shared_file dom2; { // Garbage collect writer to free write-lock - ofstream lw(dom2); + ofstream lw(dom2); lw << 4 << 9 << 35; } diff --git a/tests/adiar/internal/algorithms/nested_sweeping.test.cpp b/tests/adiar/internal/algorithms/nested_sweeping.test.cpp index 4dbe8b607..04d55decd 100644 --- a/tests/adiar/internal/algorithms/nested_sweeping.test.cpp +++ b/tests/adiar/internal/algorithms/nested_sweeping.test.cpp @@ -82,8 +82,8 @@ class test_not_sweep } //////////////////////////////////////////////////////////////////////////////////////////////// - constexpr inline bdd::label_type - map_level(bdd::label_type x) const + constexpr inline bdd::level_type + map_level(bdd::level_type x) const { return x; } @@ -109,12 +109,12 @@ class test_not_sweep while (!inner_pq.empty()) { inner_pq.setup_next_level(); - const node::label_type level_label = inner_pq.current_level(); - node::id_type level_size = 0u; + const node::level_type level = inner_pq.current_level(); + node::id_type level_size = 0u; while (!inner_pq.empty_level()) { // Give node a new name - const node::uid_type u(level_label, level_size++); + const node::uid_type u(level, level_size++); // Get target of next request adiar_assert(!inner_pq.top().target.first().is_flagged(), @@ -136,7 +136,7 @@ class test_not_sweep } } - aw.push(level_info(level_label, level_size)); + aw.push(level_info(level, level_size)); af->max_1level_cut = std::max(af->max_1level_cut, inner_pq.size()); } @@ -177,7 +177,7 @@ class test_not_sweep /// \brief Whether it wants to sweep on some level. ////////////////////////////////////////////////////////////////////////////////////////////////// bool - has_sweep(node::pointer_type::label_type l) const + has_sweep(node::pointer_type::level_type l) const { return (l % _nesting_modulo) == 0u; } @@ -276,8 +276,8 @@ class test_terminal_sweep } //////////////////////////////////////////////////////////////////////////////////////////////// - constexpr inline node::label_type - map_level(node::label_type x) const + constexpr inline node::level_type + map_level(node::level_type x) const { return x; } @@ -303,25 +303,25 @@ class test_terminal_sweep while (!inner_pq.empty()) { inner_pq.setup_next_level(); - const node::label_type level_label = inner_pq.current_level(); - node::id_type level_size = 0u; + const node::level_type level = inner_pq.current_level(); + node::id_type level_size = 0u; while (!inner_pq.empty_level()) { // Get target of next request const node::pointer_type next = inner_pq.top().target.first(); node::uid_type t; - if (next.label() % _nesting_modulo == 1) { + if (next.level() % _nesting_modulo == 1) { // Collapse immediately to a terminal - t = node::uid_type(level_label % (_nesting_modulo + 1) > 0); + t = node::uid_type(level % (_nesting_modulo + 1) > 0); } else { // Create a simple (i, _, _) node with two terminals. - t = node::uid_type(level_label, level_size++); + t = node::uid_type(level, level_size++); - const node::pointer_type t0((level_label) % (_nesting_modulo) > 1); + const node::pointer_type t0((level) % (_nesting_modulo) > 1); aw.push_terminal({ t, false, t0 }); - const node::pointer_type t1((level_label + 1) % (_nesting_modulo) > 1); + const node::pointer_type t1((level + 1) % (_nesting_modulo) > 1); aw.push_terminal({ t, true, t1 }); } @@ -335,7 +335,7 @@ class test_terminal_sweep } } } - if (level_size > 0) { aw.push(level_info(level_label, level_size)); } + if (level_size > 0) { aw.push(level_info(level, level_size)); } } return __bdd(af, ep); @@ -359,7 +359,7 @@ class test_terminal_sweep /// \brief Whether it wants to sweep on some level. ////////////////////////////////////////////////////////////////////////////////////////////////// bool - has_sweep(node::pointer_type::label_type l) const + has_sweep(node::pointer_type::level_type l) const { return (l % _nesting_modulo) == 0u; } @@ -2128,7 +2128,7 @@ go_bandit([]() { }); describe("nested_sweeping::aux algorithms", []() { - describe("__reduce_level__fast(..., label, ...)", []() { + describe("__reduce_level__fast(..., level, ...)", []() { using pq_t = reduce_priority_queue<1, memory_mode::Internal>; it("does not suppress an entire level of redundant nodes", []() { @@ -3279,7 +3279,7 @@ go_bandit([]() { }); }); - describe("__reduce_level__fast(..., in_label, out_label, ...)", []() { + describe("__reduce_level__fast(..., in_level, out_level, ...)", []() { using pq_t = reduce_priority_queue<1, memory_mode::Internal>; it("does not canonically sort output [bottom level]", []() { @@ -5646,8 +5646,8 @@ go_bandit([]() { {} //////////////////////////////////////////////////////////////////////////////////////////////// - constexpr inline bdd::label_type - map_level(bdd::label_type x) const + constexpr inline bdd::level_type + map_level(bdd::level_type x) const { return x + this->_shift; } diff --git a/tests/adiar/internal/data_structures/levelized_priority_queue.test.cpp b/tests/adiar/internal/data_structures/levelized_priority_queue.test.cpp index 6589d1d6b..0cc7b38a9 100644 --- a/tests/adiar/internal/data_structures/levelized_priority_queue.test.cpp +++ b/tests/adiar/internal/data_structures/levelized_priority_queue.test.cpp @@ -4,13 +4,19 @@ struct lpq_test_data { - ptr_uint64::label_type label; - uint64_t nonce; + ptr_uint64::level_type _level; + uint64_t _nonce; - ptr_uint64::label_type + ptr_uint64::level_type level() const { - return label; + return _level; + } + + uint64_t + nonce() const + { + return _nonce; } }; @@ -24,7 +30,7 @@ namespace snowhouse ToString(const lpq_test_data& d) { std::stringstream stream; - stream << "{ " << d.label << ", " << d.nonce << " }"; + stream << "{ " << d.level() << ", " << d.nonce() << " }"; return stream.str(); } }; @@ -48,7 +54,7 @@ namespace adiar::internal bool operator==(const lpq_test_data& a, const lpq_test_data& b) { - return a.label == b.label && a.nonce == b.nonce; + return a.level() == b.level() && a.nonce() == b.nonce(); } struct lpq_test_lt @@ -56,7 +62,7 @@ struct lpq_test_lt bool operator()(const lpq_test_data& a, const lpq_test_data& b) { - return a.label < b.label || (a.label == b.label && a.nonce < b.nonce); + return a.level() < b.level() || (a.level() == b.level() && a.nonce() < b.nonce()); } }; @@ -65,7 +71,7 @@ struct lpq_test_gt bool operator()(const lpq_test_data& a, const lpq_test_data& b) { - return a.label > b.label || (a.label == b.label && a.nonce > b.nonce); + return a.level() > b.level() || (a.level() == b.level() && a.nonce() > b.nonce()); } }; @@ -85,7 +91,7 @@ go_bandit([]() { describe("adiar/internal/levelized_priority_queue.h", []() { //////////////////////////////////////////////////////////////////////////// // TODO: Most level files should be replaced with a simpler - // shared_file (and use the << operator). + // shared_file (and use the << operator). // Yet, we of course need one test or two with a meta file. // // TODO: Are we not missing some unit tests for the very simple accessors? @@ -462,7 +468,7 @@ go_bandit([]() { }); }); - describe(".setup_next_level(stop_label)", []() { + describe(".setup_next_level(stop_level)", []() { it("does nothing when given level prior to next bucket [1]", []() { const std::vector ls = { 1, // skipped @@ -987,7 +993,7 @@ go_bandit([]() { AssertThat(pq.can_pull(), Is().False()); }); - it("can set up next level with a stop_label [1]", []() { + it("can set up next level with a stop_level [1]", []() { lpq_test_file f; { // Garbage collect the writer early @@ -1017,7 +1023,7 @@ go_bandit([]() { AssertThat(pq.can_pull(), Is().False()); }); - it("can set up next level with a stop_label [2]", []() { + it("can set up next level with a stop_level [2]", []() { lpq_test_file f; { // Garbage collect the writer early @@ -2363,7 +2369,7 @@ go_bandit([]() { }); }); - describe(".setup_next_level(stop_label)", []() { + describe(".setup_next_level(stop_level)", []() { it("forwards to first level", []() { const std::vector ls = { 1, // skipped 2, @@ -2756,7 +2762,7 @@ go_bandit([]() { AssertThat(pq.can_pull(), Is().False()); }); - it("can set up next level with a stop_label [1]", []() { + it("can set up next level with a stop_level [1]", []() { lpq_test_file f; { // Garbage collect the writer early @@ -2786,7 +2792,7 @@ go_bandit([]() { AssertThat(pq.can_pull(), Is().False()); }); - it("can set up next level with a stop_label [2]", []() { + it("can set up next level with a stop_level [2]", []() { lpq_test_file f; { // Garbage collect the writer early @@ -3060,7 +3066,7 @@ go_bandit([]() { AssertThat(pq.can_pull(), Is().False()); }); - it("can set up next level with a stop_label [3]", []() { + it("can set up next level with a stop_level [3]", []() { const std::vector ls = { 0, // skipped 1, 2, 3, 4, @@ -3100,7 +3106,7 @@ go_bandit([]() { AssertThat(pq.can_pull(), Is().False()); }); - it("can set up next level with a stop_label [4]", []() { + it("can set up next level with a stop_level [4]", []() { const std::vector ls = { 0, // skipped 1, 2, 3, 4, 5, 6 }; @@ -3133,7 +3139,7 @@ go_bandit([]() { AssertThat(pq.can_pull(), Is().False()); }); - it("can set up next level with a stop_label [5]", []() { + it("can set up next level with a stop_level [5]", []() { const std::vector ls = { 0, // skipped 1, 2, @@ -3166,7 +3172,7 @@ go_bandit([]() { AssertThat(pq.can_pull(), Is().False()); }); - it("can set up next level with a stop_label [6]", []() { + it("can set up next level with a stop_level [6]", []() { const std::vector ls = { 0, // skipped 1, 2, 3, 4, 5, 6, 7 }; @@ -3206,7 +3212,7 @@ go_bandit([]() { AssertThat(pq.can_pull(), Is().False()); }); - it("can set up next level with a stop_label [7]", []() { + it("can set up next level with a stop_level [7]", []() { const std::vector ls = { 0, // skipped 1, 2, 3, 4, 5, 6, 7 }; @@ -3244,7 +3250,7 @@ go_bandit([]() { AssertThat(pq.can_pull(), Is().False()); }); - it("can set up next level with a stop_label [8]", []() { + it("can set up next level with a stop_level [8]", []() { const std::vector ls = { 0, // skipped 1, 2, 3, 4, 5 }; @@ -3279,7 +3285,7 @@ go_bandit([]() { AssertThat(pq.can_pull(), Is().False()); }); - it("can set up next level with a stop_label [9]", []() { + it("can set up next level with a stop_level [9]", []() { const std::vector ls = { 0, // skipped 1, 2, 3, 4, 5 }; @@ -4243,7 +4249,7 @@ go_bandit([]() { 0u, memory_mode::Internal, 1u, - std::less, + std::less, 0u> pq({ f }, memory_available(), 32, stats_lpq_tests); diff --git a/tests/adiar/internal/data_types/arc.test.cpp b/tests/adiar/internal/data_types/arc.test.cpp index be385aaa4..d7e8bfded 100644 --- a/tests/adiar/internal/data_types/arc.test.cpp +++ b/tests/adiar/internal/data_types/arc.test.cpp @@ -18,7 +18,7 @@ go_bandit([]() { const arc a = { ptr_uint64(42, 2, 0), terminal_F }; AssertThat(a.source().is_node(), Is().True()); - AssertThat(a.source().label(), Is().EqualTo(42u)); + AssertThat(a.source().level(), Is().EqualTo(42u)); AssertThat(a.source().id(), Is().EqualTo(2u)); AssertThat(a.out_idx(), Is().EqualTo(0u)); @@ -31,7 +31,7 @@ go_bandit([]() { const arc a = { ptr_uint64(2, 0, 1), terminal_T }; AssertThat(a.source().is_node(), Is().True()); - AssertThat(a.source().label(), Is().EqualTo(2u)); + AssertThat(a.source().level(), Is().EqualTo(2u)); AssertThat(a.source().id(), Is().EqualTo(0u)); AssertThat(a.out_idx(), Is().EqualTo(1u)); @@ -44,13 +44,13 @@ go_bandit([]() { const arc a = { ptr_uint64(2, 0, 1), ptr_uint64(3, 1) }; AssertThat(a.source().is_node(), Is().True()); - AssertThat(a.source().label(), Is().EqualTo(2u)); + AssertThat(a.source().level(), Is().EqualTo(2u)); AssertThat(a.source().id(), Is().EqualTo(0u)); AssertThat(a.out_idx(), Is().EqualTo(1u)); AssertThat(a.target().is_node(), Is().True()); - AssertThat(a.target().label(), Is().EqualTo(3u)); + AssertThat(a.target().level(), Is().EqualTo(3u)); AssertThat(a.target().id(), Is().EqualTo(1u)); }); }); @@ -60,7 +60,7 @@ go_bandit([]() { const arc a = { uid_uint64(42, 2), 0, terminal_F }; AssertThat(a.source().is_node(), Is().True()); - AssertThat(a.source().label(), Is().EqualTo(42u)); + AssertThat(a.source().level(), Is().EqualTo(42u)); AssertThat(a.source().id(), Is().EqualTo(2u)); AssertThat(a.out_idx(), Is().EqualTo(0u)); @@ -73,7 +73,7 @@ go_bandit([]() { const arc a = { uid_uint64(2, 0), 1, terminal_T }; AssertThat(a.source().is_node(), Is().True()); - AssertThat(a.source().label(), Is().EqualTo(2u)); + AssertThat(a.source().level(), Is().EqualTo(2u)); AssertThat(a.source().id(), Is().EqualTo(0u)); AssertThat(a.out_idx(), Is().EqualTo(1u)); @@ -86,13 +86,13 @@ go_bandit([]() { const arc a = { uid_uint64(2, 0), 1, ptr_uint64(3, 1) }; AssertThat(a.source().is_node(), Is().True()); - AssertThat(a.source().label(), Is().EqualTo(2u)); + AssertThat(a.source().level(), Is().EqualTo(2u)); AssertThat(a.source().id(), Is().EqualTo(0u)); AssertThat(a.out_idx(), Is().EqualTo(1u)); AssertThat(a.target().is_node(), Is().True()); - AssertThat(a.target().label(), Is().EqualTo(3u)); + AssertThat(a.target().level(), Is().EqualTo(3u)); AssertThat(a.target().id(), Is().EqualTo(1u)); }); }); diff --git a/tests/adiar/internal/data_types/convert.test.cpp b/tests/adiar/internal/data_types/convert.test.cpp index a97ff3c69..f44533d48 100644 --- a/tests/adiar/internal/data_types/convert.test.cpp +++ b/tests/adiar/internal/data_types/convert.test.cpp @@ -12,14 +12,14 @@ go_bandit([]() { const arc a = low_arc_of(n); AssertThat(a.source().is_flagged(), Is().False()); - AssertThat(a.source().label(), Is().EqualTo(7u)); + AssertThat(a.source().level(), Is().EqualTo(7u)); AssertThat(a.source().id(), Is().EqualTo(42u)); AssertThat(a.out_idx(), Is().EqualTo(0u)); AssertThat(a.source().out_idx(), Is().EqualTo(0u)); AssertThat(a.target().is_flagged(), Is().False()); - AssertThat(a.target().label(), Is().EqualTo(8u)); + AssertThat(a.target().level(), Is().EqualTo(8u)); AssertThat(a.target().id(), Is().EqualTo(21u)); }); }); @@ -30,14 +30,14 @@ go_bandit([]() { const arc a = high_arc_of(n); AssertThat(a.source().is_flagged(), Is().False()); - AssertThat(a.source().label(), Is().EqualTo(6u)); + AssertThat(a.source().level(), Is().EqualTo(6u)); AssertThat(a.source().id(), Is().EqualTo(13u)); AssertThat(a.out_idx(), Is().EqualTo(1u)); AssertThat(a.source().out_idx(), Is().EqualTo(1u)); AssertThat(a.target().is_flagged(), Is().False()); - AssertThat(a.target().label(), Is().EqualTo(9u)); + AssertThat(a.target().level(), Is().EqualTo(9u)); AssertThat(a.target().id(), Is().EqualTo(8u)); }); }); @@ -49,7 +49,7 @@ go_bandit([]() { const node n = node_of(l_arc, h_arc); - AssertThat(n.label(), Is().EqualTo(7u)); + AssertThat(n.level(), Is().EqualTo(7u)); AssertThat(n.id(), Is().EqualTo(42u)); AssertThat(n.low(), Is().EqualTo(l_arc.target())); @@ -62,7 +62,7 @@ go_bandit([]() { const node n = node_of(l_arc, h_arc); - AssertThat(n.label(), Is().EqualTo(7u)); + AssertThat(n.level(), Is().EqualTo(7u)); AssertThat(n.id(), Is().EqualTo(42u)); AssertThat(n.low(), Is().EqualTo(l_arc.target())); @@ -70,14 +70,14 @@ go_bandit([]() { }); }); - describe("node_of(label, arc, arc)", []() { + describe("node_of(level, arc, arc)", []() { it("should combine low and high arcs to nodes into single node", [&]() { const arc l_arc(uid_uint64(17, 42), false, ptr_uint64(9, 8)); const arc h_arc(uid_uint64(17, 42), true, ptr_uint64(8, 21)); const node n = node_of(7, l_arc, h_arc); - AssertThat(n.label(), Is().EqualTo(7u)); + AssertThat(n.level(), Is().EqualTo(7u)); AssertThat(n.id(), Is().EqualTo(42u)); AssertThat(n.low(), Is().EqualTo(l_arc.target())); @@ -90,7 +90,7 @@ go_bandit([]() { const node n = node_of(8, l_arc, h_arc); - AssertThat(n.label(), Is().EqualTo(8u)); + AssertThat(n.level(), Is().EqualTo(8u)); AssertThat(n.id(), Is().EqualTo(42u)); AssertThat(n.low(), Is().EqualTo(l_arc.target())); diff --git a/tests/adiar/internal/data_types/level_info.test.cpp b/tests/adiar/internal/data_types/level_info.test.cpp index 21da10fef..c7736c03f 100644 --- a/tests/adiar/internal/data_types/level_info.test.cpp +++ b/tests/adiar/internal/data_types/level_info.test.cpp @@ -11,35 +11,30 @@ go_bandit([]() { AssertThat(sizeof(li), Is().EqualTo(2u * 8u)); }); - describe(".level(), .label()", [&] { + describe(".level()", [&] { it("creates and retrieves from (0,1)", [&]() { const level_info li(0, 1); AssertThat(li.level(), Is().EqualTo(0u)); - AssertThat(li.label(), Is().EqualTo(0u)); }); it("creates and retrieves from (0,2)", [&]() { const level_info li(0, 2); AssertThat(li.level(), Is().EqualTo(0u)); - AssertThat(li.label(), Is().EqualTo(0u)); }); it("creates and retrieves from (42,8)", [&]() { const level_info li(42, 8); AssertThat(li.level(), Is().EqualTo(42u)); - AssertThat(li.label(), Is().EqualTo(42u)); }); it("creates and retrieves from (max,1)", [&]() { const level_info li(ptr_uint64::max_label, 1); AssertThat(li.level(), Is().EqualTo(ptr_uint64::max_label)); - AssertThat(li.level(), Is().EqualTo(ptr_uint64::max_label)); }); it("creates and retrieves from (max,2)", [&]() { const level_info li(ptr_uint64::max_label, 2); AssertThat(li.level(), Is().EqualTo(ptr_uint64::max_label)); - AssertThat(li.level(), Is().EqualTo(ptr_uint64::max_label)); }); }); @@ -68,12 +63,12 @@ go_bandit([]() { describe("to_string()", [] { it("prints { level: 0 (x0), size: 1 }", [&]() { const level_info li(0, 1); - AssertThat(li.to_string(), Is().EqualTo("{ 0 (x0) | width: 1 }")); + AssertThat(li.to_string(), Is().EqualTo("{ 0 | width: 1 }")); }); it("prints { level: 4 (x4), size: 2 }", [&]() { const level_info li(4, 2); - AssertThat(li.to_string(), Is().EqualTo("{ 4 (x4) | width: 2 }")); + AssertThat(li.to_string(), Is().EqualTo("{ 4 | width: 2 }")); }); }); diff --git a/tests/adiar/internal/data_types/node.test.cpp b/tests/adiar/internal/data_types/node.test.cpp index a522909a7..027dee0ee 100644 --- a/tests/adiar/internal/data_types/node.test.cpp +++ b/tests/adiar/internal/data_types/node.test.cpp @@ -15,11 +15,11 @@ go_bandit([]() { AssertThat(sizeof(n), Is().EqualTo(3u * 8u)); }); - describe("node(...), .label(), .id(), .low(), .high()", [&]() { - it("creates node [label_type, id_type, ptr_uint64, ptr_uint64] [1]", [&]() { + describe("node(...), .level(), .id(), .low(), .high()", [&]() { + it("creates node [level_type, id_type, ptr_uint64, ptr_uint64] [1]", [&]() { const node n = node(3u, 12u, terminal_F, terminal_T); AssertThat(n.uid(), Is().EqualTo(ptr_uint64(3, 12))); - AssertThat(n.label(), Is().EqualTo(3u)); + AssertThat(n.level(), Is().EqualTo(3u)); AssertThat(n.id(), Is().EqualTo(12u)); AssertThat(n.child(false), Is().EqualTo(n.low())); @@ -28,10 +28,10 @@ go_bandit([]() { AssertThat(n.high(), Is().EqualTo(terminal_T)); }); - it("creates node [label_type, id_type, ptr_uint64, ptr_uint64] [2]", [&]() { + it("creates node [level_type, id_type, ptr_uint64, ptr_uint64] [2]", [&]() { const node n = node(3u, 42u, terminal_T, terminal_F); AssertThat(n.uid(), Is().EqualTo(ptr_uint64(3, 42))); - AssertThat(n.label(), Is().EqualTo(3u)); + AssertThat(n.level(), Is().EqualTo(3u)); AssertThat(n.id(), Is().EqualTo(42u)); AssertThat(n.child(false), Is().EqualTo(n.low())); @@ -40,13 +40,13 @@ go_bandit([]() { AssertThat(n.high(), Is().EqualTo(terminal_F)); }); - it("creates node [label_type, id_type, node&, node&]", [&]() { + it("creates node [level_type, id_type, node&, node&]", [&]() { const node n_child1 = node(3u, 12u, terminal_F, terminal_T); const node n_child2 = node(3u, 42u, terminal_T, terminal_F); const node n = node(2, 2, n_child1, n_child2); AssertThat(n.uid(), Is().EqualTo(ptr_uint64(2, 2))); - AssertThat(n.label(), Is().EqualTo(2u)); + AssertThat(n.level(), Is().EqualTo(2u)); AssertThat(n.id(), Is().EqualTo(2u)); AssertThat(n.child(false), Is().EqualTo(n.low())); @@ -55,12 +55,12 @@ go_bandit([]() { AssertThat(n.high(), Is().EqualTo(n_child2.uid())); }); - it("creates node [label_type, id_type, node&, ptr_uint64]", [&]() { + it("creates node [level_type, id_type, node&, ptr_uint64]", [&]() { const node n_child = node(2u, 2u, terminal_F, terminal_T); const node n = node(1u, 7u, terminal_T, n_child); AssertThat(n.uid(), Is().EqualTo(ptr_uint64(1, 7))); - AssertThat(n.label(), Is().EqualTo(1u)); + AssertThat(n.level(), Is().EqualTo(1u)); AssertThat(n.id(), Is().EqualTo(7u)); AssertThat(n.child(false), Is().EqualTo(n.low())); @@ -69,12 +69,12 @@ go_bandit([]() { AssertThat(n.high(), Is().EqualTo(n_child.uid())); }); - it("creates node [label_type, id_type, ptr_uint64, node&]", [&]() { + it("creates node [level_type, id_type, ptr_uint64, node&]", [&]() { const node n_child = node(2u, 2u, terminal_F, terminal_T); const node n = node(0u, 3u, terminal_T, n_child); AssertThat(n.uid(), Is().EqualTo(ptr_uint64(0, 3))); - AssertThat(n.label(), Is().EqualTo(0u)); + AssertThat(n.level(), Is().EqualTo(0u)); AssertThat(n.id(), Is().EqualTo(3u)); AssertThat(n.child(false), Is().EqualTo(n.low())); @@ -193,7 +193,7 @@ go_bandit([]() { }); describe("comparators [node]", [&]() { - it("sorts primarily by label", [&]() { + it("sorts primarily by level", [&]() { const node node_1 = node(1u, 2u, terminal_F, terminal_T); const node node_2 = node(2u, 1u, terminal_T, terminal_F); @@ -302,7 +302,7 @@ go_bandit([]() { }); describe("comparators [uid]", [&]() { - it("sorts primarily by label [ 1]", [&]() { + it("sorts primarily by level [ 1]", [&]() { const node n = node(0u, 1u, terminal_F, terminal_T); const node::uid_type u = node::uid_type(1u, 0u); @@ -312,7 +312,7 @@ go_bandit([]() { AssertThat(u, Is().GreaterThanOrEqualTo(n)); }); - it("sorts primarily by label [!1]", [&]() { + it("sorts primarily by level [!1]", [&]() { const node n = node(0u, 1u, terminal_F, terminal_T); const node::uid_type u = node::uid_type(1u, 0u); @@ -322,7 +322,7 @@ go_bandit([]() { AssertThat(n, Is().Not().GreaterThanOrEqualTo(u)); }); - it("sorts primarily by label [ 2]", [&]() { + it("sorts primarily by level [ 2]", [&]() { const node n = node(21u, 8u, terminal_F, terminal_T); const node::uid_type u = node::uid_type(42u, 2u); @@ -332,7 +332,7 @@ go_bandit([]() { AssertThat(u, Is().GreaterThanOrEqualTo(n)); }); - it("sorts primarily by label [ 3]", [&]() { + it("sorts primarily by level [ 3]", [&]() { const node n = node(1u, 1u, terminal_F, terminal_T); const node::uid_type u = node::uid_type(0u, 2u); @@ -342,7 +342,7 @@ go_bandit([]() { AssertThat(n, Is().GreaterThanOrEqualTo(u)); }); - it("sorts primarily by label [ 4]", [&]() { + it("sorts primarily by level [ 4]", [&]() { const node n = node(42u, 0u, terminal_F, terminal_T); const node::uid_type u = node::uid_type(21u, 8u); @@ -352,7 +352,7 @@ go_bandit([]() { AssertThat(n, Is().GreaterThanOrEqualTo(u)); }); - it("sorts primarily by label [!4]", [&]() { + it("sorts primarily by level [!4]", [&]() { const node n = node(42u, 0u, terminal_F, terminal_T); const node::uid_type u = node::uid_type(21u, 8u); diff --git a/tests/adiar/internal/data_types/ptr.test.cpp b/tests/adiar/internal/data_types/ptr.test.cpp index e8e1c8af1..d2e9720b5 100644 --- a/tests/adiar/internal/data_types/ptr.test.cpp +++ b/tests/adiar/internal/data_types/ptr.test.cpp @@ -590,61 +590,49 @@ go_bandit([]() { }); }); - describe(".label(), .level()", [&]() { - it("should store and retrieve label for (0, max_id, false) Ptr", [&]() { - // This checks overflow of ids/out_idx into labels + describe(".level()", [&]() { + it("should store and retrieve level for (0, max_id, false) Ptr", [&]() { + // This checks overflow of ids/out_idx into levels const ptr_uint64 p = ptr_uint64(0, ptr_uint64::max_id, true); - AssertThat(p.label(), Is().EqualTo(0u)); - AssertThat(flag(p).label(), Is().EqualTo(0u)); - - AssertThat(p.label(), Is().EqualTo(p.level())); + AssertThat(p.level(), Is().EqualTo(0u)); + AssertThat(flag(p).level(), Is().EqualTo(0u)); }); it("should store and retrieve label for (12, max_id, false) Ptr", [&]() { const ptr_uint64 p = ptr_uint64(12, ptr_uint64::max_id, false); - AssertThat(p.label(), Is().EqualTo(12u)); - AssertThat(flag(p).label(), Is().EqualTo(12u)); - - AssertThat(p.label(), Is().EqualTo(p.level())); + AssertThat(p.level(), Is().EqualTo(12u)); + AssertThat(flag(p).level(), Is().EqualTo(12u)); }); it("should store and retrieve for (42, 2) Ptr", [&]() { const ptr_uint64 p = ptr_uint64(42, 2); - AssertThat(p.label(), Is().EqualTo(42u)); - AssertThat(flag(p).label(), Is().EqualTo(42u)); - - AssertThat(p.label(), Is().EqualTo(p.level())); + AssertThat(p.level(), Is().EqualTo(42u)); + AssertThat(flag(p).level(), Is().EqualTo(42u)); }); it("should store and retrieve for (21, 0, true) Ptr", [&]() { const ptr_uint64 p = ptr_uint64(21, 0, true); - AssertThat(p.label(), Is().EqualTo(21u)); - AssertThat(flag(p).label(), Is().EqualTo(21u)); - - AssertThat(p.label(), Is().EqualTo(p.level())); + AssertThat(p.level(), Is().EqualTo(21u)); + AssertThat(flag(p).level(), Is().EqualTo(21u)); }); it("should store and retrieve for (max_label, max_id) Ptr", [&]() { const ptr_uint64 p = ptr_uint64(ptr_uint64::max_label, ptr_uint64::max_id); - AssertThat(p.label(), Is().EqualTo(ptr_uint64::max_label)); - AssertThat(flag(p).label(), Is().EqualTo(ptr_uint64::max_label)); - - AssertThat(p.label(), Is().EqualTo(p.level())); + AssertThat(p.level(), Is().EqualTo(ptr_uint64::max_label)); + AssertThat(flag(p).level(), Is().EqualTo(ptr_uint64::max_label)); }); it("should store and retrieve for (max_label, max_id, max_out_idx) Ptr", [&]() { const ptr_uint64 p = ptr_uint64(ptr_uint64::max_label, ptr_uint64::max_id, ptr_uint64::max_out_idx); - AssertThat(p.label(), Is().EqualTo(ptr_uint64::max_label)); - AssertThat(flag(p).label(), Is().EqualTo(ptr_uint64::max_label)); - - AssertThat(p.label(), Is().EqualTo(p.level())); + AssertThat(p.level(), Is().EqualTo(ptr_uint64::max_label)); + AssertThat(flag(p).level(), Is().EqualTo(ptr_uint64::max_label)); }); }); @@ -1063,7 +1051,7 @@ go_bandit([]() { }); describe("ordering ( < )", [&]() { - it("should sort by label, then by id", [&]() { + it("should sort by level, then by id", [&]() { const ptr_uint64 node_1_2 = ptr_uint64(1, 2); const ptr_uint64 node_2_1 = ptr_uint64(2, 1); const ptr_uint64 node_2_2 = ptr_uint64(2, 2); @@ -1072,7 +1060,7 @@ go_bandit([]() { AssertThat(node_2_1 < node_2_2, Is().True()); }); - it("should sort by label and id independent of the flag", [&]() { + it("should sort by level and id independent of the flag", [&]() { const ptr_uint64 node_1_2 = ptr_uint64(1, 2); const ptr_uint64 node_2_1 = ptr_uint64(2, 1); @@ -1099,7 +1087,7 @@ go_bandit([]() { AssertThat(flag(node_1_T) < flag(node_2_F), Is().True()); }); - it("should sort by label, then id, and finally out-index", [&]() { + it("should sort by level, then id, and finally out-index", [&]() { const ptr_uint64 node_a = ptr_uint64(0, 3, true); const ptr_uint64 node_b = ptr_uint64(1, 2, false); @@ -1111,7 +1099,7 @@ go_bandit([]() { AssertThat(node_c < node_d, Is().True()); }); - it("should sort by label id, and out-index independent of the flag", [&]() { + it("should sort by level id, and out-index independent of the flag", [&]() { const ptr_uint64 node_a = ptr_uint64(0, 3, true); const ptr_uint64 node_b = ptr_uint64(1, 2, false); diff --git a/tests/adiar/zdd/project.test.cpp b/tests/adiar/zdd/project.test.cpp index d9cd13ea2..fa3dce280 100644 --- a/tests/adiar/zdd/project.test.cpp +++ b/tests/adiar/zdd/project.test.cpp @@ -1722,7 +1722,7 @@ go_bandit([]() { it("returns { Ø } for {1} with dom = {0} [const &]", [&]() { shared_file dom; { - ofstream lw(dom); + ofstream lw(dom); lw << 0; } @@ -2203,7 +2203,7 @@ go_bandit([]() { it("returns { Ø } for {1} with dom = {0} [const &]", [&]() { shared_file dom; { - ofstream lw(dom); + ofstream lw(dom); lw << 0; }