I have an MILP model that I am trying to solve. I have a new constriant that I explained before on this question My new constraint is :
if: y[(i,j,k)]==1
then : y[(j,i,k+1)] ,y[(j,i,k+2)],y[(j,i,k+3)] ,y[(j,i,k+4)],y[(j,i,k+5)],y[(j,i,k+6)],y[(j,i,k+7)],y[(j,i,k+8)==0 .
I put this constraint in this way on my mode:
mdl.add_constraints((y[(i,j,k)]+y[(j,i,k+1)] +y[(j,i,k+2)]+y[(j,i,k+3)]
+y[(j,i,k+4)]+y[(j,i,k+5)]+y[(j,i,k+6)]+y[(j,i,k+7)]+y[(j,i,k+8)] )<=1 for k in K4 for i in T for j in T )
But running my model with this new constriant makes my model to be solved very slow. Is there something wrong with my constraint or is there a way to change it in a way that my model can be solved faster?
Edit: When I put my condition in this way the run time is fast but the model does not respect the if then constraint in solutions . my code:
for i in T:
for j in T:
if i!=j:
for k in K4:
mdl.add( mdl.if_then( y[(i,j,k)]==1 , y[(j,i,k+1)]==0))
mdl.add( mdl.if_then( y[(i,j,k)]==1 , y[(j,i,k+2)]==0))
mdl.add( mdl.if_then( y[(i,j,k)]==1 , y[(j,i,k+3)]==0))
mdl.add( mdl.if_then( y[(i,j,k)]==1 , y[(j,i,k+4)]==0))
mdl.add( mdl.if_then( y[(i,j,k)]==1 , y[(j,i,k+5)]==0))
mdl.add( mdl.if_then( y[(i,j,k)]==1 , y[(j,i,k+6)]==0))
mdl.add( mdl.if_then( y[(i,j,k)]==1 , y[(j,i,k+7)]==0))
mdl.add( mdl.if_then( y[(i,j,k)]==1 , y[(j,i,k+8)]==0))