Skip to content

Commit 2774d92

Browse files
Fix support for MOI.ConstraintName for Vector Functions (#189)
* fix ConstraintName for VectorFunction * bump * format * Update test/moi_tests.jl --------- Co-authored-by: Oscar Dowson <odow@users.noreply.github.com>
1 parent d620432 commit 2774d92

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ParametricOptInterface"
22
uuid = "0ce4ce61-57bf-432b-a095-efac525d185e"
33
authors = ["Tomás Gutierrez <tomasfmgutierrez@gmail.com>"]
4-
version = "0.12.0"
4+
version = "0.12.1"
55

66
[deps]
77
MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee"

src/MOI_wrapper.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,19 @@ function MOI.supports(
513513
MOI.supports(model.optimizer, attr, MOI.ConstraintIndex{G,S})
514514
end
515515

516+
function MOI.supports(
517+
model::Optimizer,
518+
attr::MOI.ConstraintName,
519+
::Type{MOI.ConstraintIndex{F,S}},
520+
) where {T,F<:MOI.VectorQuadraticFunction{T},S}
521+
G = MOI.VectorAffineFunction{T}
522+
# We can't tell at type-time whether the constraints will be quadratic or
523+
# lowered to affine, so we return the conservative choice for supports of
524+
# needing to support names for both quadratic and affine constraints.
525+
return MOI.supports(model.optimizer, attr, MOI.ConstraintIndex{F,S}) &&
526+
MOI.supports(model.optimizer, attr, MOI.ConstraintIndex{G,S})
527+
end
528+
516529
function MOI.set(
517530
model::Optimizer,
518531
attr::MOI.ConstraintName,

test/moi_tests.jl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2045,6 +2045,18 @@ MOI.Utilities.@model(
20452045
()
20462046
);
20472047

2048+
MOI.Utilities.@model(
2049+
Model185_2,
2050+
(),
2051+
(),
2052+
(MOI.PositiveSemidefiniteConeTriangle,),
2053+
(),
2054+
(),
2055+
(),
2056+
(),
2057+
(MOI.VectorAffineFunction,)
2058+
);
2059+
20482060
function test_issue_185()
20492061
inner = Model185{Float64}()
20502062
mock = MOI.Utilities.MockOptimizer(inner; supports_names = false)
@@ -2056,6 +2068,17 @@ function test_issue_185()
20562068
return
20572069
end
20582070

2071+
function test_issue_185_vector()
2072+
inner = Model185_2{Float64}()
2073+
mock = MOI.Utilities.MockOptimizer(inner; supports_names = false)
2074+
model = POI.Optimizer(MOI.Bridges.full_bridge_optimizer(mock, Float64))
2075+
for F in (MOI.VectorAffineFunction, MOI.VectorQuadraticFunction)
2076+
C = MOI.ConstraintIndex{F{Float64},MOI.PositiveSemidefiniteConeTriangle}
2077+
@test !MOI.supports(model, MOI.ConstraintName(), C)
2078+
end
2079+
return
2080+
end
2081+
20592082
function test_psd_cone_with_parameter()
20602083
#=
20612084
variables: x

0 commit comments

Comments
 (0)