Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/MOI_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,19 @@ function MOI.supports(
return MOI.supports(model.optimizer, attr, tp)
end

function MOI.supports(
model::Optimizer,
attr::MOI.ConstraintName,
::Type{MOI.ConstraintIndex{F,S}},
) where {T,F<:MOI.ScalarQuadraticFunction{T},S}
G = MOI.ScalarAffineFunction{T}
# We can't tell at type-time whether the constraints will be quadratic or
# lowered to affine, so we return the conservative choice for supports of
# needing to support names for both quadratic and affine constraints.
return MOI.supports(model.optimizer, attr, MOI.ConstraintIndex{F,S}) &&
MOI.supports(model.optimizer, attr, MOI.ConstraintIndex{G,S})
end

function MOI.set(
model::Optimizer,
attr::MOI.ConstraintName,
Expand Down
23 changes: 23 additions & 0 deletions test/moi_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1982,3 +1982,26 @@ function test_no_quadratic_terms()
@test MOI.get(optimizer, MOI.ConstraintDual(), c) ≈ -1 atol = ATOL
return
end

MOI.Utilities.@model(
Model185,
(),
(MOI.EqualTo,),
(),
(),
(),
(MOI.ScalarAffineFunction,),
(),
()
);

function test_issue_185()
inner = Model185{Float64}()
mock = MOI.Utilities.MockOptimizer(inner; supports_names = false)
model = POI.Optimizer(MOI.Bridges.full_bridge_optimizer(mock, Float64))
for F in (MOI.ScalarAffineFunction, MOI.ScalarQuadraticFunction)
C = MOI.ConstraintIndex{F{Float64},MOI.EqualTo{Float64}}
@test !MOI.supports(model, MOI.ConstraintName(), C)
end
return
end
Loading