From 20001f6f05b6031349993fe87c79bed7c45d0a1b Mon Sep 17 00:00:00 2001 From: reiniscirpons Date: Tue, 9 Apr 2024 10:35:32 +0100 Subject: [PATCH] Fix pruner evaluation order bug --- src/sims.cpp | 11 ++-- tests/test-sims.cpp | 125 +++++++++++++++++++------------------------- 2 files changed, 61 insertions(+), 75 deletions(-) diff --git a/src/sims.cpp b/src/sims.cpp index d2d1464a4..7f833e46a 100644 --- a/src/sims.cpp +++ b/src/sims.cpp @@ -596,17 +596,18 @@ namespace libsemigroups { } } - for (auto const& pruner : _sims1or2->pruners()) { - if (!pruner(_felsch_graph)) { - return false; - } - } return true; } template bool SimsBase::IteratorBase::install_descendents( PendingDef const& current) { + for (auto const& pruner : _sims1or2->pruners()) { + if (!pruner(_felsch_graph)) { + return false; + } + } + letter_type a = current.generator + 1; size_type const M = _felsch_graph.number_of_active_nodes(); size_type const N = _felsch_graph.number_of_edges(); diff --git a/tests/test-sims.cpp b/tests/test-sims.cpp index e5fda214e..1e22494dc 100644 --- a/tests/test-sims.cpp +++ b/tests/test-sims.cpp @@ -3849,77 +3849,62 @@ namespace libsemigroups { Sims2 s(p); SimsRefinerIdeals ip(s.presentation()); s.add_pruner(ip); - size_t result = 0; - s.for_each(3, [&ip, &result](auto const& wg) { - if (ip(wg)) { - result++; - } - }); - REQUIRE(result == 5); - result = 0; - s.for_each(4, [&ip, &result](auto const& wg) { - if (ip(wg)) { - result++; - } - }); - REQUIRE(result == 7); - - result = 0; - s.for_each(5, [&ip, &result](auto const& wg) { - if (ip(wg)) { - result++; - } - }); - REQUIRE(result == 9); - - result = 0; - s.for_each(6, [&ip, &result](auto const& wg) { - if (ip(wg)) { - result++; - } - }); - REQUIRE(result == 11); - result = 0; - s.for_each(7, [&ip, &result](auto const& wg) { - if (ip(wg)) { - result++; - } - }); - REQUIRE(result == 12); - - result = 0; - s.for_each(8, [&ip, &result](auto const& wg) { - if (ip(wg)) { - result++; - } - }); - REQUIRE(result == 12); - - REQUIRE(s.number_of_congruences(1) == 1); // computed using GAP - REQUIRE(s.number_of_congruences(2) == 3); // computed using GAP - - auto it = s.cbegin(3); - REQUIRE((*it++) == to_word_graph(4, {{1, 1}, {1, 1}})); - REQUIRE((*it++) == to_word_graph(4, {{1, 2}, {1, 1}, {1, 1}})); - REQUIRE((*it++) == to_word_graph(4, {{1, 2}, {2, 2}, {2, 2}})); - REQUIRE(*it - == to_word_graph(4, {{1, 2}, {2, 3}, {3, 3}, {3, 3}})); - - // REQUIRE((sims::right_generating_pairs(*it) | rx::to_vector()) - // == std::vector>()); - // REQUIRE((*it++) - // == to_word_graph(4, {{1, 2}, {3, 2}, {2, 2}, {2, 2}})); - // REQUIRE((*it++) - // == to_word_graph(4, {{1, 2}, {3, 3}, {3, 3}, {3, 3}})); - - // REQUIRE(s.number_of_congruences(3) == 5); // computed using GAP - - // REQUIRE(s.number_of_congruences(4) == 7); // computed using GAP - // REQUIRE(s.number_of_congruences(5) == 9); // computed using GAP - // REQUIRE(s.number_of_congruences(6) == 11); // computed using GAP - // REQUIRE(s.number_of_congruences(7) == 12); // computed using GAP - // REQUIRE(s.number_of_congruences(8) == 12); // computed using GAP + // size_t result = 0; + // s.for_each(3, [&ip, &result](auto const& wg) { + // if (ip(wg)) { + // result++; + // } + // }); + // REQUIRE(result == 5); + // result = 0; + // s.for_each(4, [&ip, &result](auto const& wg) { + // if (ip(wg)) { + // result++; + // } + // }); + // REQUIRE(result == 7); + // + // result = 0; + // s.for_each(5, [&ip, &result](auto const& wg) { + // if (ip(wg)) { + // result++; + // } + // }); + // REQUIRE(result == 9); + // + // result = 0; + // s.for_each(6, [&ip, &result](auto const& wg) { + // if (ip(wg)) { + // result++; + // } + // }); + // REQUIRE(result == 11); + // + // result = 0; + // s.for_each(7, [&ip, &result](auto const& wg) { + // if (ip(wg)) { + // result++; + // } + // }); + // REQUIRE(result == 12); + // + // result = 0; + // s.for_each(8, [&ip, &result](auto const& wg) { + // if (ip(wg)) { + // result++; + // } + // }); + // REQUIRE(result == 12); + + REQUIRE(s.number_of_congruences(1) == 1); // computed using GAP + REQUIRE(s.number_of_congruences(2) == 3); // computed using GAP + REQUIRE(s.number_of_congruences(3) == 5); // computed using GAP + REQUIRE(s.number_of_congruences(4) == 7); // computed using GAP + REQUIRE(s.number_of_congruences(5) == 9); // computed using GAP + REQUIRE(s.number_of_congruences(6) == 11); // computed using GAP + REQUIRE(s.number_of_congruences(7) == 12); // computed using GAP + REQUIRE(s.number_of_congruences(8) == 12); // computed using GAP } // about 2 seconds