When creating a variable indexed by Tuple{Int64, Float64}, I get a different order (apparently, sorted as string) than that provided when creating or accessing the variable.
Steps to reproduce:
using JuMP
model = Model()
N = 1:2
M = [[1.0, 11.0, 100.0], [0.0, 17.0, 104.0]]
@variable(model, foo[n in N, M[n]])
foo[1, M[1]]
Current outcome:
JuMP.Containers.SparseAxisArray{VariableRef, 2, Tuple{Int64, Float64}} with 6 entries:
[1, 1.0 ] = foo[1,1.0]
[1, 100.0] = foo[1,100.0]
[1, 11.0 ] = foo[1,11.0]
[2, 0.0 ] = foo[2,0.0]
[2, 104.0] = foo[2,104.0]
[2, 17.0 ] = foo[2,17.0]
Expected outcome:
JuMP.Containers.SparseAxisArray{VariableRef, 2, Tuple{Int64, Float64}} with 6 entries:
[1, 1.0 ] = foo[1,1.0]
[1, 11.0 ] = foo[1,11.0]
[1, 100.0] = foo[1,100.0]
[2, 0.0 ] = foo[2,0.0]
[2, 17.0 ] = foo[2,17.0]
[2, 104.0] = foo[2,104.0]
I’m having a huge problem with SOS2 constraints, as something like
@constraint(model, C[n in N], foo[n, M[n]] in SOS2(M[n]))
enforces the constraint on a different order than that established by M
, resulting in
C[1] : [foo[1,11.0], foo[1,1.0], foo[1,100.0]] ∈ MathOptInterface.SOS2{Float64}([1.0, 11.0, 100.0])
C[2] : [foo[2,0.0], foo[2,104.0], foo[2,17.0]] ∈ MathOptInterface.SOS2{Float64}([0.0, 17.0, 104.0])
Is that something expected? It seems very counter-intuitive for me.
EDIT: I’m using Julia 1.9.3 and JuMP v1.19.0.
EDIT2: fix constraint, extend example wrt the SOS2 constraint.