-
Notifications
You must be signed in to change notification settings - Fork 65
Add ImportanceSamplingForwardPass #848
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
base: master
Are you sure you want to change the base?
Conversation
odow
commented
Apr 16, 2025
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #848 +/- ##
==========================================
- Coverage 96.39% 95.31% -1.08%
==========================================
Files 26 26
Lines 3633 3674 +41
==========================================
Hits 3502 3502
- Misses 131 172 +41 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This is it: |
Ah I knew there was something! A student of Dave is trying to do something similar. |
Hi Oscar, For now, if my understanding is correct, the code for ImportanceSamplingForwardPass is like a skeleton?
The block above seems to be a standard forward pass. I think of a linear policy graph, the child is deterministic and we sample the noise using the original pmf. |
model.objective_sense == MOI.MIN_SENSE, | ||
) | ||
terms = SDDP.Noise.(support, adjusted_probability) | ||
node_index, noise = SDDP.sample_noise(terms) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Danjiang2000 it's a complete implementation. The two for-loops build the nominal probability pmf, then we use SDDP.adjust_probability
to get the risk-adjusted probabilities, and then we sample a new node and noise from that distribution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Oscar,
Thanks for your last answer, it is really helpful.
I am 'drafting' to modify this forward_pass function so that it can better serve the purpose of an importance sampling experiment.
In the current implementation, we sample noise using adjusted pmf, and we can find the cumulative cost along the path we sample. To do the importance sampling, I also want to know the weight adjustment for each path, which means I need to multiply the weight adjustment on each path together.
I am not sure if there is a better way to suggest code modification I want to make, so I will write the code in this comment:
At line 413,
cumulative_weight = 1.0
At line 464,
sel = (node_index, noise)
idx = findfirst(x -> x == sel, support)
ratio = nominal_probability[idx] / adjusted_probability[idx]
cumulative_weight *= ratio
At line 475,
cumulative_weight = cumulative_weight,
Then, to simulate via importance sampling, I can write another function that repeat this modified forward pass multiple times. If I want to have a point estimate for entropic cost, I can find point estimate for exponential cost by sample averaging the product of cumulative weight and exponential of cumulative cost.
Does this sound like a good plan if I want to implement a complete importance sampling experiment?

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this sound like a good plan if I want to implement a complete importance sampling experiment?
Yes, I think at least for now.
What this is really asking for the ability to sample with the risk-adjusted probabilities in SDDP.simulate
instead of SDDP.train
. We either need to write something separate for SDDP.simulate
, or change SDDP.simulate
to use the AbstractForwardPass
machinery.
I haven't update arXiv, but yet another alternative version for single cut is:
It is a bit weird in the sense that if you are storing all cuts individually, why not just do multicut? Maybe single cut is faster for that problem. |
Yeah I thought of this. I initially considered looping through the cuts evaluating them before I realized I could reach in and find the right I guess the point is that there is a lot of information in the disaggregated cuts that we are throwing away just for the sake of adding fewer constraints. |