Skip to content

Commit c6d91a4

Browse files
authored
[Bridges] Fix ConstraintFunction getter of conversion bridge with small rounding errors (#2360)
1 parent 2fb6eb2 commit c6d91a4

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/Bridges/Constraint/bridges/functionize.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ function MOI.get(
299299
# We need canonical, because the downstream bridges may have added
300300
# additional terms that mean it can't be directly converted to G.
301301
f = MOI.get(model, MOI.ConstraintFunction(), b.constraint)
302-
return convert(G, MOI.Utilities.canonical(f))
302+
return MOI.Utilities.convert_approx(G, MOI.Utilities.canonical(f))
303303
end
304304

305305
"""

test/Bridges/Constraint/functionize.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,18 @@ function test_first_bridge()
361361
return
362362
end
363363

364+
function test_approx_convert(T = Float64)
365+
inner = MOI.Utilities.Model{T}()
366+
# `SOCtoRSOC` will rotate the function so there will be small
367+
# rounding errors when getting the `ConstraintFunction`
368+
# and we test that it's ignored
369+
soc = MOI.Bridges.Constraint.SOCR{T}(inner)
370+
model = MOI.Bridges.Constraint.VectorFunctionize{T}(soc)
371+
config = MOI.Test.Config(T)
372+
MOI.Test.test_basic_VectorOfVariables_SecondOrderCone(model, config)
373+
return
374+
end
375+
364376
end # module
365377

366378
TestConstraintFunctionize.runtests()

0 commit comments

Comments
 (0)