diff --git a/src/MOI_wrapper.jl b/src/MOI_wrapper.jl index b8bbf63..853fa86 100644 --- a/src/MOI_wrapper.jl +++ b/src/MOI_wrapper.jl @@ -149,6 +149,17 @@ function MOI.is_valid(model::Optimizer, vi::MOI.VariableIndex) return false end +function MOI.is_valid( + model::Optimizer, + ci::MOI.ConstraintIndex{MOI.VariableIndex,MOI.Parameter{T}}, +) where {T} + vi = MOI.VariableIndex(ci.value) + if haskey(model.parameters, p_idx(vi)) + return true + end + return false +end + function MOI.supports( model::Optimizer, attr::MOI.VariableName, diff --git a/test/moi_tests.jl b/test/moi_tests.jl index 6e3350c..29d40bd 100644 --- a/test/moi_tests.jl +++ b/test/moi_tests.jl @@ -19,6 +19,7 @@ function test_basic_tests() y, cy = MOI.add_constrained_variable(optimizer, MOI.Parameter(0.0)) @test MOI.is_valid(optimizer, x[1]) @test MOI.is_valid(optimizer, y) + @test MOI.is_valid(optimizer, cy) @test MOI.get(optimizer, POI.ListOfPureVariableIndices()) == x @test MOI.get(optimizer, MOI.ListOfVariableIndices()) == [x[1], x[2], y] z = MOI.VariableIndex(4)