Skip to content

Inconsistency in dimension of complementarity set #947

@frapac

Description

@frapac

It seems that there is a little inconsistency with how we define the dimension of the complementarity set in MOI:
https://github.com/JuliaOpt/MathOptInterface.jl/blob/master/src/sets.jl#L680-L683

That leads to mispecified problems when using JuMP in AUTOMATIC mode. E.g., when defining the constraint

[x, y] \in MOI.Complements(1)

we are calling this function:
https://github.com/JuliaOpt/MathOptInterface.jl/blob/master/src/variables.jl#L99-L101
and MOI defines a VectorOfVariables with length 1 instead of 2, because the dimension of the set Complements(1) is equal to one.

A solution would be to define instead:

dimension(set::Complements) = 2 * set.dimension

but that may lead to other issues apart.

As a MWE, the following code breaks (but works fine once we use Knitro in direct mode):

m = JuMP.Model(with_optimizer(KNITRO.Optimizer))
@variable(m, t1 >= 0)
@variable(m, t2 >= 0)
@constraint(m, [t1; t2] in MOI.Complements(1))
@objective(m, Min, 7)
JuMP.optimize!(m)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions