Skip to content

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

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open

Inner approximations #830

wants to merge 23 commits into from

Conversation

bfpc
Copy link
Collaborator

@bfpc bfpc commented Feb 27, 2025

An initial version of inner approximations for Value functions. Currently, supports only LinearPolicyGraphs, and no belief/objective states.

bfpc added 2 commits February 27, 2025 08:24
The inner_dp algorithm is inspired from Philpott, de Matos, Finardi (2013)
and Baucke, Downward, Zakeri (2017)
Copy link

codecov bot commented Feb 27, 2025

Codecov Report

Attention: Patch coverage is 86.10272% with 46 lines in your changes missing coverage. Please review.

Project coverage is 95.52%. Comparing base (90bab46) to head (edc065c).
Report is 7 commits behind head on master.

Files with missing lines Patch % Lines
src/Inner.jl 86.10% 46 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

src/Inner.jl Outdated
module Inner
# This code is heavily based on bellman_functions.jl

using JuMP
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
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?

Copy link
Collaborator Author

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 constants SINGLE_VERTEX & MULTI_VERTEX (c) replace by something like NODEWISE & 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 ;-)

Copy link
Owner

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.

Copy link
Owner

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?

Copy link
Collaborator Author

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.

# # 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
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
# 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

Copy link
Owner

Choose a reason for hiding this comment

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

# 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
Copy link
Owner

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

Copy link
Owner

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.

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.

3 participants