Skip to content

Commit

Permalink
Fix table MILP bridge with constants in function
Browse files Browse the repository at this point in the history
  • Loading branch information
blegat committed Sep 4, 2024
1 parent 8950c80 commit a0d66a5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Bridges/Constraint/bridges/table.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function bridge_constraint(
end
assign_f = MOI.ScalarAffineFunction(terms, zero(T))
assign_f = MOI.Utilities.operate!(-, T, assign_f, fi)
ci = MOI.add_constraint(model, assign_f, MOI.EqualTo(zero(T)))
ci = MOI.Utilities.normalize_and_add_constraint(model, assign_f, MOI.EqualTo(zero(T)))

Check warning on line 75 in src/Bridges/Constraint/bridges/table.jl

View check run for this annotation

Codecov / codecov/patch

src/Bridges/Constraint/bridges/table.jl#L75

Added line #L75 was not covered by tests
push!(assignment, ci)
end
return TableToMILPBridge{T,F}(z, unity, assignment, f, s)
Expand Down
18 changes: 18 additions & 0 deletions test/Bridges/Constraint/table.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,24 @@ function test_runtests()
a4 in ZeroOne()
""",
)
MOI.Bridges.runtests(
MOI.Bridges.Constraint.TableToMILPBridge,
"""
variables: x, y
[x, y, 1] in Table(Float64[1 1 0; 0 1 1; 1 0 1; 1 1 1])
""",
"""
variables: x, y, a1, a2, a3, a4
a1 + a2 + a3 + a4 == 1.0
a1 + a3 + a4 + -1.0 * x == 0.0
a1 + a2 + a4 + -1.0 * y == 0.0
a2 + a3 + a4 == 1.0
a1 in ZeroOne()
a2 in ZeroOne()
a3 in ZeroOne()
a4 in ZeroOne()
""",
)
return
end

Expand Down

0 comments on commit a0d66a5

Please sign in to comment.