Skip to content

ProductOfSets is wrong when a constraint has zero rows #3019

Description

@odow

This took me a while to track down. It is the cause of the failure in jump-dev/JuMP.jl#4188 (comment)

The chain goes:

Phew!

Here's a MWE:

julia> import MathOptInterface as MOI

julia> MOI.Utilities.@product_of_sets(_Cones, MOI.Zeros)

julia> const OptimizerCache{T} = MOI.Utilities.GenericModel{
           T,
           MOI.Utilities.ObjectiveContainer{T},
           MOI.Utilities.VariablesContainer{T},
           MOI.Utilities.MatrixOfConstraints{
               T,
               MOI.Utilities.MutableSparseMatrixCSC{
                   T,
                   Int,
                   MOI.Utilities.OneBasedIndexing,
               },
               Vector{T},
               _Cones{T},
           },
       };

julia> model = OptimizerCache{Float64}();

julia> f = MOI.VectorAffineFunction(MOI.VectorAffineTerm{Float64}[], Float64[]);

julia> c = MOI.add_constraint(model, f, MOI.Zeros(0))
MathOptInterface.ConstraintIndex{MathOptInterface.VectorAffineFunction{Float64}, MathOptInterface.Zeros}(1)

julia> MOI.Utilities.final_touch(model, nothing)

julia> MOI.get(model, MOI.ListOfConstraintTypesPresent())
Tuple{Type, Type}[]

julia> F, S = MOI.VectorAffineFunction{Float64}, MOI.Zeros
(MathOptInterface.VectorAffineFunction{Float64}, MathOptInterface.Zeros)

julia> MOI.get(model, MOI.NumberOfConstraints{F,S}())
0

julia> MOI.get(model, MOI.ListOfConstraintIndices{F,S}())
MathOptInterface.ConstraintIndex{MathOptInterface.VectorAffineFunction{Float64}, MathOptInterface.Zeros}[]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions