23 using Objects = std::vector<std::pair<int, int>>;
24 Objects objects{ { 1, 3 }, { 2, 2 }, { 3, 65 }, { 1, 1 }, { 2, 2 },
25 { 4, 3 }, { 1, 1 }, { 10, 23 } };
26 const int capacity = 6;
27 auto size = [](std::pair<int, int> object) {
return object.first; }
29 auto value = [](std::pair<int, int> object) {
return object.second; }
34 std::cout <<
"Knapsack unbounded FPTAS on value" << std::endl;
36 double epsilon = 1. / 4.;
37 auto maxValue = paal::knapsack_0_1_on_value_fptas(
38 epsilon, objects, capacity, std::back_inserter(result), size, value);
40 std::cout <<
"Max value " << maxValue.first <<
", Total size "
41 << maxValue.second << std::endl;
42 for (
auto o : result) {
43 std::cout <<
"{ size = " << o.first <<
", value = " << o.second <<
"} ";
45 std::cout << std::endl;
int main()
[Knapsack Example]