## Using SOS type_1 constraint

Problems with modeling
abb.omidi
User Posts: 18
Joined: 2 years ago

### Using SOS type_1 constraint

Dear support team,

I was trying to solve a scheduling model using GAMS/Gurobi. The snippet code is:

Code: Select all

``````Binary variable x(i,k);
Equations c1,c2;
c1(k)..   sum(i, x(i,k)) =e= 1;
c2(i)..   sum(k, x(i,k)) =e= 1;``````
Using the binary variables, the model has solved optimally.
I have used SOS type_1 variables instead of binary variables and run the model.

Code: Select all

``````SOS1 variable x(i,k);
Equations c1,c2;
c1(k)..   sum(i, x(i,k)) =e= 1;
c2(i)..   sum(k, x(i,k)) =e= 1;``````
The model has solved optimally and the results are the same as previous.
AKAIK, the SOS type_1 constraint says that at most one of the variables must be non-zero. the equation is:

Code: Select all

``x1 + x2 + ... + xn <= 1   for n=1...N ``
I'm working on the coding my model in the GUROBI software using Java API. While I have defined the SOS type_1 constraint in the model and run it, I get the zero solution for all assignment variables. I negotiated to GUROBI support team and they mentioned that:
the all-zero solution is feasible.
Would you say that do I have a mistake to implement GAMS code, please?

Regards
Omidi. A

Fred
Posts: 151
Joined: 2 years ago

### Re: Using SOS type_1 constraint

Hi,

As explained in the documentation, the right-most index defines the SOS set.
In your case that means x(i,k) defines i special ordered sets with k elements each.
https://www.gams.com/latest/docs/UG_Lan ... eVariables

I hope this helps!

Fred

abb.omidi
User Posts: 18
Joined: 2 years ago

### Re: Using SOS type_1 constraint

Dear Fred,

Thanks for your useful comment.
As per your advice, I try to use a medium scale problem using both binary and SOS1 variables. The results and solving time are the same. I think using of SOS1 does not improve solving time (in my problem). Unfortunately, I can not understand why GUROBI (Java API) report a zero solution to me but, in the GAMS/Gurobi it works fine.

Thanks in advance
Omidi. A