Hello all!
I am trying to use the new way of SOS2 constraints (MOI.SOS2) but since I have a 3-dimensional variable (the last dimension should be part of the SOS2 set), existing examples are not sufficient. Any hints how to expand? Using the following code does not work

P = 10
Q = 5 @variable(m,0<=test[1:P,1:Q]<=1)
for p = 1:P @constraint(m, test[p] in MOI.SOS2(collect(1:Q)))
end

and results in the error: ERROR: In @constraint(m, test[p] in MOI.SOS2(collect(1:Q))): unable to add the constraint because we don’t recognize test[1,1] as a valid JuMP function.

I would have expected that since in the example x[1:3] is referred to as x in the SOS2-constraint this would have been sufficient. I would not like to step into more inconvenient modeling approaches but think this should be straightforward and supported by MOI!

p.s. You might want to read PSA: make it easier to help you. It has some advice of formatting the code in questions and making a minimum working example.

Constraints of type MathOptInterface.VectorOfVariables-in-MathOptInterface.SOS2{Int64} are not supported by the solver and there are no bridges that can reformulate it into supported constraints.

Here the entire “dummy” problem…

model = Model(with_optimizer(Gurobi.Optimizer, env, OutputFlag=1))
P = 10
Q = 5 @variable(model,0<=test[1:P,1:Q]<=1)
for p = 1:P @constraint(model, test[p,:] in MOI.SOS2(collect(1:Q)))
end @objective(model, Max, sum(i*test[i,j] for i=1:P, j=1:Q))
optimize!(model)

My real problem is a very large MILP where I try to represent a working point of a unit i at each time t with a piecewise linear function using some lambda-variables, i.e.
level[i,t] = sum(lambda[i,t,p]*coeff[p] for p=1:pc)
This is needed to handle some nonlinearities and is possible to do via GAMS/AMPL but I would like to be able to formulate these more complex PWL in Julia.