CYCLUS
Public Member Functions | List of all members
cyclus::toolkit::MatlSellPolicy Class Reference

Detailed Description

MatlSellPolicy performs semi-automatic inventory management of a material buffer by making offers and trading away materials in an attempt to empty the buffer's inventory every time step.

For simple behavior, policies virtually eliminate the need to write any code for resource exchange. Just assign a few policies to work with a few buffers and focus on writing the physics and other behvavior of your agent. Typical usage goes something like this:

class YourAgent : public Facility {
public:
...
void EnterNotify() {
Facility::EnterNotify(); // always do this first
policy_.Init(this, &outbuf_, "outbuf-label").Set(outcommod).Start();
}
...
private:
MatlSellPolicy policy_;
ResBuf<Material> outbuf_;
...
}

The policy needs to be initialized with its owning agent and the material buffer that is is managing. It also needs to be activated by calling the Start function for it to begin participation in resource exchange. And don't forget to add some commodities to offer on by calling Set. All policy configuration should usually occur in the agent's EnterNotify member function.

When a policy's managing agent is deallocated, you MUST either call the policy's Stop function or delete the policy. Otherwise SEGFAULT.

Definition at line 51 of file matl_sell_policy.h.

#include <matl_sell_policy.h>

Inheritance diagram for cyclus::toolkit::MatlSellPolicy:
cyclus::Trader

Public Member Functions

bool Excl () const
 
double Limit () const
 
 MatlSellPolicy ()
 
MatlSellPolicySet (std::string commod)
 
void Start ()
 
void Stop ()
 
virtual ~MatlSellPolicy ()
 
MatlSellPolicyInit (Agent *manager, ResBuf< Material > *buf, std::string name)
 
MatlSellPolicyInit (Agent *manager, ResBuf< Material > *buf, std::string name, double throughput)
 
MatlSellPolicyInit (Agent *manager, ResBuf< Material > *buf, std::string name, bool ignore_comp)
 
MatlSellPolicyInit (Agent *manager, ResBuf< Material > *buf, std::string name, double throughput, bool ignore_comp)
 
MatlSellPolicyInit (Agent *manager, ResBuf< Material > *buf, std::string name, double throughput, bool ignore_comp, double quantize)
 
- Public Member Functions inherited from cyclus::Trader
virtual void AcceptMatlTrades (const std::vector< std::pair< Trade< Material >, Material::Ptr > > &responses)
 
virtual void AcceptProductTrades (const std::vector< std::pair< Trade< Product >, Product::Ptr > > &responses)
 
virtual void AdjustMatlPrefs (PrefMap< Material >::type &prefs)
 
virtual void AdjustProductPrefs (PrefMap< Product >::type &prefs)
 
virtual std::set< RequestPortfolio< Material >::Ptr > GetMatlRequests ()
 
virtual std::set< BidPortfolio< Product >::Ptr > GetProductBids (CommodMap< Product >::type &commod_requests)
 
virtual std::set< RequestPortfolio< Product >::Ptr > GetProductRequests ()
 
virtual void GetProductTrades (const std::vector< Trade< Product > > &trades, std::vector< std::pair< Trade< Product >, Product::Ptr > > &responses)
 
virtual Agentmanager ()
 
 Trader (Agent *manager)
 
virtual std::set< BidPortfolio< Material >::Ptr > GetMatlBids (CommodMap< Material >::type &commod_requests)
 
virtual void GetMatlTrades (const std::vector< Trade< Material > > &trades, std::vector< std::pair< Trade< Material >, Material::Ptr > > &responses)
 

Additional Inherited Members

- Protected Attributes inherited from cyclus::Trader
Agentmanager_
 

Constructor & Destructor Documentation

cyclus::toolkit::MatlSellPolicy::MatlSellPolicy ( )

Creates an uninitialized policy.

The Init function MUST be called before anything else is done with the policy.

Definition at line 14 of file matl_sell_policy.cc.

cyclus::toolkit::MatlSellPolicy::~MatlSellPolicy ( )
virtual

Definition at line 24 of file matl_sell_policy.cc.

