Skip to content

Conversation

@manuelma
Copy link
Collaborator

@manuelma manuelma commented Sep 8, 2025

This PR introduces the delta formulation for the representative periods model. The main changes are as follows:

  • When generating time-slices for represented blocks, we ignore the resolution parameter and we instead use the resolution of the representative_periods_mapping parameter. This is because we only need time-slices at mapping resolution to write the deltas.
  • For represented periods, the only constraints are the min_node_state and node_state_capacity constraints for nodes with is_long_term_storage=true. No other constraint is generated outside of representative periods.
  • In the above two constraints, the node_state is obtained from a JuMP expression corresponding to the delta equation.
  • We don't generate any variables for represented periods.

Also we introduce temporal blocks with free start using middle histories, superseding #1254 (now closed).

Fixes #1233

Checklist before merging

  • Documentation is up-to-date
  • Unit tests have been added/updated accordingly
  • improved type stability or, when outside the scope of the pull request, at least indicated where and how the code is not properly typed
  • Code has been formatted according to SpineOpt's style
  • Unit tests pass

@codecov
Copy link

codecov bot commented Sep 8, 2025

Codecov Report

❌ Patch coverage is 92.50000% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.33%. Comparing base (6f7ee3d) to head (1151d61).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/data_structure/temporal_structure.jl 91.77% 13 Missing ⚠️
src/constraints/constraint_cyclic_node_state.jl 85.71% 1 Missing ⚠️
src/variables/variable_node_state.jl 88.88% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1253      +/-   ##
==========================================
- Coverage   86.48%   86.33%   -0.15%     
==========================================
  Files         148      148              
  Lines        4660     4735      +75     
==========================================
+ Hits         4030     4088      +58     
- Misses        630      647      +17     

☔ 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.

@DillonJ
Copy link
Contributor

DillonJ commented Sep 8, 2025

Great stuff. @manuelma reports the following build times for a version of our SpineH2IRL model:

Before any improvements: 45 min
Improved implementation (PR #1247): 7 min
Delta formulation (This PR): 3 min

@datejada @aporrasc : Can you guys test on the WP5 test model?

@datejada
Copy link
Member

datejada commented Sep 9, 2025

Great stuff. @manuelma reports the following build times for a version of our SpineH2IRL model:

Before any improvements: 45 min Improved implementation (PR #1247): 7 min Delta formulation (This PR): 3 min

@datejada @aporrasc : Can you guys test on the WP5 test model?

It looks promising; it's the 12RP case from @aporrasc that I have, which goes from around 10m to 4.5m to create the model. So, kudos for that. Some open questions from my side are:

  1. The objective function should be the same when solving (or close to it). I didn't check that so far.
  2. How does this scale with more RPs (50RP, 100RPs...)

Thanks!

@manuelma manuelma changed the title Delta formulation Delta formulation and free starts Sep 18, 2025
manuelma and others added 27 commits September 18, 2025 19:21
So histories of different blocks aren't mixed.
This is controversial but we need to discuss it.
...to not include the middle histories.
...whenever blocks with free start overlap with blocks without free
start, such as RPs.
Now we only disallow the history of blocks with free start to
be related to other blocks with free start. The "non-history" part
is allowed to be related so that blocks with free start can overlap.
…cks without has_free_start:

- Collecting the generator into an array first
- Checking if the array is empty before calling last()
- Only applying initial values when last_history_t is not nothing
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.

Reformulate formulation with representative periods in SpineOpt

4 participants