26 for (
const auto& d:
mSets) {
27 max = std::max(max, d.size());
33 for (
auto& d:
mSets) {
45 return static_cast<std::size_t
>(std::count_if(
mSets.begin(),
mSets.end(),
46 [](
const auto& d){ return d.any(); }
51 assert(
mSets.size() > 0);
52 std::size_t largest_id = 0;
53 std::size_t largest_size =
mSets[0].count();
54 for (std::size_t
id = 1;
id <
mSets.size(); ++id) {
55 std::size_t size =
mSets[id].count();
56 if (size > largest_size) {
65 assert(
mSets.size() > 0);
66 std::size_t largest_id = 0;
67 double largest_size =
mSets[0].count() * weights[0];
68 for (std::size_t
id = 1;
id <
mSets.size(); ++id) {
69 double size =
mSets[id].count() * weights[id];
70 if (size > largest_size) {
80 [](
const auto& lhs,
const auto& rhs){
87 assert(
mSets.size() > s);
88 auto selected =
mSets[s];
96 os <<
"SetCover:" << std::endl;
97 for (
const auto& s: sc.
mSets) {
99 os <<
"\t" << s << std::endl;
std::ostream & operator<<(std::ostream &os, const SetCover &sc)
Print the set cover to os.
This class is a simple wrapper around boost::dynamic_bitset.
Represents a set cover problem.
std::size_t active_set_count() const
Returns the number of active sets (that still cover uncovered elements).
void select_set(std::size_t s)
Selects the given set and purges the covered elements from all other sets.
void prune_sets()
Removes empty sets.
std::vector< Bitset > mSets
The actual sets.
Bitset get_uncovered() const
Returns the uncovered elements.
std::size_t set_count() const
Returns the number of sets.
std::size_t element_count() const
Returns the number of elements.
void set(std::size_t set, std::size_t element)
States that s covers the given element.
std::size_t largest_set() const
Returns the id of the largest set.