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

support for binomial active/dormant in storage #635

Merged
merged 5 commits into from
Oct 31, 2024

Conversation

nuclearkatie
Copy link
Contributor

Adds the ability to use a binomial distribution to active and dormant cycles which requires one parameter, the probability that any individual time step would end the current cycle. This is specifically useful for disruption modeling, where you can assume that at every time step there is some very small chance that the agent goes offline (i.e. dormant) and vice versa for dormant.

This is a negative binomial distribution (since we're sampling the number of trials until n successes, rather than sampling the successes in n trials), in the specific case where the number of successes is always one. This is equal to a geometric distribution, but since negative binomial is more generic that's what is implemented in cyclus#1841 and used here. Note that like a coin toss, every time step is independent and has the same probability, active_buying_end_probability (or dormant)

Requires cyclus#1841 to be merged first

@nuclearkatie nuclearkatie self-assigned this Oct 25, 2024
Copy link

github-actions bot commented Oct 25, 2024

Build Status Report - dfd4e23 - 2024-10-31 02:27:52 +0000

Build FROM cyclus_20.04_apt/cyclus:latest
  • Cycamore: Success
  • Cymetric: Success
Build FROM cyclus_20.04_apt/cyclus:stable
  • Cycamore: Failure
  • Cymetric: Skipped due to upstream failure ⚠️
Build FROM cyclus_20.04_conda/cyclus:latest
  • Cycamore: Success
  • Cymetric: Success
Build FROM cyclus_20.04_conda/cyclus:stable
  • Cycamore: Failure
  • Cymetric: Skipped due to upstream failure ⚠️
Build FROM cyclus_22.04_apt/cyclus:latest
  • Cycamore: Success
  • Cymetric: Success
Build FROM cyclus_22.04_apt/cyclus:stable
  • Cycamore: Failure
  • Cymetric: Skipped due to upstream failure ⚠️
Build FROM cyclus_22.04_conda/cyclus:latest
  • Cycamore: Success
  • Cymetric: Success
Build FROM cyclus_22.04_conda/cyclus:stable
  • Cycamore: Failure
  • Cymetric: Skipped due to upstream failure ⚠️
Build FROM cyclus_24.04_apt/cyclus:latest
  • Cycamore: Success
  • Cymetric: Success
Build FROM cyclus_24.04_apt/cyclus:stable
  • Cycamore: Failure
  • Cymetric: Skipped due to upstream failure ⚠️
Build FROM cyclus_24.04_conda/cyclus:latest
  • Cycamore: Success
  • Cymetric: Success
Build FROM cyclus_24.04_conda/cyclus:stable
  • Cycamore: Failure
  • Cymetric: Skipped due to upstream failure ⚠️

@gonuke
Copy link
Member

gonuke commented Oct 27, 2024

I think this looks OK for the example you have, but not sure this is the best way to accomplish the disruption modeling scenario. I was thinking more about something that had a regular active/dormant cycle, but could be disrupted for some different amount of (longer) dormant time with some probability.

@nuclearkatie
Copy link
Contributor Author

Ah, interesting. So that's kind of like a negative binomial on top of another distribution?
Sample from typical distribution for active/dormant length, then sample from a regular binomial with trials = sampled length to see if it is disrupted? Or am I still misunderstanding the logic you're interested in having?

@gonuke
Copy link
Member

gonuke commented Oct 28, 2024

I think I'm thinking of something simpler. Sample from a Bernoulli (binomial with N=1) distribution with a high probability (p = 0.99), and use a nominal dormant length (e.g. 10 days) when successful (= 1 success, happens most of the time) and a disrupted dormant length (e.g. 150 days) when non successful (=0 success, happens rarely).

Of course, this could just be done by sampling a random number and comparing to p, but maybe it makes more sense in your Boost distribution framework.

@nuclearkatie
Copy link
Contributor Author

Ok I started working on the plane but I want to check in one more time before getting a working version. Basically, this would require a new understanding of dormant_dist in the buy policy. Right now, the dormant dist is always sampled directly as the dormant period length. For a disruption like this, you're describing a dormant dist that's used as as a binary, and then another parameter (or dist) would actually be used to set the next_dormant_end. I could do this by having a new buy pol Init with a new var (actually dist because at that point a dist is the same amount of work as a var and storage could just used permanently fixed dist for your notional length anyway), but then you need more special handling similar to cumulative_cap because now the dormant dist is not just something that can be sampled... Unless I make a wrapper dist? Either way, more handling is needed in Cyclus and not just Cycamore at this point to implement your suggestion

@gonuke
Copy link
Member

gonuke commented Oct 28, 2024

It does need something new in Cyclus and I would implement it something like this: cyclus/cyclus#1827

Could also use a binomial distribution under the hood

@gonuke
Copy link
Member

gonuke commented Oct 28, 2024

It does need something new in Cyclus and I would implement it something like this: cyclus/cyclus#1827

Could also use a binomial distribution under the hood

Of course - this is not building properly - but I use it to show the concept.

@gonuke
Copy link
Member

gonuke commented Oct 28, 2024

It does need something new in Cyclus and I would implement it something like this: cyclus/cyclus#1827
Could also use a binomial distribution under the hood

Of course - this is not building properly - but I use it to show the concept.

It builds now.... I think I'm using the binomial distribution correctly. I expect it to return either 0 or 1, and it should return 1 with p_success.

@nuclearkatie
Copy link
Contributor Author

nuclearkatie commented Oct 29, 2024

Ok, I added FixedWithDisruption as an option to both active and dormant cycles using your new distribution in cyclus#1827 (obviously requires that to be merged first). Hopefully I've made the docs clear enough so people can decide between the two skewed cycles

@nuclearkatie nuclearkatie requested a review from gonuke October 30, 2024 02:12
@nuclearkatie
Copy link
Contributor Author

Passing on latest now

Copy link
Member

@gonuke gonuke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is one optional parameter missing in the comments. You also didn't include the list of distribution types in the top of the header - I think you mentioned that today.

Finally - one optional request for formatting in comments.

src/storage.h Outdated Show resolved Hide resolved
src/storage.h Outdated Show resolved Hide resolved
@gonuke gonuke merged commit ce67519 into cyclus:main Oct 31, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants