Skip to content

Add low bound to the sum of flows for transport flows #1178

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

Merged
merged 16 commits into from
May 13, 2025

Conversation

gnawin
Copy link
Member

@gnawin gnawin commented Apr 28, 2025

Model

  • Enforce free signs only for transport flows, the rest flows will have a low bound of 0.
  • Add a lower bound of 0 for the sum of outgoing flows, if one of them is a transport flow, for producers, conversions, and storages. Exclude assets with UC because the bound is already applied by constraint min_output_flow_with_unit_commitment.
  • Add a lower bound of 0 for the sum of incoming flows, if one of them is a transport flow, for conversions, and storages. Since UC does not have bounds for incoming flows, so assets with UC are not excluded.

Documentation

  • Update concepts.
  • Update mathematical formulation.

Testing

  • Update multi-year : one transport flow is defined from a producer to a demand. Previously the flow has a lower bound directly, but now lower bounds are set by the new constraints.
  • Update Norse: one flow from balance to export had free signs (which I believe did not make sense), with the changes in this PR, that flow becomes positive.
  • Add a new test Power-flow (pre-maturely):
flowchart LR
    A["producer - CCGT"] <-- "Flow 1" --> B["Hub"]
    A["producer - CCGT"] <-- "Flow 2" --> C["Demand"]
    B["Hub"] <-- "Flow 3" --> C["Demand"]
Loading

In this case, we want to test multiple outgoing flows from CCGT: $Flow1 + Flow2 \ge 0$, which has been checked by looking at the lp file.

An integration test has been added, but most probably it will be updated after DC-OPF.

Related issues

Closes #1159, #1168

Checklist

  • I am following the contributing guidelines

  • Tests are passing

  • Lint workflow is passing

  • Docs were updated and workflow is passing

Copy link
Contributor

github-actions bot commented Apr 28, 2025

✅ MPS files match

🤖 This was CompareMPS, we hope you have enjoyed this program.

Copy link

codecov bot commented Apr 28, 2025

Codecov Report

Attention: Patch coverage is 83.33333% with 1 line in your changes missing coverage. Please review.

Project coverage is 97.63%. Comparing base (326f025) to head (1077cd0).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/variables/flows.jl 0.00% 1 Missing ⚠️

