CYCLUS
|
MatlBuyPolicy performs semi-automatic inventory management of a material buffer by making requests and accepting materials in an attempt to fill the buffer fully every time step according to an (s, S) inventory policy (see [1]).
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 request by calling Set. All policy configuration should usually occur in the agent's EnterNotify member function.
[1] Zheng, Yu-Sheng. "A simple proof for optimality of (s, S) policies in infinite-horizon inventory systems." Journal of Applied Probability (1991): 802-810.
@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 59 of file matl_buy_policy.h.
#include <matl_buy_policy.h>
Additional Inherited Members | |
Protected Attributes inherited from cyclus::Trader | |
Agent * | manager_ |
cyclus::toolkit::MatlBuyPolicy::MatlBuyPolicy | ( | ) |
Creates an uninitialized policy.
The Init function MUST be called before anything else is done with the policy.
Definition at line 16 of file matl_buy_policy.cc.
|
virtual |
Definition at line 32 of file matl_buy_policy.cc.
|
virtual |
default implementation for material trade acceptance
Reimplemented from cyclus::Trader.
Definition at line 304 of file matl_buy_policy.cc.
void cyclus::toolkit::MatlBuyPolicy::CheckActiveDormantCumulativeTimes | ( | ) |
Definition at line 350 of file matl_buy_policy.cc.
Definition at line 207 of file matl_buy_policy.h.
|
inline |
whether trades will be denoted as exclusive or not
Definition at line 183 of file matl_buy_policy.h.
|
virtual |
Trader Methods.
Reimplemented from cyclus::Trader.
Definition at line 259 of file matl_buy_policy.cc.
MatlBuyPolicy & cyclus::toolkit::MatlBuyPolicy::Init | ( | Agent * | manager, |
ResBuf< Material > * | buf, | ||
std::string | name, | ||
TotalInvTracker * | buf_tracker ) |
Configures the policy to keep buf filled to a certain fraction of its capacity every time step.
manager | the agent |
buf | the resource buffer |
name | a unique name identifying this policy |
throughput | a constraining value for total transaction quantities in a single time step |
inv_policy | the inventory policy to use. Options are "sS", "RQ". Each inventory policy options has two additional required parameters. An (s,S) inventory policy orders material only when the buffer is below the minimum value, s, and orders only enough to bring the buffer to the maximum value, S. An (s,S) policy allows partial orders. Set s as req_at and S as fill. An (R,Q) inventory policy requests material when the buffer is below the minimum value, R, and places an exclusive request for size Q. Set R as req_at and Q as fill. |
req_at,the | inventory minimum (s, and R) for (s,S) and (R,Q),. If the buffer has less than or equal to value, new material will be requested based on the policy in place. |
fill_behav,the | quantity govering the fill strategy for inventory policies. For (s,S), this is the maximum value, and material will be ordered up to this amount. For (R,Q), this is the quantity of material that will be ordered (exclusive). |
cumulative_cap | the cumulative capacity of material to be received in one active cycle. A cumulative cap inventory policy allows for a cumulative capacity of material to be received in one active cycle. Once the cumulative capacity is recieved, the agent enters a dormant period. Also requires dormant distributions using dormant_dist. |
quantize | If quantize is greater than zero, the policy will make exclusive, integral quantize kg requests. Otherwise, single requests will be sent to fill the buffer's empty space. |
active_dist | an IntDistribution object that will be used to sample the number of time steps in the "on" phase. If not set, a fixed distribution with a value of 1 will be used. |
dormant_dist | an IntDistribution object that will be used to sample the number of time steps in the "off" phase. If not set, a fixed distribution with a value of 0 will be used (no dormant, always on) |
size_dist | a DoubleDistribution object that will be used to sample the size of the request as a fraction of the available capacity at the current time step. If not set, a fixed distribution with a value of 1.0 will be used. Note that active and dormant periods are note currently compatible with (s, S) inventory management |
Definition at line 136 of file matl_buy_policy.cc.
MatlBuyPolicy & cyclus::toolkit::MatlBuyPolicy::Init | ( | Agent * | manager, |
ResBuf< Material > * | buf, | ||
std::string | name, | ||
TotalInvTracker * | buf_tracker, | ||
double | throughput, | ||
double | cumulative_cap, | ||
IntDistribution::Ptr | ) |
MatlBuyPolicy & cyclus::toolkit::MatlBuyPolicy::Init | ( | Agent * | manager, |
ResBuf< Material > * | buf, | ||
std::string | name, | ||
TotalInvTracker * | buf_tracker, | ||
double | throughput, | ||
double | quantize ) |
Definition at line 163 of file matl_buy_policy.cc.
MatlBuyPolicy & cyclus::toolkit::MatlBuyPolicy::Init | ( | Agent * | manager, |
ResBuf< Material > * | buf, | ||
std::string | name, | ||
TotalInvTracker * | buf_tracker, | ||
double | throughput, | ||
IntDistribution::Ptr | active_dist = NULL, | ||
IntDistribution::Ptr | dormant_dist = NULL, | ||
DoubleDistribution::Ptr | size_dist = NULL ) |
MatlBuyPolicy & cyclus::toolkit::MatlBuyPolicy::Init | ( | Agent * | manager, |
ResBuf< Material > * | buf, | ||
std::string | name, | ||
TotalInvTracker * | buf_tracker, | ||
double | throughput, | ||
std::string | inv_policy, | ||
double | fill_behav, | ||
double | req_at ) |
Definition at line 176 of file matl_buy_policy.cc.
MatlBuyPolicy & cyclus::toolkit::MatlBuyPolicy::Init | ( | Agent * | manager, |
ResBuf< Material > * | buf, | ||
std::string | name, | ||
TotalInvTracker * | buf_tracker, | ||
std::string | inv_policy, | ||
double | fill_behav, | ||
double | req_at ) |
Definition at line 192 of file matl_buy_policy.cc.
|
inline |
whether a request can be made
Definition at line 180 of file matl_buy_policy.h.
|
inline |
Definition at line 203 of file matl_buy_policy.h.
the number of requests made per each commodity
Definition at line 192 of file matl_buy_policy.h.
the amount requested per each request
Definition at line 187 of file matl_buy_policy.h.
|
inline |
Returns corresponding commodities from which each material object was received for the current time step.
The data returned by this function are ONLY valid during the Tock phase of a time step.
Definition at line 199 of file matl_buy_policy.h.
double cyclus::toolkit::MatlBuyPolicy::SampleRequestSize | ( | ) |
Definition at line 346 of file matl_buy_policy.cc.
MatlBuyPolicy & cyclus::toolkit::MatlBuyPolicy::Set | ( | std::string | commod | ) |
Instructs the policy to fill its buffer with requests on the given commodity of composition c and the given preference.
This must be called at least once or the policy will do nothing. The policy can request on an arbitrary number of commodities by calling Set multiple times. Re-calling Set to modify the composition or preference of a commodity that has been set previously is allowed.
commod | the commodity name |
c | the composition to request for the given commodity |
pref | the preference value for the commodity |
Definition at line 222 of file matl_buy_policy.cc.
MatlBuyPolicy & cyclus::toolkit::MatlBuyPolicy::Set | ( | std::string | commod, |
Composition::Ptr | c ) |
Definition at line 228 of file matl_buy_policy.cc.
MatlBuyPolicy & cyclus::toolkit::MatlBuyPolicy::Set | ( | std::string | commod, |
Composition::Ptr | c, | ||
double | pref ) |
Definition at line 232 of file matl_buy_policy.cc.
void cyclus::toolkit::MatlBuyPolicy::SetNextActiveTime | ( | ) |
}@
Definition at line 328 of file matl_buy_policy.cc.
void cyclus::toolkit::MatlBuyPolicy::SetNextDormantTime | ( | ) |
Definition at line 333 of file matl_buy_policy.cc.
void cyclus::toolkit::MatlBuyPolicy::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 241 of file matl_buy_policy.cc.
void cyclus::toolkit::MatlBuyPolicy::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 250 of file matl_buy_policy.cc.
|
inline |
the total amount available to request
Definition at line 172 of file matl_buy_policy.h.
|
inline |
Definition at line 211 of file matl_buy_policy.h.