Skip to main content

Indicator Constraints with Integers

Answered

Comments

4 comments

  • Daniel Espinoza

    Hi Gabriel,

    Indicator constraints must use binary variables and values to set a condition. In your case they are integer, hence the error

    0
  • Gabriel Estrada Martinez
    Gurobi-versary
    First Comment
    First Question

    Hi Daniel,

    Thank you for the quick response. I am aware of this binary restriction. This is why I added the dummy variables but it still doesn't work. Do you know any other way around this issue?

     

    0
  • Daniel Espinoza

    I would guess that this does not work:

    m.addConstr(dummy311[j,t] == (T[t] - at[j]))

    as the difference should be a general integer.... probably you want to to say something like

    T[t]-at[j] <= Max(T[t]-at[j]:t,j)*(1-dummy311[j,t])

    at[j]-T[t] <= Max(T[t]-at[j]:t,j)*(1-dummy311[j,t])

    the maximum you should compute. Those constraint force that T[t] == at[j] whenever dummy311[j,t]=1

    0
  • Gabriel Estrada Martinez
    Gurobi-versary
    First Comment
    First Question

    Hi Daniel,

    thank you again for your input. It was very helpful. I managed to create an alternative and my model runs perfectly now. Just in case you are interested the code that I implemented is the following:

    # Constraint 31
    for j in VN:
    for t in T:
    for k in K:
    m.addConstr((dummy312[j,t] == 1) >> (at[j] == T[t]),
    "constraint31a[%s,%s]" % (j,t))
    m.addConstr((dummy312[j,t] == 1) >> ((quicksum(x[i,j,k] for i in Vk)) <= z[g[f[j]],k,t]),
    "constraint31b[%s,%s,%s]" % (j,t,k))
    for j in VN:
    m.addConstr(quicksum(dummy312[j,t] for t in T) == 1,
    "constraint31c[%s,%s]" % (j,t))
    0

Please sign in to leave a comment.