Skip to content

Commit dd9eb9d

Browse files
committed
Add test for issue #2452
1 parent 1daba71 commit dd9eb9d

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

test/Bridges/bridge_optimizer.jl

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,6 +1187,60 @@ function test_cannot_unbridge_variable_function()
11871187
return
11881188
end
11891189

1190+
MOI.Utilities.@model(
1191+
Model2452,
1192+
(),
1193+
(),
1194+
(MOI.Nonnegatives, MOI.Zeros),
1195+
(),
1196+
(),
1197+
(),
1198+
(MOI.VectorOfVariables,),
1199+
(MOI.VectorAffineFunction,)
1200+
)
1201+
1202+
function MOI.supports_constraint(
1203+
::Model2452{T},
1204+
::Type{MOI.VariableIndex},
1205+
::Type{
1206+
<:Union{
1207+
MOI.GreaterThan{T},
1208+
MOI.LessThan{T},
1209+
MOI.EqualTo{T},
1210+
MOI.Interval{T},
1211+
MOI.ZeroOne,
1212+
MOI.Integer,
1213+
},
1214+
},
1215+
) where {T}
1216+
return false
1217+
end
1218+
1219+
function MOI.supports_constraint(
1220+
::Model2452{T},
1221+
::Type{MOI.VectorOfVariables},
1222+
::Type{MOI.Reals},
1223+
) where {T}
1224+
return false
1225+
end
1226+
1227+
function test_issue_2452()
1228+
src = MOI.Utilities.UniversalFallback(MOI.Utilities.Model{Float64}())
1229+
x = MOI.add_variable(src)
1230+
MOI.add_constraint(src, x, MOI.GreaterThan(1.0))
1231+
c = MOI.add_constraint(src, 2.0 * x, MOI.EqualTo(3.0))
1232+
dest = MOI.instantiate(Model2452{Float64}; with_bridge_type = Float64)
1233+
index_map = MOI.copy_to(dest, src)
1234+
set = MOI.get(dest, MOI.ConstraintSet(), index_map[c])
1235+
@test_broken set == MOI.EqualTo(3.0)
1236+
MOI.set(dest, MOI.ConstraintSet(), index_map[c], set)
1237+
@test_broken MOI.get(dest, MOI.ConstraintSet(), index_map[c]) == set
1238+
new_set = MOI.EqualTo(2.0)
1239+
MOI.set(dest, MOI.ConstraintSet(), index_map[c], new_set)
1240+
@test_broken MOI.get(dest, MOI.ConstraintSet(), index_map[c]) == new_set
1241+
return
1242+
end
1243+
11901244
end # module
11911245

11921246
TestBridgeOptimizer.runtests()

0 commit comments

Comments
 (0)