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

The deal with WrapHistorical #19

Closed
odow opened this issue Dec 14, 2022 · 3 comments
Closed

The deal with WrapHistorical #19

odow opened this issue Dec 14, 2022 · 3 comments

Comments

@odow
Copy link
Collaborator

odow commented Dec 14, 2022

I think WrapHistorical is just:

@adow031
Copy link
Member

adow031 commented Dec 14, 2022

I think that the reason I kept using WrapHistorical was so that I could create a custom sample_scenario function that would set terminated_due_to_cycle = true.

"""
SDDP.sample_scenario(
graph::SDDP.PolicyGraph{T},
sampling_scheme::WrapHistorical{T,NoiseTerm};
kwargs...,
) where {T,NoiseTerm}
A method to sample a scenario using historical data, that returns `true`
for `terminated_due_to_cycle`. This is used with a custom forward pass:
`JADEForwardPass`.
"""
function SDDP.sample_scenario(
graph::SDDP.PolicyGraph{T},
sampling_scheme::WrapHistorical{T,NoiseTerm};
# Ignore the other kwargs because the user is giving
# us the full scenario.
kwargs...,
) where {T,NoiseTerm}
if sampling_scheme.sequential
sampling_scheme.counter += 1
if sampling_scheme.counter > length(sampling_scheme.scenarios)
sampling_scheme.counter = 1
end
return sampling_scheme.scenarios[sampling_scheme.counter].term, true
end
return SDDP.sample_noise(sampling_scheme.scenarios), true
end

@odow
Copy link
Collaborator Author

odow commented Dec 14, 2022

We could add that as an option. Or at the very least, simplify this implementation.

@odow
Copy link
Collaborator Author

odow commented Dec 19, 2022

Closed by #27

@odow odow closed this as completed Dec 19, 2022
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

No branches or pull requests

2 participants