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;
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())
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) {
100 Request<T>* r =
b->request();
102 std::stringstream ss;
103 ss << ctx_->
time() <<
"_" <<
b->request();
105 ->
AddVal(
"ReqId", ss.str())
106 ->AddVal(
"BidderId",
b->bidder()->manager()->id())
107 ->AddVal(
"BidQuantity",
b->offer()->quantity())
108 ->AddVal(
"Exclusive",
b->exclusive())
109 ->AddVal(
"Preference", pref)
a holding class for information related to a TradeExecutor
virtual const int id() const
The agent instance's unique ID within a simulation.
A simulation context provides access to necessary simulation-global functions and state.
Datum * NewDatum(std::string title)
See Recorder::NewDatum documentation.
ExchangeSolver * solver()
Returns the exchange solver associated with this context.
virtual int time()
Returns the current simulation timestep.
Datum * AddVal(const char *field, boost::spirit::hold_any val, std::vector< int > *shape=NULL)
Add an arbitrary field-value pair to the datum.
void Record()
Record this datum to its Recorder.
static std::string GetEnv(std::string var)
Method to check the existence of and return an environment variable.
boost::shared_ptr< ExchangeGraph > Ptr
The ExchangeManager is designed to house all of the internals involved in executing a resource exchan...
ExchangeManager(Context *ctx)
void Execute()
execute the full resource sequence
double Solve(ExchangeGraph *graph=NULL)
interface for solving a given exchange graph
An ExchangeTranslator facilitates translation from a resource specific exchange to a resource-neutral...
void BackTranslateSolution(const std::vector< Match > &matches, std::vector< Trade< T > > &ret)
Provide a vector of Trades given a vector of Matches.
ExchangeGraph::Ptr Translate()
translate the ExchangeContext into an ExchangeGraph
A Request encapsulates all the information required to communicate the needs of an agent in the Dynam...
std::string commodity() const
boost::shared_ptr< T > target() const
double preference() const
Trader * requester() const
The ResourceExchange class manages the communication for the supply and demand of resources in a simu...
void AdjustAll()
adjust preferences for requests given bid responses
void AddAllBids()
queries traders and collects all responses to requests for bids
bool Empty()
return true if this is an empty exchange (i.e., no requests exist, therefore no bids)
void AddAllRequests()
queries traders and collects all requests for bids
ExchangeContext< T > & ex_ctx()
The TradeExecutor is an object whose task is to execute a collection of Trades.
void ExecuteTrades()
execute all trades, collecting responders from bidders and sending responses to requesters
virtual Agent * manager()
taken directly from OsiSolverInterface.cpp on 2/17/14 from https://projects.coin-or....
@ LEV_DEBUG1
debugging information - least verbose
double b(int nuc)
Computes the scattering length [cm] from the coherent and incoherent components.
The ExchangeContext is designed to provide an ease-of-use interface for querying and reaggregating in...
std::vector< typename BidPortfolio< T >::Ptr > bids
a reference to an exchange's set of bids
std::map< Trader *, typename PrefMap< T >::type > trader_prefs
maps commodity name to requests for that commodity
std::vector< typename RequestPortfolio< T >::Ptr > requests
a reference to an exchange's set of requests