Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rename random distributions in storage for clarity #586

Merged
merged 3 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ cycamore Change Log
* Downstream testing in CI workflows (#573, #580, #582, #583)
* GitHub workflow for publishing images on release (#573, #582, #583)
* GitHub workflows for building/testing on a PR and push to `main` (#549, #564, #573, #582, #583)
* Add functionality for random behavior on the size (#550) and frequency (#565) of a sink
* Add functionality for random behavior on the size (#550) and frequency (#565) of a sink (#586)
* GitHub workflow to check that the CHANGELOG has been updated (#562)
* Added inventory policies to Storage through the material buy policy (#574)

Expand Down
18 changes: 9 additions & 9 deletions src/storage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ void Storage::InitBuyPolicyParameters() {
}

if (active_buying_frequency_type == "Fixed") {
active_dist_ = boost::shared_ptr<cyclus::FixedIntDist>(new cyclus::FixedIntDist(active_buying_val));
active_dist_ = cyclus::FixedIntDist::Ptr (new cyclus::FixedIntDist(active_buying_val));
}
else if (active_buying_frequency_type == "Uniform") {
if ((active_buying_min == -1) || (active_buying_max == -1)) {
throw cyclus::ValueError("Invalid active buying frequency range. Please provide both a min and max value.");
}
active_dist_ = boost::shared_ptr<cyclus::UniformIntDist>(new cyclus::UniformIntDist(active_buying_min, active_buying_max));
active_dist_ = cyclus::UniformIntDist::Ptr (new cyclus::UniformIntDist(active_buying_min, active_buying_max));
}
else if (active_buying_frequency_type == "Normal") {
if ((active_buying_mean == -1) || (active_buying_stddev == -1)) {
Expand All @@ -76,21 +76,21 @@ void Storage::InitBuyPolicyParameters() {
if (active_buying_max == -1) {
active_buying_max = std::numeric_limits<int>::max();}

active_dist_ = boost::shared_ptr<cyclus::NormalIntDist>(new cyclus::NormalIntDist(active_buying_mean, active_buying_stddev,
active_dist_ = cyclus::NormalIntDist::Ptr (new cyclus::NormalIntDist(active_buying_mean, active_buying_stddev,
active_buying_min, active_buying_max));
}
else {
throw cyclus::ValueError("Invalid active buying frequency type");}

/// set up dormant buying distribution
if (dormant_buying_frequency_type == "Fixed") {
dormant_dist_ = boost::shared_ptr<cyclus::FixedIntDist>(new cyclus::FixedIntDist(dormant_buying_val));
dormant_dist_ = cyclus::FixedIntDist::Ptr (new cyclus::FixedIntDist(dormant_buying_val));
}
else if (dormant_buying_frequency_type == "Uniform") {
if ((dormant_buying_min == -1) || (dormant_buying_max == -1)) {
throw cyclus::ValueError("Invalid dormant buying frequency range. Please provide both a min and max value.");
}
dormant_dist_ = boost::shared_ptr<cyclus::UniformIntDist>(new cyclus::UniformIntDist(dormant_buying_min, dormant_buying_max));
dormant_dist_ = cyclus::UniformIntDist::Ptr (new cyclus::UniformIntDist(dormant_buying_min, dormant_buying_max));
}
else if (dormant_buying_frequency_type == "Normal") {
if ((dormant_buying_mean == -1) || (dormant_buying_stddev == -1)) {
Expand All @@ -99,29 +99,29 @@ void Storage::InitBuyPolicyParameters() {
if (dormant_buying_min == -1) {dormant_buying_min = 1;}
if (dormant_buying_max == -1) {
dormant_buying_max = std::numeric_limits<int>::max();}
dormant_dist_ = boost::shared_ptr<cyclus::NormalIntDist>(new cyclus::NormalIntDist(dormant_buying_mean, dormant_buying_stddev,
dormant_dist_ = cyclus::NormalIntDist::Ptr (new cyclus::NormalIntDist(dormant_buying_mean, dormant_buying_stddev,
dormant_buying_min, dormant_buying_max));
}
else {
throw cyclus::ValueError("Invalid dormant buying frequency type");}

/// set up buying size distribution
if (buying_size_type == "Fixed") {
size_dist_ = boost::shared_ptr<cyclus::FixedDoubleDist>(new cyclus::FixedDoubleDist(buying_size_val));
size_dist_ = cyclus::FixedDoubleDist::Ptr (new cyclus::FixedDoubleDist(buying_size_val));
}
else if (buying_size_type == "Uniform") {
if ((buying_size_min == -1) || (buying_size_max == -1)) {
throw cyclus::ValueError("Invalid buying size range. Please provide both a min and max value.");
}
size_dist_ = boost::shared_ptr<cyclus::UniformDoubleDist>(new cyclus::UniformDoubleDist(buying_size_min, buying_size_max));
size_dist_ = cyclus::UniformDoubleDist::Ptr (new cyclus::UniformDoubleDist(buying_size_min, buying_size_max));
}
else if (buying_size_type == "Normal") {
if ((buying_size_mean == -1) || (buying_size_stddev == -1)) {
throw cyclus::ValueError("Invalid buying size range. Please provide both a mean and standard deviation value.");
}
if (buying_size_min == -1) {buying_size_min = 0;}
if (buying_size_max == -1) {buying_size_max = 1;}
size_dist_ = boost::shared_ptr<cyclus::NormalDoubleDist>(new cyclus::NormalDoubleDist(buying_size_mean, buying_size_stddev,
size_dist_ = cyclus::NormalDoubleDist::Ptr (new cyclus::NormalDoubleDist(buying_size_mean, buying_size_stddev,
buying_size_min, buying_size_max));
}
else {
Expand Down
6 changes: 3 additions & 3 deletions src/storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -486,9 +486,9 @@ class Storage
}
double longitude;

boost::shared_ptr<cyclus::IntDistribution> active_dist_ = NULL;
boost::shared_ptr<cyclus::IntDistribution> dormant_dist_ = NULL;
boost::shared_ptr<cyclus::DoubleDistribution> size_dist_ = NULL;
cyclus::IntDistribution::Ptr active_dist_ = NULL;
cyclus::IntDistribution::Ptr dormant_dist_ = NULL;
cyclus::DoubleDistribution::Ptr size_dist_ = NULL;

cyclus::toolkit::Position coordinates;

Expand Down
Loading