All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Macros Pages
budgeted_maximum_coverage_example.cpp
Go to the documentation of this file.
1 
9 #include <iostream>
11 #include <vector>
12 #include <iterator>
13 
14 #include <boost/range/irange.hpp>
16 
17 int main() {
18  std::vector<std::vector<int>> set_to_elements = {
19  { 1 }, { 2 }, { 0, 1 }, { 2, 3, 4 }
20  };
21  std::vector<int> set_to_cost = { 1, 1, 5, 5 };
22  std::vector<int> element_to_weight = { 3, 5, 1, 1, 1 };
23  const int BUDGET = 10;
24  auto sets = boost::irange(0, 4);
25  std::vector<int> result;
26  auto element_index = [](int el){return el;};
28  sets,
29  [&](int set){return set_to_cost[set];},
30  [&](int set){return set_to_elements[set];},
31  back_inserter(result),
32  element_index,
33  BUDGET,
34  [&](int el){return element_to_weight[el];});
35  std::cout << "Covered: " << covered << std::endl;
36 }
int main()
[Budgeted Maximum Coverage Example]
auto budgeted_maximum_coverage(SetRange &&sets, GetCostOfSet set_to_cost, GetElementsOfSet set_to_elements, OutputIterator result, ElementIndex get_el_index, Budget budget, GetWeightOfElement element_to_weight=GetWeightOfElement(), const unsigned int initial_set_size=3)
detail
auto irange(T begin, T end)
irange
Definition: irange.hpp:22