Skip to content

Commit 979274d

Browse files
committed
Merge remote-tracking branch 'origin/master' into jg/newdo
2 parents 4a0358b + 103d44a commit 979274d

2 files changed

Lines changed: 36 additions & 0 deletions

File tree

src/MOI_wrapper.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,19 @@ function MOI.supports(
496496
return MOI.supports(model.optimizer, attr, tp)
497497
end
498498

499+
function MOI.supports(
500+
model::Optimizer,
501+
attr::MOI.ConstraintName,
502+
::Type{MOI.ConstraintIndex{F,S}},
503+
) where {T,F<:MOI.ScalarQuadraticFunction{T},S}
504+
G = MOI.ScalarAffineFunction{T}
505+
# We can't tell at type-time whether the constraints will be quadratic or
506+
# lowered to affine, so we return the conservative choice for supports of
507+
# needing to support names for both quadratic and affine constraints.
508+
return MOI.supports(model.optimizer, attr, MOI.ConstraintIndex{F,S}) &&
509+
MOI.supports(model.optimizer, attr, MOI.ConstraintIndex{G,S})
510+
end
511+
499512
function MOI.set(
500513
model::Optimizer,
501514
attr::MOI.ConstraintName,

test/moi_tests.jl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1998,6 +1998,29 @@ function test_no_quadratic_terms()
19981998
return
19991999
end
20002000

2001+
MOI.Utilities.@model(
2002+
Model185,
2003+
(),
2004+
(MOI.EqualTo,),
2005+
(),
2006+
(),
2007+
(),
2008+
(MOI.ScalarAffineFunction,),
2009+
(),
2010+
()
2011+
);
2012+
2013+
function test_issue_185()
2014+
inner = Model185{Float64}()
2015+
mock = MOI.Utilities.MockOptimizer(inner; supports_names = false)
2016+
model = POI.Optimizer(MOI.Bridges.full_bridge_optimizer(mock, Float64))
2017+
for F in (MOI.ScalarAffineFunction, MOI.ScalarQuadraticFunction)
2018+
C = MOI.ConstraintIndex{F{Float64},MOI.EqualTo{Float64}}
2019+
@test !MOI.supports(model, MOI.ConstraintName(), C)
2020+
end
2021+
return
2022+
end
2023+
20012024
function test_psd_cone_with_parameter()
20022025
#=
20032026
variables: x

0 commit comments

Comments
 (0)