Rolling horizon tutorial
~BLOCKED until other rolling horizon PRs are merged.~
Create a tutorial for rolling horizon with a similar output to the JuMP tutorial https://jump.dev/JuMP.jl/stable/tutorials/algorithms/rolling_horizon/.
Related issues
Closes #1385 Part of #1365
Checklist
- [x] I am following the contributing guidelines
- [x] Tests are passing
- [x] Lint workflow is passing
- [x] Docs were updated and workflow is passing
:robot: CompareMPS report
:white_check_mark: MPS files match
Codecov Report
:x: Patch coverage is 97.29730% with 4 lines in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 98.47%. Comparing base (eb442c5) to head (bdbab55).
:warning: Report is 4 commits behind head on main.
| Files with missing lines | Patch % | Lines |
|---|---|---|
| src/rolling-horizon/rolling-horizon.jl | 90.47% | 4 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## main #1387 +/- ##
==========================================
- Coverage 98.61% 98.47% -0.14%
==========================================
Files 38 42 +4
Lines 1368 1511 +143
==========================================
+ Hits 1349 1488 +139
- Misses 19 23 +4
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
:memo: Check the documentation preview: https://tulipaenergy.github.io/TulipaEnergyModel.jl/previews/PR1387
@clizbe, the tutorial here can be reviewed in parallel to the rest of the rolling horizon changes
This has been rebased and marked as ready to review
Thanks for the review @clizbe, I've committed the easy and commented on the rest
@clizbe, it is not on you, I am the one sorry here, I have not been able to explain myself correctly with the RH, let me try again 😜
-
The solutions will differ as long as there are constraints connecting different time periods, such as energy storage balance, ramping constraints, and unit commitment. Since we have a battery in this case, energy storage balance constraints are crucial, leading us to expect feasible solutions.
-
Why do we anticipate these differences? When we optimize for an entire week at once, the model benefits from perfect foresight of the optimization horizon. This means that at the beginning of the week, the model knows what will happen by the end, allowing it to optimize the storage level from the first hour based on this comprehensive information. In contrast, a rolling horizon approach limits the optimization to a two-day window. As a result, the model cannot foresee events that occur later in the week and can only optimize for the immediate two days. While this creates suboptimal outcomes for the overall week, it remains a viable solution.
-
Why accept suboptimal solutions? There are a couple of reasons. First, solving an entire planning horizon (like a full year) may not be feasible or could take a long time. The rolling horizon approach provides a practical approximation to the perfect foresight model. Second, using smaller optimization models allows for a more accurate representation of market dynamics. With detailed considerations (like startup/shutdown processes, ramping, and DC optimal power flow), players are often limited in their foresight to just a few days, leading to suboptimal decisions. This reality is naturally reflected in the prices generated by the rolling horizon method.
-
How do we define uncertainty in our model? Uncertainty refers to potential future scenarios that occur with specific probabilities, such as a dry weather year, a wet weather year, or an average weather year, each with associated probabilities A, B, and C, respectively.
-
Does uncertainty affect the rolling horizon approach? Not really. The rolling horizon analysis typically focuses on a single scenario (for example, a dry weather year). The differences in the solutions arise not from uncertainty but from the fact that each optimization window is shorter than the overall horizon for that scenario.
-
Some might argue that a shorter optimization window allows the rolling horizon to account for future uncertainty. However, as defined in Tulipa, this is not an accurate use of the term uncertainty in this context. The rolling horizon simply prevents the solution from anticipating future events that lie outside its optimization window.
-
Is there a way in which the rolling horizon approach and the full model yield the same results? Yes, if there are no intertemporal constraints—such as those related to storage, ramping, or unit commitment—the solutions will be identical.
You should make a TED talk! ;)
@datejada, I've updated the errors now as well, let me know if that's what you're looking for
Thanks for the reviews @clizbe and @datejada, the tutorial looks much better now!