❌ Your patch status has failed because the patch coverage (83.33%) is below the target coverage (95.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1178      +/-   ##
==========================================
+ Coverage   97.62%   97.63%   +0.01%     
==========================================
  Files          31       31              
  Lines        1135     1140       +5     
==========================================
+ Hits         1108     1113       +5     
  Misses         27       27              

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

@gnawin
Copy link
Member Author

gnawin commented Apr 28, 2025

@datejada The MPS file has changed, but somehow the change was not detected. I'll update the MPS file once you have a look at the Github actions. Thanks.

@gnawin gnawin marked this pull request as draft April 28, 2025 14:26
@gnawin gnawin force-pushed the 1159-add-lower-bound branch from 6bb1d9a to 74d2804 Compare May 1, 2025 13:26
@gnawin gnawin force-pushed the 1159-add-lower-bound branch from 74d2804 to dcd1ad8 Compare May 6, 2025 13:03
Copy link
Contributor

github-actions bot commented May 6, 2025

🤖 CompareMPS report

✅ MPS files match

Copy link
Contributor

github-actions bot commented May 6, 2025

🤖 CompareMPS report

⚠️ MPS files differ

What to do?

👍 If this is expected

Then you just have to update the MPS files running from the root of TulipaEnergyModel.jl:

julia --project=. utils/scripts/model-mps-update.jl

👎 If this is bad

Then, review the log below to figure out why the files differ:

┌ Info: New comparison
│ Comparing files
│ - /home/runner/work/TulipaEnergyModel.jl/TulipaEnergyModel.jl/utils/scripts/../../benchmark/model-mps-folder/Multi-year Investments.mps
│ - /tmp/jl_pLZhwX/Multi-year Investments.mps
└ @ Main /home/runner/work/TulipaEnergyModel.jl/TulipaEnergyModel.jl/utils/scripts/model-mps-compare.jl:29
┌ Info: Create mps for /home/runner/work/TulipaEnergyModel.jl/TulipaEnergyModel.jl/utils/scripts/../../test/inputs/Multi-year Investments in /tmp/jl_pLZhwX
└ @ Main /home/runner/work/TulipaEnergyModel.jl/TulipaEnergyModel.jl/utils/scripts/model-mps-compare.jl:34
┌ Error: Files don't have the same size
└ @ Main /home/runner/work/TulipaEnergyModel.jl/TulipaEnergyModel.jl/utils/scripts/model-mps-compare.jl:43
┌ Info: New comparison
│ Comparing files
│ - /home/runner/work/TulipaEnergyModel.jl/TulipaEnergyModel.jl/utils/scripts/../../benchmark/model-mps-folder/Norse.mps
│ - /tmp/jl_90njvh/Norse.mps
└ @ Main /home/runner/work/TulipaEnergyModel.jl/TulipaEnergyModel.jl/utils/scripts/model-mps-compare.jl:29
┌ Info: Create mps for /home/runner/work/TulipaEnergyModel.jl/TulipaEnergyModel.jl/utils/scripts/../../test/inputs/Norse in /tmp/jl_90njvh
└ @ Main /home/runner/work/TulipaEnergyModel.jl/TulipaEnergyModel.jl/utils/scripts/model-mps-compare.jl:34
┌ Error: Files don't have the same size
└ @ Main /home/runner/work/TulipaEnergyModel.jl/TulipaEnergyModel.jl/utils/scripts/model-mps-compare.jl:43
┌ Info: New comparison
│ Comparing files
│ - /home/runner/work/TulipaEnergyModel.jl/TulipaEnergyModel.jl/utils/scripts/../../benchmark/model-mps-folder/Storage.mps
│ - /tmp/jl_vDjycz/Storage.mps
└ @ Main /home/runner/work/TulipaEnergyModel.jl/TulipaEnergyModel.jl/utils/scripts/model-mps-compare.jl:29
┌ Info: Create mps for /home/runner/work/TulipaEnergyModel.jl/TulipaEnergyModel.jl/utils/scripts/../../test/inputs/Storage in /tmp/jl_vDjycz
└ @ Main /home/runner/work/TulipaEnergyModel.jl/TulipaEnergyModel.jl/utils/scripts/model-mps-compare.jl:34
┌ Info: No difference found
└ @ Main /home/runner/work/TulipaEnergyModel.jl/TulipaEnergyModel.jl/utils/scripts/model-mps-compare.jl:84
┌ Info: New comparison
│ Comparing files
│ - /home/runner/work/TulipaEnergyModel.jl/TulipaEnergyModel.jl/utils/scripts/../../benchmark/model-mps-folder/Tiny.mps
│ - /tmp/jl_nRki11/Tiny.mps
└ @ Main /home/runner/work/TulipaEnergyModel.jl/TulipaEnergyModel.jl/utils/scripts/model-mps-compare.jl:29
┌ Info: Create mps for /home/runner/work/TulipaEnergyModel.jl/TulipaEnergyModel.jl/utils/scripts/../../test/inputs/Tiny in /tmp/jl_nRki11
└ @ Main /home/runner/work/TulipaEnergyModel.jl/TulipaEnergyModel.jl/utils/scripts/model-mps-compare.jl:34
┌ Info: No difference found
└ @ Main /home/runner/work/TulipaEnergyModel.jl/TulipaEnergyModel.jl/utils/scripts/model-mps-compare.jl:84
┌ Info: New comparison
│ Comparing files
│ - /home/runner/work/TulipaEnergyModel.jl/TulipaEnergyModel.jl/utils/scripts/../../benchmark/model-mps-folder/UC-ramping.mps
│ - /tmp/jl_UARQih/UC-ramping.mps
└ @ Main /home/runner/work/TulipaEnergyModel.jl/TulipaEnergyModel.jl/utils/scripts/model-mps-compare.jl:29
┌ Info: Create mps for /home/runner/work/TulipaEnergyModel.jl/TulipaEnergyModel.jl/utils/scripts/../../test/inputs/UC-ramping in /tmp/jl_UARQih
└ @ Main /home/runner/work/TulipaEnergyModel.jl/TulipaEnergyModel.jl/utils/scripts/model-mps-compare.jl:34
┌ Info: No difference found
└ @ Main /home/runner/work/TulipaEnergyModel.jl/TulipaEnergyModel.jl/utils/scripts/model-mps-compare.jl:84
┌ Info: New comparison
│ Comparing files
│ - /home/runner/work/TulipaEnergyModel.jl/TulipaEnergyModel.jl/utils/scripts/../../benchmark/model-mps-folder/Variable Resolution.mps
│ - /tmp/jl_4i69GI/Variable Resolution.mps
└ @ Main /home/runner/work/TulipaEnergyModel.jl/TulipaEnergyModel.jl/utils/scripts/model-mps-compare.jl:29
┌ Info: Create mps for /home/runner/work/TulipaEnergyModel.jl/TulipaEnergyModel.jl/utils/scripts/../../test/inputs/Variable Resolution in /tmp/jl_4i69GI
└ @ Main /home/runner/work/TulipaEnergyModel.jl/TulipaEnergyModel.jl/utils/scripts/model-mps-compare.jl:34
┌ Info: No difference found
└ @ Main /home/runner/work/TulipaEnergyModel.jl/TulipaEnergyModel.jl/utils/scripts/model-mps-compare.jl:84

For more details about this workflow, check https://tulipaenergy.github.io/TulipaEnergyModel.jl/dev/91-developer/#Testing-the-generate-MPS-files.

@gnawin gnawin force-pushed the 1159-add-lower-bound branch from dcd1ad8 to af0c8c2 Compare May 9, 2025 14:17
@gnawin gnawin marked this pull request as ready for review May 9, 2025 15:02
@gnawin gnawin requested a review from datejada May 9, 2025 15:02
@gnawin gnawin marked this pull request as draft May 9, 2025 18:02
@gnawin gnawin marked this pull request as ready for review May 9, 2025 18:31
Copy link
Member

@datejada datejada left a comment

Choose a reason for hiding this comment

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

@gnawin Thanks for the PR, one last thing, I think we commented on it before but I forgot the reason. Can we make the codecov pass? or there is something why we are not testing those cases anymore.

@gnawin
Copy link
Member Author

gnawin commented May 13, 2025

@datejada the Github code coverage give the same results in the original PR (#1172 (comment)), while locally it was okay. I have only changed the documentation afterwards.

Now when I open code coverage, it shows one line is missing for flows.jl:
image
As you can see that line is already missed (for unknown reasons) in main.

I also ran local code coverage, here are the results:
Main
image
This branch
image

So nothing is changing in flows.jl, and that line is actually covered (as it is the lower bound of non-transport flow variables).

Copy link
Member

@datejada datejada left a comment

Choose a reason for hiding this comment

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

Thank you for the explanation of the codecov. No more comments from y side 😃

@datejada datejada merged commit d462d8d into main May 13, 2025
7 of 8 checks passed
@datejada datejada deleted the 1159-add-lower-bound branch May 13, 2025 10:51
@gnawin gnawin mentioned this pull request Jun 12, 2025
9 tasks
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.

Lower bound for the capacity constraints
2 participants