diff --git a/src/toolkit/matl_buy_policy.cc b/src/toolkit/matl_buy_policy.cc index 5db7fc4519..9657e16aa7 100644 --- a/src/toolkit/matl_buy_policy.cc +++ b/src/toolkit/matl_buy_policy.cc @@ -34,6 +34,19 @@ MatlBuyPolicy::~MatlBuyPolicy() { manager()->context()->UnregisterTrader(this); } +MatlBuyPolicy& MatlBuyPolicy::ResetBehavior() { + throughput_ = std::numeric_limits::max(); + quantize_ = 1; + fill_to_ = std::numeric_limits::max(); + req_at_ = std::numeric_limits::max(); + cumulative_cap_ = -1; + cycle_total_inv_ = 0; + active_dist_ = NULL; + dormant_dist_ = NULL; + size_dist_ = NULL; + return *this; +} + void MatlBuyPolicy::set_manager(Agent* m) { if (m != NULL) { Trader::manager_ = m; @@ -238,6 +251,12 @@ MatlBuyPolicy& MatlBuyPolicy::Set(std::string commod, Composition::Ptr c, return *this; } +MatlBuyPolicy& MatlBuyPolicy::Unset(std::string commod){ + + commod_details_.erase(commod); + return *this; +} + void MatlBuyPolicy::Start() { if (manager() == NULL) { std::stringstream ss; diff --git a/src/toolkit/matl_buy_policy.h b/src/toolkit/matl_buy_policy.h index 67ea825265..6393845b23 100644 --- a/src/toolkit/matl_buy_policy.h +++ b/src/toolkit/matl_buy_policy.h @@ -141,6 +141,13 @@ class MatlBuyPolicy : public Trader { IntDistribution::Ptr); /// @} + /// Reset a material buy policy parameters that govern its behavior + /// to the default state. Preserve the Trader that manages the policy. + /// The primary use case of this method is when there is a desire to + /// change the behavior of a policy. This reset can be called prior + /// to calling a new `Init()` to establish the new behavior. + MatlBuyPolicy& ResetBehavior(); + /// 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 @@ -156,6 +163,9 @@ class MatlBuyPolicy : public Trader { MatlBuyPolicy& Set(std::string commod, Composition::Ptr c, double pref); /// @} + /// Instructs the policy to stop requesting a speific commodity + MatlBuyPolicy& Unset(std::string commod); + /// 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