From c42178f0e2bdd0dcf91154569d11416f10a7aeef Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Wed, 8 Oct 2025 15:32:30 +1300 Subject: [PATCH] [Bridges] fix supports_constraint for IndicatorToMILPBridge --- .../bridges/IndicatorToMILPBridge.jl | 2 +- .../Constraint/IndicatorToMILPBridge.jl | 37 +++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/src/Bridges/Constraint/bridges/IndicatorToMILPBridge.jl b/src/Bridges/Constraint/bridges/IndicatorToMILPBridge.jl index bd05ebfe1b..8056af283b 100644 --- a/src/Bridges/Constraint/bridges/IndicatorToMILPBridge.jl +++ b/src/Bridges/Constraint/bridges/IndicatorToMILPBridge.jl @@ -81,7 +81,7 @@ end function MOI.Bridges.added_constrained_variable_types( ::Type{<:IndicatorToMILPBridge}, ) - return Tuple{Type}[(MOI.Reals,)] + return Tuple{Type}[(MOI.Reals,), (MOI.ZeroOne,)] end function MOI.Bridges.added_constraint_types( diff --git a/test/Bridges/Constraint/IndicatorToMILPBridge.jl b/test/Bridges/Constraint/IndicatorToMILPBridge.jl index d29ab62d30..f5f4acc56b 100644 --- a/test/Bridges/Constraint/IndicatorToMILPBridge.jl +++ b/test/Bridges/Constraint/IndicatorToMILPBridge.jl @@ -320,6 +320,43 @@ function test_runtests_error_not_binary() return end +MOI.Utilities.@model( + Model2867, + (), + (MOI.EqualTo, MOI.LessThan), + (), + (), + (), + (MOI.ScalarAffineFunction,), + (), + () +) + +function MOI.supports_constraint( + model::Model2867, + ::Type{MOI.VariableIndex}, + ::Type{<:Union{MOI.Integer,MOI.ZeroOne}}, +) + return get(model.ext, :supports, false) +end + +function test_issue_2867() + model = MOI.instantiate(Model2867{Float64}; with_bridge_type = Float64) + @test !MOI.supports_constraint( + model, + MOI.VectorOfVariables, + MOI.Indicator{MOI.ACTIVATE_ON_ONE,MOI.EqualTo{Float64}}, + ) + model = MOI.instantiate(Model2867{Float64}; with_bridge_type = Float64) + model.model.ext[:supports] = true + @test MOI.supports_constraint( + model, + MOI.VectorOfVariables, + MOI.Indicator{MOI.ACTIVATE_ON_ONE,MOI.EqualTo{Float64}}, + ) + return +end + end # module TestConstraintIndicatorToMILP.runtests()