Member Function Documentation

bool cyclus::toolkit::MatlSellPolicy::Excl ( ) const
inline

whether trades will be denoted as exclusive or not

Definition at line 112 of file matl_sell_policy.h.

std::set< BidPortfolio< Material >::Ptr > cyclus::toolkit::MatlSellPolicy::GetMatlBids ( CommodMap< Material >::type &  commod_requests)
virtual

Trader Methods.

Reimplemented from cyclus::Trader.

Definition at line 123 of file matl_sell_policy.cc.

void cyclus::toolkit::MatlSellPolicy::GetMatlTrades ( const std::vector< Trade< Material > > &  trades,
std::vector< std::pair< Trade< Material >, Material::Ptr > > &  responses 
)
virtual

default implementation for responding to material trades

Parameters
tradesall trades in which this trader is the supplier
responsesa container to populate with responses to each trade

Reimplemented from cyclus::Trader.

Definition at line 171 of file matl_sell_policy.cc.

MatlSellPolicy & cyclus::toolkit::MatlSellPolicy::Init ( Agent manager,
ResBuf< Material > *  buf,
std::string  name 
)

Configures the policy to keep buf empty every time step by offering away as much material as possible.

If quantize is greater than zero, the policy will make exclusive, integral quantize kg offers. Otherwise, a single offer will be sent each time step to empty the buffer's entire inventory.

Parameters
managerthe agent
bufthe resource buffer
namea unique name identifying this policy
throughputa maximum throughput per time step for material leaving buf ignore the composition of material in buf. When making bids, requested material compositions will be used. When making trades, material in the buffer will have its composition transmuted to match the requested material.
quantizeIf quantize is greater than zero, the policy will make exclusive, integral quantize kg bids. Otherwise, single bids will be sent matching the requested quantity.

Definition at line 43 of file matl_sell_policy.cc.

MatlSellPolicy & cyclus::toolkit::MatlSellPolicy::Init ( Agent manager,
ResBuf< Material > *  buf,
std::string  name,
double  throughput 
)

Definition at line 51 of file matl_sell_policy.cc.

MatlSellPolicy & cyclus::toolkit::MatlSellPolicy::Init ( Agent manager,
ResBuf< Material > *  buf,
std::string  name,
bool  ignore_comp 
)

Definition at line 60 of file matl_sell_policy.cc.

MatlSellPolicy & cyclus::toolkit::MatlSellPolicy::Init ( Agent manager,
ResBuf< Material > *  buf,
std::string  name,
double  throughput,
bool  ignore_comp 
)

Definition at line 69 of file matl_sell_policy.cc.

MatlSellPolicy & cyclus::toolkit::MatlSellPolicy::Init ( Agent manager,
ResBuf< Material > *  buf,
std::string  name,
double  throughput,
bool  ignore_comp,
double  quantize 
)

Definition at line 80 of file matl_sell_policy.cc.

double cyclus::toolkit::MatlSellPolicy::Limit ( ) const

the current (total) limit on transactions, i.e., the quantity of resources that can be transacted in a time step

Definition at line 116 of file matl_sell_policy.cc.

MatlSellPolicy & cyclus::toolkit::MatlSellPolicy::Set ( std::string  commod)

Instructs the policy to empty its buffer with offers on the given commodity.

This must be called at least once or the policy will do nothing. The policy can offer on an arbitrary number of commodities by calling Set multiple times.

Definition at line 92 of file matl_sell_policy.cc.

void cyclus::toolkit::MatlSellPolicy::Start ( )

Registers this policy as a trader in the current simulation.

This function must be called for the policy to begin participating in resource exchange. Init MUST be called prior to calling this function. Start is idempotent.

Definition at line 97 of file matl_sell_policy.cc.

void cyclus::toolkit::MatlSellPolicy::Stop ( )

Unregisters this policy as a trader in the current simulation.

This function need only be called if a policy is to be stopped during a simulation (it is not required to be called explicitly at the end). Stop is idempotent.

Definition at line 106 of file matl_sell_policy.cc.


The documentation for this class was generated from the following files: