1 #ifndef CYCLUS_SRC_EXCHANGE_MANAGER_H_ 2 #define CYCLUS_SRC_EXCHANGE_MANAGER_H_ 31 debug_ =
Env::GetEnv(
"CYCLUS_DEBUG_DRE").size() > 0;
44 RecordDebugInfo(exchng.
ex_ctx());
61 std::vector< Trade<T> > trades;
62 xlator.BackTranslateSolution(graph->matches(), trades);
72 typename std::vector<typename RequestPortfolio<T>::Ptr>::iterator it;
74 std::vector<Request<T>*> reqs = (*it)->requests();
75 typename std::vector<Request<T>*>::iterator it2;
76 for (it2 = reqs.begin(); it2 != reqs.end(); ++it2) {
79 ss << ctx_->
time() <<
"_" << r;
82 ->AddVal(
"ReqId", ss.str())
83 ->AddVal(
"RequesterID", r->
requester()->manager()->id())
87 ->AddVal(
"ResType", r->
target()->type())
88 ->AddVal(
"Quantity", r->
target()->quantity())
89 ->AddVal(
"ResUnits", r->
target()->units())
94 typename std::vector<typename BidPortfolio<T>::Ptr>::iterator it3;
95 for (it3 = exctx.
bids.begin(); it3 != exctx.
bids.end(); ++it3) {
96 std::set<Bid<T>*> bids = (*it3)->bids();
97 typename std::set<Bid<T>*>::iterator it4;
98 for (it4 = bids.begin(); it4 != bids.end(); ++it4) {
102 std::stringstream ss;
105 ->
AddVal(
"ReqId", ss.str())
106 ->AddVal(
"BidderId", b->
bidder()->manager()->id())
107 ->AddVal(
"BidQuantity", b->
offer()->quantity())
109 ->AddVal(
"Preference", pref)
121 #endif // CYCLUS_SRC_EXCHANGE_MANAGER_H_ std::map< Trader *, typename PrefMap< T >::type > trader_prefs
maps commodity name to requests for that commodity
std::string commodity() const
The ResourceExchange class manages the communication for the supply and demand of resources in a simu...
std::vector< typename RequestPortfolio< T >::Ptr > requests
a reference to an exchange's set of requests
double b(int nuc)
Computes the scattering length [cm] from the coherent and incoherent components.
ExchangeContext< T > & ex_ctx()
The TradeExecutor is an object whose task is to execute a collection of Trades.
boost::shared_ptr< T > target() const
bool Empty()
return true if this is an empty exchange (i.e., no requests exist, therefore no bids) ...
The ExchangeManager is designed to house all of the internals involved in executing a resource exchan...
void ExecuteTrades()
execute all trades, collecting responders from bidders and sending responses to requesters ...
The ExchangeContext is designed to provide an ease-of-use interface for querying and reaggregating in...
boost::shared_ptr< T > offer() const
double Solve(ExchangeGraph *graph=NULL)
interface for solving a given exchange graph
void AddAllRequests()
queries traders and collects all requests for bids
std::vector< typename BidPortfolio< T >::Ptr > bids
a reference to an exchange's set of bids
boost::shared_ptr< ExchangeGraph > Ptr
virtual int time()
Returns the current simulation timestep.
void AddAllBids()
queries traders and collects all responses to requests for bids
A Bid encapsulates all the information required to communicate a bid response to a request for a reso...
static std::string GetEnv(std::string var)
Method to check the existence of and return an environment variable.
void AdjustAll()
adjust preferences for requests given bid responses
double preference() const
Datum * AddVal(const char *field, boost::spirit::hold_any val, std::vector< int > *shape=NULL)
Add an arbitrary field-value pair to the datum.
Trader * requester() const
ExchangeManager(Context *ctx)
void Execute()
execute the full resource sequence
A simulation context provides access to necessary simulation-global functions and state...
taken directly from OsiSolverInterface.cpp on 2/17/14 from https://projects.coin-or.org/Osi/browser/trunk.
debugging information - least verbose
void Record()
Record this datum to its Recorder.
An ExchangeTranslator facilitates translation from a resource specific exchange to a resource-neutral...
ExchangeSolver * solver()
Returns the exchange solver associated with this context.
Request< T > * request() const
Datum * NewDatum(std::string title)
See Recorder::NewDatum documentation.
A Request encapsulates all the information required to communicate the needs of an agent in the Dynam...