I am trying to model a conditional constraint in Guuobi python:
if a>= b then c == 1, otherwise c == 0
a and c are both model variables and c is binary
I have the following code based on How do I model conditional statements in Gurobi?but something is not correct as I cannot obtain the optimal answer. My code is:
Constraint4 = LP.addConstrs((a[i,j] >= b[j] + eps - M * (1 - c[i,j])
for j in items
for i in months
if i == months[2]), name="BigM1")
Constraint5 = LP.addConstrs((a[i,j] <= b[j] + M * c[i,j]
for j in items
for i in months
if i == months[2]), name="BigM2")