Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a Bin2-style bilinear product approximation (z ≈ x·y) to the existing quadratic-approximation tooling by decomposing into two squared terms via the difference-of-squares identity, with an optional McCormick envelope for additional bounding, plus a new dedicated unit test file.
Changes:
- Add McCormick envelope constraints helper for bilinear products.
- Add bilinear approximation helpers that reuse existing SOS2/manual-SOS2/sawtooth quadratic approximations on
(x+y)²and(x−y)². - Add unit tests covering container structure, basic correctness cases, and approximation behavior for the three bilinear variants.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
src/quadratic_approximations/mccormick.jl |
Introduces McCormickConstraint and _add_mccormick_envelope! for optional linear envelopes around z = x·y. |
src/quadratic_approximations/bilinear.jl |
Adds Bin2 bilinear approximation implementation and three wrappers (solver SOS2, manual SOS2, sawtooth), reusing quadratic approximation functions. |
src/InfrastructureOptimizationModels.jl |
Includes the new McCormick and bilinear approximation source files in the main module. |
test/test_bilinear_approximations.jl |
New test suite for bilinear approximations (structure + solve-based checks). |
test/InfrastructureOptimizationModelsTests.jl |
Wires the new bilinear test file into the unit test runner. |
Comments suppressed due to low confidence (2)
test/test_bilinear_approximations.jl:5
_setup_bilinear_testdepends on_setup_qa_containerbeing defined by another test file (currentlytest_quadratic_approximations.jl) and on include ordering inInfrastructureOptimizationModelsTests.jl. This makes the test file non-self-contained and can break if test include order changes or if this test is run in isolation. Consider moving shared setup helpers into a dedicatedtest_utilsinclude (or redefining the needed helpers locally) so each test file is independent.
function _setup_bilinear_test(device_names::Vector{String}, time_steps::UnitRange{Int})
container = _setup_qa_container(time_steps)
x_var_container = IOM.add_variable_container!(
test/test_bilinear_approximations.jl:370
- This test file uses
MOI.SOS2{Float64}but does not define/importMOIlocally (it currently relies onconst MOI = JuMP.MOIfrom another included test file). To avoid cross-test coupling, referenceJuMP.MOIdirectly here or addconst MOI = JuMP.MOIin this file.
sos2_count = JuMP.num_constraints(
setup.jump_model,
Vector{JuMP.VariableRef},
MOI.SOS2{Float64},
)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
acostarelli
approved these changes
Mar 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Thanks for opening a PR to InfrastructureOptimizationModels.jl, please take note of the following when making a PR:
Check the contributor guidelines