carl  24.04
Computer ARithmetic Library
remove_duplicates.cpp
Go to the documentation of this file.
1 #include "remove_duplicates.h"
2 
4 
5 #include <algorithm>
6 
8 
10  std::vector<Bitset> columns;
11  for (std::size_t i = 0; i < sc.set_count(); ++i) {
12  const auto& set = sc.get_set(i);
13  while (columns.size() < set.size()) {
14  columns.emplace_back();
15  }
16  for (std::size_t elem: set) {
17  columns[elem].set(i);
18  }
19  }
20  std::sort(columns.begin(), columns.end());
21  columns.erase(std::unique(columns.begin(), columns.end()), columns.end());
22  SetCover newsc;
23  for (std::size_t i = 0; i < columns.size(); ++i) {
24  for (std::size_t s: columns[i]) {
25  newsc.set(s, i);
26  }
27  }
28  sc = newsc;
29  return Bitset();
30 }
31 
32 }
Bitset remove_duplicates(SetCover &sc)
Preprocessing heuristic: Compresses the matrix by removing duplicate columns.
This class is a simple wrapper around boost::dynamic_bitset.
Definition: Bitset.h:20
Represents a set cover problem.
Definition: SetCover.h:15
const auto & get_set(std::size_t set) const
Returns the given set.
Definition: SetCover.h:27
std::size_t set_count() const
Returns the number of sets.
Definition: SetCover.cpp:40
void set(std::size_t set, std::size_t element)
States that s covers the given element.
Definition: SetCover.cpp:10