Adding sorting of columns in heuristic covering

This commit is contained in:
aletempiac 2023-11-17 15:55:10 +01:00
parent 1ca7a3a353
commit 3d602e2f00
1 changed files with 14 additions and 19 deletions

View File

@ -997,7 +997,7 @@ private:
best_bound_sets.clear(); best_bound_sets.clear();
/* create covering matrix */ /* create covering matrix */
if ( !create_covering_matrix<true>( isets, matrix, free_set_size, false ) ) if ( !create_covering_matrix<true>( isets, matrix, free_set_size, true ) )
{ {
return; return;
} }
@ -1148,29 +1148,24 @@ private:
sol_existance |= column; sol_existance |= column;
} }
/* necessary condition for the existance of a solution */
// if ( __builtin_popcountl( sol_existance ) != combinations )
// {
// return false;
// }
if ( !sort ) if ( !sort )
{ {
return true; return true;
} }
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 ) { std::sort( matrix.begin(), matrix.end(), [&]( auto const& a, auto const& b ) {
return a.sort_cost < b.sort_cost; 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";
// }
// }
return true; return true;
} }