Skip to content

Commit 2543d03

Browse files
authored
[Bridges] fix supports_constraint for IndicatorToMILPBridge (#2868)
1 parent 95aab34 commit 2543d03

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

src/Bridges/Constraint/bridges/IndicatorToMILPBridge.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ end
8181
function MOI.Bridges.added_constrained_variable_types(
8282
::Type{<:IndicatorToMILPBridge},
8383
)
84-
return Tuple{Type}[(MOI.Reals,)]
84+
return Tuple{Type}[(MOI.Reals,), (MOI.ZeroOne,)]
8585
end
8686

8787
function MOI.Bridges.added_constraint_types(

test/Bridges/Constraint/IndicatorToMILPBridge.jl

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,43 @@ function test_runtests_error_not_binary()
320320
return
321321
end
322322

323+
MOI.Utilities.@model(
324+
Model2867,
325+
(),
326+
(MOI.EqualTo, MOI.LessThan),
327+
(),
328+
(),
329+
(),
330+
(MOI.ScalarAffineFunction,),
331+
(),
332+
()
333+
)
334+
335+
function MOI.supports_constraint(
336+
model::Model2867,
337+
::Type{MOI.VariableIndex},
338+
::Type{<:Union{MOI.Integer,MOI.ZeroOne}},
339+
)
340+
return get(model.ext, :supports, false)
341+
end
342+
343+
function test_issue_2867()
344+
model = MOI.instantiate(Model2867{Float64}; with_bridge_type = Float64)
345+
@test !MOI.supports_constraint(
346+
model,
347+
MOI.VectorOfVariables,
348+
MOI.Indicator{MOI.ACTIVATE_ON_ONE,MOI.EqualTo{Float64}},
349+
)
350+
model = MOI.instantiate(Model2867{Float64}; with_bridge_type = Float64)
351+
model.model.ext[:supports] = true
352+
@test MOI.supports_constraint(
353+
model,
354+
MOI.VectorOfVariables,
355+
MOI.Indicator{MOI.ACTIVATE_ON_ONE,MOI.EqualTo{Float64}},
356+
)
357+
return
358+
end
359+
323360
end # module
324361

325362
TestConstraintIndicatorToMILP.runtests()

0 commit comments

Comments
 (0)