CYCLUS
Loading...
Searching...
No Matches
trader.h
Go to the documentation of this file.
1#ifndef CYCLUS_SRC_TRADER_H_
2#define CYCLUS_SRC_TRADER_H_
3
4#include <set>
5
6#include "bid_portfolio.h"
7#include "composition.h"
8#include "exchange_context.h"
9#include "product.h"
10#include "material.h"
11#include "request_portfolio.h"
12#include "trade.h"
13
14namespace cyclus {
15
16/// @class Trader
17///
18/// @brief A simple API for agents that wish to exchange resources in the
19/// simulation
20///
21/// A Trader is a mixin class designed for agents that wish to exchange
22/// resources. It defines the API for the querying of requests, offers, and the
23/// corresponding exchanges.
24class Trader {
25 public:
27
28 virtual Agent* manager() { return manager_; }
29
30 /// @brief default implementation for material requests
31 virtual std::set<RequestPortfolio<Material>::Ptr> GetMatlRequests() {
32 return std::set<RequestPortfolio<Material>::Ptr>();
33 }
34
35 /// @brief default implementation for product requests
36 virtual std::set<RequestPortfolio<Product>::Ptr> GetProductRequests() {
37 return std::set<RequestPortfolio<Product>::Ptr>();
38 }
39
40 /// @brief default implementation for material requests
41 virtual std::set<BidPortfolio<Material>::Ptr> GetMatlBids(
42 CommodMap<Material>::type& commod_requests) {
43 return std::set<BidPortfolio<Material>::Ptr>();
44 }
45
46 /// @brief default implementation for product requests
47 virtual std::set<BidPortfolio<Product>::Ptr> GetProductBids(
48 CommodMap<Product>::type& commod_requests) {
49 return std::set<BidPortfolio<Product>::Ptr>();
50 }
51
52 /// default implementation for material preferences.
54
55 /// default implementation for material preferences.
57
58 /// @brief default implementation for responding to material trades
59 /// @param trades all trades in which this trader is the supplier
60 /// @param responses a container to populate with responses to each trade
61 virtual void GetMatlTrades(
62 const std::vector<Trade<Material>>& trades,
63 std::vector<std::pair<Trade<Material>, Material::Ptr>>& responses) {}
64
65 /// @brief default implementation for responding to product trades
66 /// @param trades all trades in which this trader is the supplier
67 /// @param responses a container to populate with responses to each trade
68 virtual void GetProductTrades(
69 const std::vector<Trade<Product>>& trades,
70 std::vector<std::pair<Trade<Product>, Product::Ptr>>& responses) {}
71
72 /// @brief default implementation for material trade acceptance
73 virtual void AcceptMatlTrades(
74 const std::vector<std::pair<Trade<Material>, Material::Ptr>>& responses) {
75 }
76
77 /// @brief default implementation for product trade acceptance
78 virtual void AcceptProductTrades(
79 const std::vector<std::pair<Trade<Product>, Product::Ptr>>& responses) {}
80
81 protected:
83
84 private:
85 /// @warning this function is hidden to prevent an invalid signature that can
86 /// raise difficult to find bugs
87 virtual std::set<BidPortfolio<Material>::Ptr> GetMatlBids(
88 const CommodMap<Material>::type& commod_requests) {
89 return std::set<BidPortfolio<Material>::Ptr>();
90 }
91
92 /// @warning this function is hidden to prevent an invalid signature that can
93 /// raise difficult to find bugs
94 virtual std::set<BidPortfolio<Product>::Ptr> GetProductBids(
95 const CommodMap<Product>::type& commod_requests) {
96 return std::set<BidPortfolio<Product>::Ptr>();
97 }
98};
99
100} // namespace cyclus
101
102#endif // CYCLUS_SRC_TRADER_H_
The abstract base class used by all types of agents that live and interact in a simulation.
Definition agent.h:50
boost::shared_ptr< Material > Ptr
Definition material.h:75
boost::shared_ptr< Product > Ptr
Definition product.h:23
virtual void AcceptMatlTrades(const std::vector< std::pair< Trade< Material >, Material::Ptr > > &responses)
default implementation for material trade acceptance
Definition trader.h:73
Trader(Agent *manager)
Definition trader.h:26
Agent * manager_
Definition trader.h:82
virtual void AdjustMatlPrefs(PrefMap< Material >::type &prefs)
default implementation for material preferences.
Definition trader.h:53
virtual void GetProductTrades(const std::vector< Trade< Product > > &trades, std::vector< std::pair< Trade< Product >, Product::Ptr > > &responses)
default implementation for responding to product trades
Definition trader.h:68
virtual std::set< BidPortfolio< Product >::Ptr > GetProductBids(CommodMap< Product >::type &commod_requests)
default implementation for product requests
Definition trader.h:47
virtual void GetMatlTrades(const std::vector< Trade< Material > > &trades, std::vector< std::pair< Trade< Material >, Material::Ptr > > &responses)
default implementation for responding to material trades
Definition trader.h:61
virtual std::set< BidPortfolio< Material >::Ptr > GetMatlBids(CommodMap< Material >::type &commod_requests)
default implementation for material requests
Definition trader.h:41
virtual void AdjustProductPrefs(PrefMap< Product >::type &prefs)
default implementation for material preferences.
Definition trader.h:56
virtual Agent * manager()
Definition trader.h:28
virtual void AcceptProductTrades(const std::vector< std::pair< Trade< Product >, Product::Ptr > > &responses)
default implementation for product trade acceptance
Definition trader.h:78
virtual std::set< RequestPortfolio< Product >::Ptr > GetProductRequests()
default implementation for product requests
Definition trader.h:36
virtual std::set< RequestPortfolio< Material >::Ptr > GetMatlRequests()
default implementation for material requests
Definition trader.h:31
taken directly from OsiSolverInterface.cpp on 2/17/14 from https://projects.coin-or....
Definition agent.cc:14
std::map< std::string, std::vector< Request< T > * > > type
std::map< Request< T > *, std::map< Bid< T > *, double > > type
A Trade is a simple container that associates a request for a resource with a bid for that resource.
Definition trade.h:15