Skip to content

Jd/bin2 approx#32

Merged
jd-lara merged 7 commits intomainfrom
jd/bin2_approx
Mar 5, 2026
Merged

Jd/bin2 approx#32
jd-lara merged 7 commits intomainfrom
jd/bin2_approx

Conversation

@jd-lara
Copy link
Member

@jd-lara jd-lara commented Mar 4, 2026

Thanks for opening a PR to InfrastructureOptimizationModels.jl, please take note of the following when making a PR:

Check the contributor guidelines

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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_test depends on _setup_qa_container being defined by another test file (currently test_quadratic_approximations.jl) and on include ordering in InfrastructureOptimizationModelsTests.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 dedicated test_utils include (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/import MOI locally (it currently relies on const MOI = JuMP.MOI from another included test file). To avoid cross-test coupling, reference JuMP.MOI directly here or add const MOI = JuMP.MOI in 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.

@jd-lara jd-lara marked this pull request as ready for review March 5, 2026 18:21
@jd-lara jd-lara merged commit 7021e49 into main Mar 5, 2026
1 of 5 checks passed
@jd-lara jd-lara deleted the jd/bin2_approx branch March 5, 2026 18:22
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