I'm using Python to solve an integer program using Gurobi. After defining all variables and constraints, I'm getting the following answers for my integer variable x[i,j]
.
x(0,0) 0.0
x(0,1) 0.0
x(0,2) 1.0
x(0,3) 1.0
x(1,0) 0.0
x(1,1) 0.0
x(1,2) 0.0
x(1,3) 0.0
x(2,0) 0.0
x(2,1) 0.0
x(2,2) 0.0
x(2,3) 0.0
x(3,0) 0.0
x(3,1) 0.0
x(3,2) 0.0
x(3,3) 0.0
So, in the next step, I need to pass all i,j
s for which x[i,j]=1
to a set called S
. I'm using the following code for this.
S=[]
if x[i,j]== 1:
S.append(i)
S.append(j)
print(S)
This prints S=[0,3]
. But the correct one should be S=[0,2,3]
. Can someone please help me to identify the mistake here?