メインコンテンツへスキップ

If Constraint

回答済み

コメント

5件のコメント

  • Rayan SAAD
    • Gurobi-versary
    • First Comment
    • First Question

    is it correct to express it like this :

    model.addConstrs( (W[i,c,k,t] ==1) >> (gp.quicksum( W[j,d,k,t] for j in range(I) for d in range(C)  if j != i if d !=c) == 0 ) for i in range(I)  for k in range(K) for t in range(T)for c in range(C))
    0
  • Jaromił Najman
    • Gurobi Staff

    Hi Rayan,

    The constraint looks correct. However, you don't necessarily need an indicator constraint for that.

    If your \(\texttt{W}\) are binary then the constraints

    \[\begin{align*}
    \sum_{i \in I, c \in C} W_{i,c,k,t} = 1 \quad \forall k \in K, t \in T
    \end{align*}\]

    already make sure that exactly one \(W_{i,c,k,t}\) is \(1\) over all \(i,c\) for a fixed \(k,t\).

    Best regards, 
    Jaromił

    0
  • Rayan SAAD
    • Gurobi-versary
    • Investigator
    • Conversationalist

    Hello Jaromi,

    than you for your response,

    i wrote the constraint like this :

    for k in range(K):
    for t in range(t):
    model.addConstr(gp.quicksum(W[i,c,k,t] for i in range(I) for c in range(C))<=1)

    and i found W[1,1,0,2] AND W[1,0,0,2] equal to 1.
    i don't where is my error
    Thank you

    0
  • Jaromił Najman
    • Gurobi Staff

    I would guess that

    for t in range(t):

    is a typo and should read

    for t in range(T):
    0
  • Rayan SAAD
    • Gurobi-versary
    • Investigator
    • Conversationalist

    Thnak you !!

     

    0

サインインしてコメントを残してください。