JuMP non-rectangular variable container: more efficient representation?

  1. IIRC fix will not replace variables with constant because converting it to a constant is an irreversible operation, you cannot set its upper bound or lower bound afterwards.
  2. SparseAxisArray behaves like a SparseArray. It is also an AbstractArray so sum should work as usual, but common index operation of dense array cannot be used (like v[1, :]). You can access all indices via eachindex(v). It is closer to a Dict{Index, Value} where index is a N dimensional tuple.
    Containers · JuMP gives a clear comparison.
  3. Use SparseAxisArray if your variables are really sparse, otherwise using DenseAxisArray then fixing variables is more convenient.
    If creating variables is not your bottleneck, do not worry about it before profiling. Most solvers will eliminate fixed variables at the presolve step so it will impact the solution time significantly.
2 Likes