1 #ifndef CYCLUS_SRC_RESOURCE_EXCHANGE_H_ 2 #define CYCLUS_SRC_RESOURCE_EXCHANGE_H_ 97 std::set<Trader*> traders = ex_ctx_.requesters;
108 inline bool Empty() {
return ex_ctx_.bids_by_request.empty(); }
112 if (traders_.size() == 0) {
113 std::set<Trader*> orig = sim_ctx_->
traders();
114 std::set<Trader*>::iterator it;
115 for (it = orig.begin(); it != orig.end(); ++it) {
116 traders_.insert(*it);
122 void AddRequests_(
Trader* t) {
123 std::set<typename RequestPortfolio<T>::Ptr> rp = QueryRequests<T>(t);
124 typename std::set<typename RequestPortfolio<T>::Ptr>::iterator it;
125 for (it = rp.begin(); it != rp.end(); ++it) {
126 ex_ctx_.AddRequestPortfolio(*it);
131 void AddBids_(
Trader* t) {
132 std::set<typename BidPortfolio<T>::Ptr> bp =
133 QueryBids<T>(t, ex_ctx_.commod_requests);
134 typename std::set<typename BidPortfolio<T>::Ptr>::iterator it;
135 for (it = bp.begin(); it != bp.end(); ++it) {
136 ex_ctx_.AddBidPortfolio(*it);
142 void AdjustPrefs_(
Trader* t) {
152 struct trader_compare {
168 std::set<Trader*, trader_compare> traders_;
176 #endif // CYCLUS_SRC_RESOURCE_EXCHANGE_H_ const std::set< Trader * > & traders() const
The ResourceExchange class manages the communication for the supply and demand of resources in a simu...
ExchangeContext< T > & ex_ctx()
static void AdjustPrefs(Agent *m, typename PrefMap< T >::type &prefs)
Preference adjustment method helpers to convert from templates to the Agent inheritance hierarchy...
bool Empty()
return true if this is an empty exchange (i.e., no requests exist, therefore no bids) ...
virtual const int id() const
The agent instance's unique ID within a simulation.
ResourceExchange(Context *ctx)
default constructor
A simple API for agents that wish to exchange resources in the simulation.
The ExchangeContext is designed to provide an ease-of-use interface for querying and reaggregating in...
void AddAllRequests()
queries traders and collects all requests for bids
std::map< Request< T > *, std::map< Bid< T > *, double > > type
virtual void AdjustMatlPrefs(PrefMap< Material >::type &prefs)
default implementation for material preferences.
virtual Agent * manager()
void AddAllBids()
queries traders and collects all responses to requests for bids
void AdjustAll()
adjust preferences for requests given bid responses
virtual void AdjustProductPrefs(PrefMap< Product >::type &prefs)
default implementation for material preferences.
virtual void AdjustProductPrefs(PrefMap< Product >::type &prefs)
default implementation for material preferences.
Agent * parent() const
Returns parent of this agent. Returns NULL if the agent has no parent.
A simulation context provides access to necessary simulation-global functions and state...
The abstract base class used by all types of agents that live and interact in a simulation.
taken directly from OsiSolverInterface.cpp on 2/17/14 from https://projects.coin-or.org/Osi/browser/trunk.
virtual void AdjustMatlPrefs(PrefMap< Material >::type &prefs)
default implementation for material preferences.