CYCLUS
Loading...
Searching...
No Matches
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_;
...
}
The Facility class is the abstract class/interface used by all facility agents.
Definition facility.h:68
MatlSellPolicy performs semi-automatic inventory management of a material buffer by making offers and...
ResBuf is a helper class that provides semi-automated management of a collection of resources (e....
Definition res_buf.h:62
T OptionalQuery(InfileTree *tree, std::string query, T default_val)
a query method for optional parameters

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.

@warn 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 52 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, std::string package_name=Package::unpackaged_name(), std::string transport_unit_name=TransportUnit::unrestricted_name())
 
- 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

◆ MatlSellPolicy()

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 15 of file matl_sell_policy.cc.

◆ ~MatlSellPolicy()

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

Definition at line 27 of file matl_sell_policy.cc.

Member Function Documentation

◆ Excl()

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

whether trades will be denoted as exclusive or not

Definition at line 115 of file matl_sell_policy.h.

◆ GetMatlBids()

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

Trader Methods.

Reimplemented from cyclus::Trader.

Definition at line 177 of file matl_sell_policy.cc.

◆ GetMatlTrades()

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 245 of file matl_sell_policy.cc.

◆ Init() [1/5]

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_comp 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 93 of file matl_sell_policy.cc.

◆ Init() [2/5]

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

Definition at line 110 of file matl_sell_policy.cc.

◆ Init() [3/5]

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

Definition at line 101 of file matl_sell_policy.cc.

◆ Init() [4/5]

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

Definition at line 119 of file matl_sell_policy.cc.

◆ Init() [5/5]

MatlSellPolicy & cyclus::toolkit::MatlSellPolicy::Init ( Agent * manager,
ResBuf< Material > * buf,
std::string name,
double throughput,
bool ignore_comp,
double quantize,
std::string package_name = Package::unpackaged_name(),
std::string transport_unit_name = TransportUnit::unrestricted_name() )

Definition at line 130 of file matl_sell_policy.cc.

◆ Limit()

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 170 of file matl_sell_policy.cc.

◆ Set()

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 146 of file matl_sell_policy.cc.

◆ Start()

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 151 of file matl_sell_policy.cc.

◆ Stop()

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 160 of file matl_sell_policy.cc.


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