Skip to content

Commit

Permalink
[Bridges] Fix ConstraintFunction getter of conversion bridge with sma…
Browse files Browse the repository at this point in the history
…ll rounding errors (#2360)
  • Loading branch information
blegat authored Dec 14, 2023
1 parent 2fb6eb2 commit c6d91a4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Bridges/Constraint/bridges/functionize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ function MOI.get(
# We need canonical, because the downstream bridges may have added
# additional terms that mean it can't be directly converted to G.
f = MOI.get(model, MOI.ConstraintFunction(), b.constraint)
return convert(G, MOI.Utilities.canonical(f))
return MOI.Utilities.convert_approx(G, MOI.Utilities.canonical(f))
end

"""
Expand Down
12 changes: 12 additions & 0 deletions test/Bridges/Constraint/functionize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,18 @@ function test_first_bridge()
return
end

function test_approx_convert(T = Float64)
inner = MOI.Utilities.Model{T}()
# `SOCtoRSOC` will rotate the function so there will be small
# rounding errors when getting the `ConstraintFunction`
# and we test that it's ignored
soc = MOI.Bridges.Constraint.SOCR{T}(inner)
model = MOI.Bridges.Constraint.VectorFunctionize{T}(soc)
config = MOI.Test.Config(T)
MOI.Test.test_basic_VectorOfVariables_SecondOrderCone(model, config)
return
end

end # module

TestConstraintFunctionize.runtests()

0 comments on commit c6d91a4

Please sign in to comment.