When the problem has as mixture of quadratic-mapped constraints and normal affine constraints, MOI.get(model, MOI.ListOfConstraintTypesPresent()) throws a BoundsError.
Here's a MWE, created by a slight modification to an included test:
using JuMP
using Test
import GLPK
import Ipopt
import SCS
import LinearAlgebra
import ParametricOptInterface
const POI = ParametricOptInterface
function test_moi_ListOfConstraintTypesPresent()
N = 10
ipopt = Ipopt.Optimizer()
model = POI.Optimizer(ipopt)
MOI.set(model, MOI.Silent(), true)
x = MOI.add_variables(model, N / 2)
y =
first.(
MOI.add_constrained_variable.(
model,
POI.Parameter.(ones(Int(N / 2))),
),
)
MOI.add_constraint(
model,
MOI.ScalarQuadraticFunction(
MOI.ScalarQuadraticTerm.(1.0, x, y),
MOI.ScalarAffineTerm{Float64}[],
0.0,
),
MOI.GreaterThan(1.0),
)
MOI.add_constraint(
model,
MOI.ScalarAffineFunction(MOI.ScalarAffineTerm{Float64}.(1.0, x), 0.0),
MOI.GreaterThan(1.0),
)
return MOI.get(model, MOI.ListOfConstraintTypesPresent())
end
test_moi_ListOfConstraintTypesPresent()
returns:
julia> test_moi_ListOfConstraintTypesPresent()
ERROR: BoundsError: attempt to access 1-element Vector{MathOptInterface.ConstraintIndex} at index [2-element BitVector]
Stacktrace:
[1] throw_boundserror(A::Vector{MathOptInterface.ConstraintIndex}, I::Tuple{Base.LogicalIndex{Int64, BitVector}})
@ Base ./abstractarray.jl:744
[2] checkbounds
@ ./abstractarray.jl:709 [inlined]
[3] _getindex
@ ./multidimensional.jl:860 [inlined]
[4] getindex(A::Vector{MathOptInterface.ConstraintIndex}, I::BitVector)
@ Base ./abstractarray.jl:1296
[5] get(model::ParametricOptInterface.Optimizer{Float64, Ipopt.Optimizer}, #unused#::MathOptInterface.ListOfConstraintTypesPresent)
@ ParametricOptInterface ~/.julia/dev/ParametricOptInterface/src/ParametricOptInterface.jl:762
[6] test_moi_ListOfConstraintTypesPresent()
@ Main ~/.julia/dev/ParametricOptInterface/mwe.jl:43
[7] top-level scope
@ ~/.julia/dev/ParametricOptInterface/mwe.jl:46
When the problem has as mixture of quadratic-mapped constraints and normal affine constraints,
MOI.get(model, MOI.ListOfConstraintTypesPresent())throws a BoundsError.Here's a MWE, created by a slight modification to an included test:
returns: