carl
24.04
Computer ARithmetic Library
|
Represents a set cover problem. More...
#include <SetCover.h>
Public Member Functions | |
void | set (std::size_t set, std::size_t element) |
States that s covers the given element. More... | |
void | set (std::size_t set, const Bitset &elements) |
States that s covers the given elements. More... | |
const auto & | get_set (std::size_t set) const |
Returns the given set. More... | |
std::size_t | element_count () const |
Returns the number of elements. More... | |
void | prune_sets () |
Removes empty sets. More... | |
std::size_t | set_count () const |
Returns the number of sets. More... | |
std::size_t | active_set_count () const |
Returns the number of active sets (that still cover uncovered elements). More... | |
std::size_t | largest_set () const |
Returns the id of the largest set. More... | |
std::size_t | largest_set (const std::vector< double > &weights) const |
Returns the id of the largest set with respect to given weights. More... | |
Bitset | get_uncovered () const |
Returns the uncovered elements. More... | |
void | select_set (std::size_t s) |
Selects the given set and purges the covered elements from all other sets. More... | |
Private Attributes | |
std::vector< Bitset > | mSets |
The actual sets. More... | |
Friends | |
std::ostream & | operator<< (std::ostream &os, const SetCover &sc) |
Print the set cover to os. More... | |
Represents a set cover problem.
Allows to state which sets cover which elements and offers some helper methods to work with this set cover for the heuristics.
Definition at line 15 of file SetCover.h.
std::size_t carl::covering::SetCover::active_set_count | ( | ) | const |
Returns the number of active sets (that still cover uncovered elements).
Definition at line 44 of file SetCover.cpp.
std::size_t carl::covering::SetCover::element_count | ( | ) | const |
Returns the number of elements.
Definition at line 24 of file SetCover.cpp.
|
inline |
Returns the given set.
Definition at line 27 of file SetCover.h.
Bitset carl::covering::SetCover::get_uncovered | ( | ) | const |
Returns the uncovered elements.
Definition at line 78 of file SetCover.cpp.
std::size_t carl::covering::SetCover::largest_set | ( | ) | const |
Returns the id of the largest set.
Definition at line 50 of file SetCover.cpp.
std::size_t carl::covering::SetCover::largest_set | ( | const std::vector< double > & | weights | ) | const |
Returns the id of the largest set with respect to given weights.
Definition at line 64 of file SetCover.cpp.
void carl::covering::SetCover::prune_sets | ( | ) |
Removes empty sets.
Definition at line 32 of file SetCover.cpp.
void carl::covering::SetCover::select_set | ( | std::size_t | s | ) |
Selects the given set and purges the covered elements from all other sets.
Definition at line 86 of file SetCover.cpp.
void carl::covering::SetCover::set | ( | std::size_t | set, |
const Bitset & | elements | ||
) |
States that s covers the given elements.
Definition at line 17 of file SetCover.cpp.
void carl::covering::SetCover::set | ( | std::size_t | set, |
std::size_t | element | ||
) |
States that s covers the given element.
Definition at line 10 of file SetCover.cpp.
std::size_t carl::covering::SetCover::set_count | ( | ) | const |
Returns the number of sets.
Definition at line 40 of file SetCover.cpp.
|
friend |
Print the set cover to os.
Definition at line 94 of file SetCover.cpp.
|
private |
The actual sets.
Definition at line 20 of file SetCover.h.