CYCLUS
Loading...
Searching...
No Matches
bid.h
Go to the documentation of this file.
1#ifndef CYCLUS_SRC_BID_H_
2#define CYCLUS_SRC_BID_H_
3
4#include <boost/shared_ptr.hpp>
5#include <boost/weak_ptr.hpp>
6#include <limits>
7
8#include "request.h"
9#include "package.h"
10
11namespace cyclus {
12
13class Trader;
14template <class T> class BidPortfolio;
15
16/// @class Bid
17///
18/// @brief A Bid encapsulates all the information required to communicate a bid
19/// response to a request for a resource, including the resource bid and the
20/// bidder.
21template <class T> class Bid {
22 public:
23 /// @brief a factory method for a bid
24 /// @param request the request being responded to by this bid
25 /// @param offer the resource being offered in response to the request
26 /// @param bidder the bidder
27 /// @param portfolio the porftolio of which this bid is a part
28 /// @param exclusive flag for whether the bid is exclusive
29 /// @param preference specifies the preference of a bid in a request
30 /// to bid arc. If NaN the request preference is used.
31 /// WARNING: This should only be set by the bidder using the
32 /// requests callback cost function. Bidders should not
33 /// arbitrarily set this preference.
35 boost::shared_ptr<T>
36 offer,
39 bool exclusive,
40 double preference) {
42 }
43
44 /// @brief a factory method for a bid
45 /// @param request the request being responded to by this bid
46 /// @param offer the resource being offered in response to the request
47 /// @param bidder the bidder
48 /// @param portfolio the porftolio of which this bid is a part
49 /// @param exclusive flag for whether the bid is exclusive
51 boost::shared_ptr<T>
52 offer,
55 bool exclusive = false,
58 std::numeric_limits<double>::quiet_NaN(), package);
59 }
60 /// @brief a factory method for a bid for a bid without a portfolio
61 /// @warning this factory should generally only be used for testing
62 inline static Bid<T>* Create(Request<T>* request, boost::shared_ptr<T> offer,
63 Trader* bidder, bool exclusive,
64 double preference,
67 }
68 /// @brief a factory method for a bid for a bid without a portfolio
69 /// @warning this factory should generally only be used for testing
70 inline static Bid<T>* Create(Request<T>* request, boost::shared_ptr<T> offer,
71 Trader* bidder, bool exclusive = false,
74 std::numeric_limits<double>::quiet_NaN(), package);
75 }
76
77 /// @return the request being responded to
78 inline Request<T>* request() const { return request_; }
79
80 /// @return the bid object for the request
81 inline boost::shared_ptr<T> offer() const { return offer_; }
82
83 /// @return the agent responding the request
84 inline Trader* bidder() const { return bidder_; }
85
86 /// @return the portfolio of which this bid is a part
87 inline typename BidPortfolio<T>::Ptr portfolio() { return portfolio_.lock(); }
88
89 /// @return whether or not this an exclusive bid
90 inline bool exclusive() const { return exclusive_; }
91
92 /// @return the preference of this bid
93 inline double preference() const { return preference_; }
94
95 private:
96 /// @brief constructors are private to require use of factory methods
97 Bid(Request<T>* request, boost::shared_ptr<T> offer, Trader* bidder,
98 bool exclusive, double preference,
100 : request_(request),
101 offer_(offer),
102 bidder_(bidder),
103 exclusive_(exclusive),
104 preference_(preference),
105 package_(package) {}
106 /// @brief constructors are private to require use of factory methods
107 Bid(Request<T>* request, boost::shared_ptr<T> offer, Trader* bidder,
109 : request_(request),
110 offer_(offer),
111 bidder_(bidder),
112 exclusive_(exclusive),
113 preference_(std::numeric_limits<double>::quiet_NaN()),
114 package_(package) {}
115
116 Bid(Request<T>* request, boost::shared_ptr<T> offer, Trader* bidder,
117 typename BidPortfolio<T>::Ptr portfolio, bool exclusive, double preference,
119 : request_(request),
120 offer_(offer),
121 bidder_(bidder),
122 portfolio_(portfolio),
123 exclusive_(exclusive),
124 preference_(preference),
125 package_(package) {}
126
127 Bid(Request<T>* request, boost::shared_ptr<T> offer, Trader* bidder,
128 typename BidPortfolio<T>::Ptr portfolio, bool exclusive = false,
130 : request_(request),
131 offer_(offer),
132 bidder_(bidder),
133 portfolio_(portfolio),
134 exclusive_(exclusive),
135 preference_(std::numeric_limits<double>::quiet_NaN()),
136 package_(package) {}
137
138 Request<T>* request_;
139 boost::shared_ptr<T> offer_;
140 Trader* bidder_;
141 boost::weak_ptr<BidPortfolio<T>> portfolio_;
142 bool exclusive_;
143 double preference_;
144 Package::Ptr package_;
145};
146
147} // namespace cyclus
148#endif // CYCLUS_SRC_BID_H_
boost::shared_ptr< BidPortfolio< T > > Ptr
A Bid encapsulates all the information required to communicate a bid response to a request for a reso...
Definition bid.h:21
Request< T > * request() const
Definition bid.h:78
double preference() const
Definition bid.h:93
static Bid< T > * Create(Request< T > *request, boost::shared_ptr< T > offer, Trader *bidder, typename BidPortfolio< T >::Ptr portfolio, bool exclusive=false, Package::Ptr package=Package::unpackaged())
a factory method for a bid
Definition bid.h:50
static Bid< T > * Create(Request< T > *request, boost::shared_ptr< T > offer, Trader *bidder, bool exclusive, double preference, Package::Ptr package=Package::unpackaged())
a factory method for a bid for a bid without a portfolio
Definition bid.h:62
static Bid< T > * Create(Request< T > *request, boost::shared_ptr< T > offer, Trader *bidder, bool exclusive=false, Package::Ptr package=Package::unpackaged())
a factory method for a bid for a bid without a portfolio
Definition bid.h:70
bool exclusive() const
Definition bid.h:90
BidPortfolio< T >::Ptr portfolio()
Definition bid.h:87
boost::shared_ptr< T > offer() const
Definition bid.h:81
static Bid< T > * Create(Request< T > *request, boost::shared_ptr< T > offer, Trader *bidder, typename BidPortfolio< T >::Ptr portfolio, bool exclusive, double preference)
a factory method for a bid
Definition bid.h:34
Trader * bidder() const
Definition bid.h:84
static Ptr & unpackaged()
Definition package.cc:24
boost::shared_ptr< Package > Ptr
Definition package.h:21
A Request encapsulates all the information required to communicate the needs of an agent in the Dynam...
Definition request.h:29
A simple API for agents that wish to exchange resources in the simulation.
Definition trader.h:24
taken directly from OsiSolverInterface.cpp on 2/17/14 from https://projects.coin-or....
Definition agent.cc:14
T OptionalQuery(InfileTree *tree, std::string query, T default_val)
a query method for optional parameters