From 1923c68dca07828f8ce91885d7920f01784a4407 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffan=20S=C3=B8lvsten?= Date: Thu, 13 Jun 2024 12:43:06 +0200 Subject: [PATCH] Use transposed result of 'bdd_and' in 'bdd_exist' for Relational Product --- src/adiar/bdd/relprod.cpp | 12 +++---- test/adiar/bdd/test_relprod.cpp | 60 ++++++++++++++++++++++----------- 2 files changed, 46 insertions(+), 26 deletions(-) diff --git a/src/adiar/bdd/relprod.cpp b/src/adiar/bdd/relprod.cpp index 4583bd0fd..ebeee77af 100644 --- a/src/adiar/bdd/relprod.cpp +++ b/src/adiar/bdd/relprod.cpp @@ -28,13 +28,13 @@ namespace adiar const function(bdd::label_type)>& m, replace_type m_type) { - const bdd tmp_1 = bdd_and(ep, states, relation); + __bdd tmp_1 = bdd_and(ep, states, relation); const bdd tmp_2 = bdd_exists(ep, std::move(tmp_1), [&m](bdd::label_type x) { return !m(x).has_value(); }); - const bdd tmp_3 = - bdd_replace(ep, std::move(tmp_2), [&m](bdd::label_type x) { return m(x).value(); }, m_type); + const bdd tmp_3 = bdd_replace( + ep, std::move(tmp_2), [&m](bdd::label_type x) { return m(x).value(); }, m_type); return tmp_3; } @@ -77,10 +77,10 @@ namespace adiar const function(bdd::label_type)>& m, replace_type m_type) { - const bdd tmp_1 = - bdd_replace(ep, states, [&m](bdd::label_type x) { return m(x).value(); }, m_type); + const bdd tmp_1 = bdd_replace( + ep, states, [&m](bdd::label_type x) { return m(x).value(); }, m_type); - const bdd tmp_2 = bdd_and(ep, std::move(tmp_1), relation); + __bdd tmp_2 = bdd_and(ep, std::move(tmp_1), relation); const bdd tmp_3 = bdd_exists(ep, std::move(tmp_2), [&m](bdd::label_type x) { return !m(x).has_value(); }); diff --git a/test/adiar/bdd/test_relprod.cpp b/test/adiar/bdd/test_relprod.cpp index 8f123c795..c4f95451d 100644 --- a/test/adiar/bdd/test_relprod.cpp +++ b/test/adiar/bdd/test_relprod.cpp @@ -1139,12 +1139,14 @@ go_bandit([]() { AssertThat(out->width, Is().EqualTo(1u)); AssertThat(out->max_1level_cut[cut::Internal], Is().EqualTo(1u)); - AssertThat(out->max_1level_cut[cut::Internal_False], Is().EqualTo(2u)); + AssertThat(out->max_1level_cut[cut::Internal_False], Is().GreaterThanOrEqualTo(2u)); + AssertThat(out->max_1level_cut[cut::Internal_False], Is().LessThanOrEqualTo(3u)); AssertThat(out->max_1level_cut[cut::Internal_True], Is().EqualTo(1u)); AssertThat(out->max_1level_cut[cut::All], Is().EqualTo(3u)); AssertThat(out->max_2level_cut[cut::Internal], Is().EqualTo(1u)); - AssertThat(out->max_2level_cut[cut::Internal_False], Is().EqualTo(2u)); + AssertThat(out->max_2level_cut[cut::Internal_False], Is().GreaterThanOrEqualTo(2u)); + AssertThat(out->max_2level_cut[cut::Internal_False], Is().LessThanOrEqualTo(3u)); AssertThat(out->max_2level_cut[cut::Internal_True], Is().EqualTo(1u)); AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(3u)); @@ -1197,12 +1199,14 @@ go_bandit([]() { AssertThat(out->width, Is().EqualTo(1u)); AssertThat(out->max_1level_cut[cut::Internal], Is().EqualTo(1u)); - AssertThat(out->max_1level_cut[cut::Internal_False], Is().EqualTo(2u)); + AssertThat(out->max_1level_cut[cut::Internal_False], Is().GreaterThanOrEqualTo(2u)); + AssertThat(out->max_1level_cut[cut::Internal_False], Is().LessThanOrEqualTo(3u)); AssertThat(out->max_1level_cut[cut::Internal_True], Is().EqualTo(1u)); AssertThat(out->max_1level_cut[cut::All], Is().EqualTo(3u)); AssertThat(out->max_2level_cut[cut::Internal], Is().EqualTo(1u)); - AssertThat(out->max_2level_cut[cut::Internal_False], Is().EqualTo(2u)); + AssertThat(out->max_2level_cut[cut::Internal_False], Is().GreaterThanOrEqualTo(2u)); + AssertThat(out->max_2level_cut[cut::Internal_False], Is().LessThanOrEqualTo(3u)); AssertThat(out->max_2level_cut[cut::Internal_True], Is().EqualTo(1u)); AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(3u)); @@ -2325,12 +2329,14 @@ go_bandit([]() { AssertThat(out->max_1level_cut[cut::Internal], Is().EqualTo(1u)); AssertThat(out->max_1level_cut[cut::Internal_False], Is().EqualTo(1u)); - AssertThat(out->max_1level_cut[cut::Internal_True], Is().EqualTo(2u)); + AssertThat(out->max_1level_cut[cut::Internal_True], Is().GreaterThanOrEqualTo(2u)); + AssertThat(out->max_1level_cut[cut::Internal_True], Is().LessThanOrEqualTo(3u)); AssertThat(out->max_1level_cut[cut::All], Is().EqualTo(3u)); AssertThat(out->max_2level_cut[cut::Internal], Is().EqualTo(1u)); AssertThat(out->max_2level_cut[cut::Internal_False], Is().EqualTo(1u)); - AssertThat(out->max_2level_cut[cut::Internal_True], Is().EqualTo(2u)); + AssertThat(out->max_2level_cut[cut::Internal_True], Is().GreaterThanOrEqualTo(2u)); + AssertThat(out->max_2level_cut[cut::Internal_True], Is().LessThanOrEqualTo(3u)); AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(3u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(1u)); @@ -2388,12 +2394,14 @@ go_bandit([]() { AssertThat(out->max_1level_cut[cut::Internal], Is().EqualTo(1u)); AssertThat(out->max_1level_cut[cut::Internal_False], Is().EqualTo(1u)); - AssertThat(out->max_1level_cut[cut::Internal_True], Is().EqualTo(2u)); + AssertThat(out->max_1level_cut[cut::Internal_True], Is().GreaterThanOrEqualTo(2u)); + AssertThat(out->max_1level_cut[cut::Internal_True], Is().LessThanOrEqualTo(3u)); AssertThat(out->max_1level_cut[cut::All], Is().EqualTo(3u)); AssertThat(out->max_2level_cut[cut::Internal], Is().EqualTo(1u)); AssertThat(out->max_2level_cut[cut::Internal_False], Is().EqualTo(1u)); - AssertThat(out->max_2level_cut[cut::Internal_True], Is().EqualTo(2u)); + AssertThat(out->max_2level_cut[cut::Internal_True], Is().GreaterThanOrEqualTo(2u)); + AssertThat(out->max_2level_cut[cut::Internal_True], Is().LessThanOrEqualTo(3u)); AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(3u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(1u)); @@ -4359,12 +4367,14 @@ go_bandit([]() { AssertThat(out->width, Is().EqualTo(1u)); AssertThat(out->max_1level_cut[cut::Internal], Is().EqualTo(1u)); - AssertThat(out->max_1level_cut[cut::Internal_False], Is().EqualTo(2u)); + AssertThat(out->max_1level_cut[cut::Internal_False], Is().GreaterThanOrEqualTo(2u)); + AssertThat(out->max_1level_cut[cut::Internal_False], Is().LessThanOrEqualTo(3u)); AssertThat(out->max_1level_cut[cut::Internal_True], Is().EqualTo(1u)); AssertThat(out->max_1level_cut[cut::All], Is().EqualTo(3u)); AssertThat(out->max_2level_cut[cut::Internal], Is().EqualTo(1u)); - AssertThat(out->max_2level_cut[cut::Internal_False], Is().EqualTo(2u)); + AssertThat(out->max_2level_cut[cut::Internal_False], Is().GreaterThanOrEqualTo(2u)); + AssertThat(out->max_2level_cut[cut::Internal_False], Is().LessThanOrEqualTo(3u)); AssertThat(out->max_2level_cut[cut::Internal_True], Is().EqualTo(1u)); AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(3u)); @@ -4401,12 +4411,14 @@ go_bandit([]() { AssertThat(out->width, Is().EqualTo(1u)); AssertThat(out->max_1level_cut[cut::Internal], Is().EqualTo(1u)); - AssertThat(out->max_1level_cut[cut::Internal_False], Is().EqualTo(2u)); + AssertThat(out->max_1level_cut[cut::Internal_False], Is().GreaterThanOrEqualTo(2u)); + AssertThat(out->max_1level_cut[cut::Internal_False], Is().LessThanOrEqualTo(3u)); AssertThat(out->max_1level_cut[cut::Internal_True], Is().EqualTo(1u)); AssertThat(out->max_1level_cut[cut::All], Is().EqualTo(3u)); AssertThat(out->max_2level_cut[cut::Internal], Is().EqualTo(1u)); - AssertThat(out->max_2level_cut[cut::Internal_False], Is().EqualTo(2u)); + AssertThat(out->max_2level_cut[cut::Internal_False], Is().GreaterThanOrEqualTo(2u)); + AssertThat(out->max_2level_cut[cut::Internal_False], Is().LessThanOrEqualTo(3u)); AssertThat(out->max_2level_cut[cut::Internal_True], Is().EqualTo(1u)); AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(3u)); @@ -4847,12 +4859,14 @@ go_bandit([]() { AssertThat(out->max_1level_cut[cut::Internal], Is().EqualTo(1u)); AssertThat(out->max_1level_cut[cut::Internal_False], Is().EqualTo(1u)); - AssertThat(out->max_1level_cut[cut::Internal_True], Is().EqualTo(2u)); + AssertThat(out->max_1level_cut[cut::Internal_True], Is().GreaterThanOrEqualTo(2u)); + AssertThat(out->max_1level_cut[cut::Internal_True], Is().LessThanOrEqualTo(3u)); AssertThat(out->max_1level_cut[cut::All], Is().EqualTo(3u)); AssertThat(out->max_2level_cut[cut::Internal], Is().EqualTo(1u)); AssertThat(out->max_2level_cut[cut::Internal_False], Is().EqualTo(1u)); - AssertThat(out->max_2level_cut[cut::Internal_True], Is().EqualTo(2u)); + AssertThat(out->max_2level_cut[cut::Internal_True], Is().GreaterThanOrEqualTo(2u)); + AssertThat(out->max_2level_cut[cut::Internal_True], Is().LessThanOrEqualTo(3u)); AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(3u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(1u)); @@ -4889,12 +4903,14 @@ go_bandit([]() { AssertThat(out->max_1level_cut[cut::Internal], Is().EqualTo(1u)); AssertThat(out->max_1level_cut[cut::Internal_False], Is().EqualTo(1u)); - AssertThat(out->max_1level_cut[cut::Internal_True], Is().EqualTo(2u)); + AssertThat(out->max_1level_cut[cut::Internal_True], Is().GreaterThanOrEqualTo(2u)); + AssertThat(out->max_1level_cut[cut::Internal_True], Is().LessThanOrEqualTo(3u)); AssertThat(out->max_1level_cut[cut::All], Is().EqualTo(3u)); AssertThat(out->max_2level_cut[cut::Internal], Is().EqualTo(1u)); AssertThat(out->max_2level_cut[cut::Internal_False], Is().EqualTo(1u)); - AssertThat(out->max_2level_cut[cut::Internal_True], Is().EqualTo(2u)); + AssertThat(out->max_2level_cut[cut::Internal_True], Is().GreaterThanOrEqualTo(2u)); + AssertThat(out->max_2level_cut[cut::Internal_True], Is().LessThanOrEqualTo(3u)); AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(3u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(1u)); @@ -5274,12 +5290,14 @@ go_bandit([]() { AssertThat(out->width, Is().EqualTo(1u)); AssertThat(out->max_1level_cut[cut::Internal], Is().EqualTo(1u)); - AssertThat(out->max_1level_cut[cut::Internal_False], Is().EqualTo(2u)); + AssertThat(out->max_1level_cut[cut::Internal_False], Is().GreaterThanOrEqualTo(2u)); + AssertThat(out->max_1level_cut[cut::Internal_False], Is().LessThanOrEqualTo(3u)); AssertThat(out->max_1level_cut[cut::Internal_True], Is().EqualTo(1u)); AssertThat(out->max_1level_cut[cut::All], Is().EqualTo(3u)); AssertThat(out->max_2level_cut[cut::Internal], Is().EqualTo(1u)); - AssertThat(out->max_2level_cut[cut::Internal_False], Is().EqualTo(2u)); + AssertThat(out->max_2level_cut[cut::Internal_False], Is().GreaterThanOrEqualTo(2u)); + AssertThat(out->max_2level_cut[cut::Internal_False], Is().LessThanOrEqualTo(3u)); AssertThat(out->max_2level_cut[cut::Internal_True], Is().EqualTo(1u)); AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(3u)); @@ -5598,12 +5616,14 @@ go_bandit([]() { AssertThat(out->max_1level_cut[cut::Internal], Is().EqualTo(1u)); AssertThat(out->max_1level_cut[cut::Internal_False], Is().EqualTo(1u)); - AssertThat(out->max_1level_cut[cut::Internal_True], Is().EqualTo(2u)); + AssertThat(out->max_1level_cut[cut::Internal_True], Is().GreaterThanOrEqualTo(2u)); + AssertThat(out->max_1level_cut[cut::Internal_True], Is().LessThanOrEqualTo(3u)); AssertThat(out->max_1level_cut[cut::All], Is().EqualTo(3u)); AssertThat(out->max_2level_cut[cut::Internal], Is().EqualTo(1u)); AssertThat(out->max_2level_cut[cut::Internal_False], Is().EqualTo(1u)); - AssertThat(out->max_2level_cut[cut::Internal_True], Is().EqualTo(2u)); + AssertThat(out->max_2level_cut[cut::Internal_True], Is().GreaterThanOrEqualTo(2u)); + AssertThat(out->max_2level_cut[cut::Internal_True], Is().LessThanOrEqualTo(3u)); AssertThat(out->max_2level_cut[cut::All], Is().EqualTo(3u)); AssertThat(out->number_of_terminals[false], Is().EqualTo(1u));