CYCLUS
|
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:
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>
Additional Inherited Members | |
Protected Attributes inherited from cyclus::Trader | |
Agent * | manager_ |
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.
|
virtual |
Definition at line 27 of file matl_sell_policy.cc.
|
inline |
whether trades will be denoted as exclusive or not
Definition at line 115 of file matl_sell_policy.h.
|
virtual |
Trader Methods.
Reimplemented from cyclus::Trader.
Definition at line 177 of file matl_sell_policy.cc.
|
virtual |
default implementation for responding to material trades
trades | all trades in which this trader is the supplier |
responses | a container to populate with responses to each trade |
Reimplemented from cyclus::Trader.
Definition at line 245 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.
manager | the agent |
buf | the resource buffer |
name | a unique name identifying this policy |
throughput | a 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. |
quantize | If 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.
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.
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.
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.
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.
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.
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.
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.
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.