-
Notifications
You must be signed in to change notification settings - Fork 65
Inner approximations #830
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?
Inner approximations #830
Conversation
The inner_dp algorithm is inspired from Philpott, de Matos, Finardi (2013) and Baucke, Downward, Zakeri (2017)
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #830 +/- ##
==========================================
- Coverage 96.38% 95.52% -0.87%
==========================================
Files 26 27 +1
Lines 3624 3955 +331
==========================================
+ Hits 3493 3778 +285
- Misses 131 177 +46 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
src/Inner.jl
Outdated
module Inner | ||
# This code is heavily based on bellman_functions.jl | ||
|
||
using JuMP |
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.
using JuMP | |
import JuMP |
Our suggested best practice is to use import Package
within any other package. This forces you to prefix Package.
on all calls, which is more explicit, and it avoids future breakage if JuMP starts exporting a new symbol. For example, if JuMP starts exporting delete
, did we mean Base.delete
or JuMP.delete
?
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.
I guess I have now "converged" to a more reasonable PR. I guess the next steps are:
- "duplicate" a graph, in order to build the "inner" policy graph from the "outer" one;
- Implement multi-vertices; do we (a) keep the notation
MULTI_CUT
(b) add new constantsSINGLE_VERTEX
&MULTI_VERTEX
(c) replace by something likeNODEWISE
&BRANCHWISE
(which could work for both and at the same time is not very common) - Test for cyclic graphs / Markovian graphs / ...
but feel free to suggest other directions ;-)
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.
I think the next step is to add more tests.
See https://app.codecov.io/gh/odow/SDDP.jl/pull/830/blob/src/Inner.jl?dropdown=coverage
We should add a test for every red uncovered line.
There really a few that are unreachable, because there's an error("Not implemented")
followed by some code. We should delete that code for now, and add a case that tests the error is hit.
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.
There's also a bunch of stuff for the risk-set and multi-cuts. Do you use any of that? I don't think so at the moment. So delete.
I don't know if we need multi-vertex support?
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,
So, my idea would be that in the (near-ish) future we could provide something like this to evaluate the gap:
model = ...
SDDP.train(model)
SDDP.build_inner_bound(model)
Naturally, this would need a function to "copy" a PolicyGraph
into a blank one, then perform a backward inner pass (or other strategy, but let's start with that). As far as I see it, the next "low-hanging fruits" should be multi-cuts and (non-cyclic) Markovian Policy Graphs.
My idea is to create a "tracking issue" for those two (which seem independent to me), and maybe also add other features of SDDP.jl
on a "wish-list". My not-so-low next candidate would be Unicyclic policy graphs (because they are useful) but the backward inner pass should be modified to perform at least some loops in order to sufficiently approximate the inner functions.
- Pass format checking - Use `import JuMP` inside of Inner submodule - Missing JSON import - Drop numerical checks because of different Random implementations between julia 1.6 & 1.10
Plus line breaking
# # Hydro 1d | ||
|
||
# This is a simple version of the hydro-thermal scheduling problem. | ||
# The goal is # to operate one hydro-dam and two thermal plants over time |
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.
# The goal is # to operate one hydro-dam and two thermal plants over time | |
# The goal is to operate one hydro-dam and two thermal plants over time |
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.
You can see the preview here: https://sddp.dev/previews/PR830/examples/inner_hydro_1d/
# License, v. 2.0. If a copy of the MPL was not distributed with this #src | ||
# file, You can obtain one at http://mozilla.org/MPL/2.0/. #src | ||
|
||
# # Hydro 1d |
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.
Let's give this a better name
# file, You can obtain one at http://mozilla.org/MPL/2.0/. #src | ||
|
||
# # Hydro 1d | ||
|
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.
Could we add something like
!!! warning
The code in this example is experimental and the API may change in any future release.
An initial version of inner approximations for Value functions. Currently, supports only
LinearPolicyGraphs
, and no belief/objective states.