20 #include <boost/function_output_iterator.hpp>
21 #include <boost/range/algorithm/copy.hpp>
28 #include <unordered_map>
29 #include <unordered_set>
36 using Bidder = std::string;
37 using Item = std::string;
38 using Items = std::unordered_set<Item>;
39 using Value =
long double;
40 using Bid = std::pair<Items, Value>;
41 using Bids = std::vector<Bid>;
42 using Assignment = std::tuple<Bidder, Items, double>;
45 const std::unordered_map<Bidder, Bids> bids {
47 {{
"lemon",
"orange"}, 1},
48 {{
"apple",
"ball"}, 1},
51 {{
"lemon",
"apple"}, 1},
52 {{
"orange",
"ball"}, 1},
55 const std::vector<Bidder> bidders {
"John",
"Bob"};
56 const std::vector<Item> items {
"apple",
"ball",
"orange",
"lemon"};
57 auto get_bids = [&](
const Bidder& bidder) ->
const Bids& {
return bids.at(bidder); };
58 auto get_value = [](
const Bid& bid) {
return bid.second; };
59 auto get_items = [](
const Bid& bid) ->
const Items& {
return bid.first; };
61 bidders, items, get_bids, get_value, get_items
65 Value social_welfare = 0;
67 std::move(bidders), std::move(items), get_bids, get_value, get_items
71 boost::make_function_output_iterator([&](Assignment a)
73 auto bidder = std::get<0>(a);
74 auto& cur_items = std::get<1>(a);
75 auto fraction = std::get<2>(a);
76 social_welfare += fraction * valuation.call<paal::auctions::value_query>(bidder, cur_items);
77 std::cout << bidder <<
" got a fraction " << fraction <<
" of bundle: ";
78 boost::copy(cur_items, std::ostream_iterator<Item>(std::cout,
", "));
79 std::cout << std::endl;
82 std::cout <<
"social welfare: " << social_welfare << std::endl;
int main()
[Fractional Winner Determination in MUCA Example]
void fractional_determine_winners_in_demand_query_auction(DemandQueryAuction &&auction, OutputIterator result, ItemToLpIdMap item_to_id, double epsilon, SeparationOracle separation_oracle=SeparationOracle{})
detail
auto make_xor_bids_to_demand_query_auction(Bidders &&bidders, Items &&items, GetBids get_bids, GetValue get_value, GetItems get_items, GetCopiesNum get_copies_num=GetCopiesNum{})
detail
auto make_xor_bids_to_value_query_auction(Bidders &&bidders, Items &&items, GetBids get_bids, GetValue get_value, GetItems get_items, GetCopiesNum get_copies_num=GetCopiesNum{}) -> decltype(make_value_query_auction_components(std::forward< Bidders >(bidders), std::forward< Items >(items), detail::xor_bids_value_query< GetBids, GetValue, GetItems >(get_bids, get_value, get_items), get_copies_num))
detail
std::string Bidder
[Demand Query Auction Components Example]
Interfaces for creating auctions from xor bids valuations.