15 #ifndef PAAL_AUCTION_COMPONENTS_HPP
16 #define PAAL_AUCTION_COMPONENTS_HPP
25 #include <boost/concept_check.hpp>
26 #include <boost/optional/optional.hpp>
27 #include <boost/range/concepts.hpp>
29 #include <type_traits>
30 #include <unordered_set>
50 struct get_copies_num;
79 template <
typename Auction>
81 template <
class Component>
82 using component_to_range_t =
typename std::remove_reference<
84 typename std::decay<Auction>::type>::
85 template type<Component>::type
92 using bidders_t = component_to_range_t<bidders>;
93 BOOST_CONCEPT_ASSERT((boost::SinglePassRangeConcept<bidders_t>));
96 using items_t = component_to_range_t<items>;
97 BOOST_CONCEPT_ASSERT((boost::SinglePassRangeConcept<items_t>));
103 auto copies = a.template call<get_copies_num>(
104 *std::begin(a.template get<items>()));
105 using get_copies_num_result_t =
puretype(copies);
106 static_assert(std::is_integral<get_copies_num_result_t>::value,
107 "return type of get_copies_num is not integral!");
113 auto get_item() -> decltype(*std::begin(a.template get<items>()))
115 return *std::begin(a.template get<items>());
118 auto get_bidder() -> decltype(*std::begin(a.template get<bidders>()))
120 return *std::begin(a.template get<bidders>());
124 template <
typename ValueQueryAuction>
132 auto value_query_ = this->a.template get<value_query>();
133 auto val = value_query_(this->get_bidder(), std::unordered_set<
134 typename base::item_val_t>{this->get_item()});
135 using value_query_result_t =
puretype(val);
136 static_assert(std::is_arithmetic<value_query_result_t>::value,
137 "return type of value_query is not arithmetic!");
141 template <
typename DemandQueryAuction>
146 auto demand_query_ = this->a.template get<demand_query>();
148 auto res = demand_query_(this->get_bidder(), get_price);
149 using demand_query_result_items_t = decltype(res.first);
150 BOOST_CONCEPT_ASSERT((boost::SinglePassRangeConcept<
151 demand_query_result_items_t>));
153 demand_query_result_items_t>));
154 using demand_query_result_value_t =
puretype(res.second);
155 static_assert(std::is_arithmetic<demand_query_result_value_t>::value,
156 "second member of the result from demand query oracle is not arithmetic!");
160 template <
typename GammaOracleAuction>
164 typename std::decay<GammaOracleAuction>::type>::
165 template type<gamma>::type;
166 static_assert(std::is_arithmetic<gamma_t>::value,
167 "gamma type is not arithmetic!");
171 auto gamma_oracle_ = this->a.template get<gamma_oracle>();
174 auto res = gamma_oracle_(this->get_bidder(), get_price, threshold);
177 using gamma_oracle_result_items_t = decltype(res->first);
178 BOOST_CONCEPT_ASSERT((boost::SinglePassRangeConcept<
179 gamma_oracle_result_items_t>));
181 gamma_oracle_result_items_t>));
182 using gamma_oracle_result_price_t =
puretype(res->second.num);
183 static_assert(std::is_arithmetic<gamma_oracle_result_price_t>::value,
184 "numerator of frac returned from gamma oracle is not arithmetic!");
185 using gamma_oracle_result_value_t =
puretype(res->second.den);
186 static_assert(std::is_arithmetic<gamma_oracle_result_value_t>::value,
187 "denominator of frac returned from gamma oracle is not arithmetic!");
208 template <
typename... Names>
228 template <
typename... Args>
239 template <
typename... Args>
241 decltype(value_query_components::make_components(std::forward<Args>(args)...))
243 auto res = value_query_components::make_components(std::forward<Args>(args)...);
260 template <
typename... Args>
271 template <
typename... Args>
274 auto res = demand_query_components::make_components(std::forward<Args>(args)...);
291 template <
typename... Args>
302 template <
typename... Args>
304 decltype(gamma_oracle_components::make_components(std::forward<Args>(args)...))
306 auto res = gamma_oracle_components::make_components(std::forward<Args>(args)...);
313 #endif // PAAL_AUCTION_COMPONENTS_HPP
typename boost::range_value< Range >::type range_to_elem_t
for given range returns type of its element
detail::add_to_base_auction< value_query > value_query_components
detail
typename value_query_components::type< Args...> value_query_auction_components
value query auction components template alias
typename gamma_oracle_components::type< Args...> gamma_oracle_auction_components
gamma oracle auction components template alias
typename demand_query_components::type< Args...> demand_query_auction_components
demand query auction components template alias
detail::add_to_base_auction< gamma_oracle, gamma > gamma_oracle_components
definition for the components class for a gamma oracle auction.
auto make_value_query_auction_components(Args &&...args) -> decltype(value_query_components::make_components(std::forward< Args >(args)...))
make function for value query components
#define puretype(t)
for given expression returns its type with removed const and reference
This structure can be passed on Names list and represents Name and the default type value...
This file contains set of simple useful functors or functor adapters.
typename data_structures::join< base_auction_components, data_structures::components< Names...> >::type add_to_base_auction
extend base auction components with other components.
Concept class for readable range concept.
detail::add_to_base_auction< demand_query > demand_query_components
definition for the components class for a demand query auction
auto make_demand_query_auction_components(Args &&...args)
make function for demand query components
data_structures::components< bidders, items, data_structures::NameWithDefault< get_copies_num, utils::return_one_functor > > base_auction_components
concepts
auto make_gamma_oracle_auction_components(Args &&...args) -> decltype(gamma_oracle_components::make_components(std::forward< Args >(args)...))
make function for gamma oracle components