Skip to content

Commit

Permalink
Fix table MILP bridge with constants in function (#2544)
Browse files Browse the repository at this point in the history
  • Loading branch information
blegat authored Sep 4, 2024
1 parent 20db26f commit fff8d4a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Bridges/Constraint/bridges/table.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@ 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)),
)
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 fff8d4a

Please sign in to comment.