From 3d602e2f00fb2fa1ea06f61c6ff1e0391232d439 Mon Sep 17 00:00:00 2001 From: aletempiac Date: Fri, 17 Nov 2023 15:55:10 +0100 Subject: [PATCH] Adding sorting of columns in heuristic covering --- src/acd/ac_decomposition.hpp | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/src/acd/ac_decomposition.hpp b/src/acd/ac_decomposition.hpp index 0faf46b91..9fb17c764 100644 --- a/src/acd/ac_decomposition.hpp +++ b/src/acd/ac_decomposition.hpp @@ -997,7 +997,7 @@ private: best_bound_sets.clear(); /* create covering matrix */ - if ( !create_covering_matrix( isets, matrix, free_set_size, false ) ) + if ( !create_covering_matrix( isets, matrix, free_set_size, true ) ) { return; } @@ -1148,29 +1148,24 @@ private: sol_existance |= column; } - /* necessary condition for the existance of a solution */ - // if ( __builtin_popcountl( sol_existance ) != combinations ) - // { - // return false; - // } - if ( !sort ) { return true; } - std::sort( matrix.begin(), matrix.end(), [&]( auto const& a, auto const& b ) { - return a.sort_cost < b.sort_cost; - } ); - - /* print */ - // if ( best_multiplicity < 6 ) - // { - // for ( uint32_t i = 0; i < columns.size(); ++i ) - // { - // std::cout << indexes[i] << " " << costs[i] << " \t" << columns[i] << "\n"; - // } - // } + if constexpr ( UseHeuristic ) + { + std::sort( matrix.begin(), matrix.end(), [&]( auto const& a, auto const& b ) { + return a.cost < b.cost; + } ); + return true; + } + else + { + std::sort( matrix.begin(), matrix.end(), [&]( auto const& a, auto const& b ) { + return a.sort_cost < b.sort_cost; + } ); + } return true; }