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

how to represent the earliest index among a set of boolean decision variables in Python

回答済み

コメント

2件のコメント

  • Ronald van der Velden
    • Gurobi Staff

    In terms of performance, I'm a bit concerned the constraints linking variables y and w/e could have a bad impact, especially when the number of weeks grows. Fortunately you might get away with a purely binary approach, without explicit variables for those earliest/latest times.

    Originally you stated: "We do not want to start transferring products on L1, unless all products of L2 is moved. However, it is OK to transfer some L1 products for the last transfer week of L2, if weekly capacity allows. "

    You could rephrase that as "You can only move products on L1 in period t if you are not transferring anything of L2 anymore at t+1 or later." or "You can only move products on L1 in period t if you are done moving L2 products before t+1".

    This suggests adding a binary variable indicating if level L2 has been completed. Specifically, assume that d(t)=1 would mean we've moved the last product of L2 before time period t. So the variable starts at 0 for the first period and remains 0 until for some specific period t we find out that there's nothing left to move anymore.

    Then we get the following:

    • Obviously we have d(t+1) >= d(t) : if we're done now, then we're also done tomorrow
    • Also we have y(p2,t) + d(t) <= 1 : if we're done already, then we can't move anything anymore for L2
    • And we have y(p1,t) <= d(t+1) : we can only move things of L1 if we're either already done with L2 or we'll be done after the current period t

    What do you think?

    0
  • Ronald van der Velden
    • Gurobi Staff

    For completeness: I believe if you stayed with your existing approach, you would need to model the second constraint as y(p, t) * e(L1) <= t to make it work. Whenever y(p,t)=0 the constraint becomes irrelevant since the left side is 0. When y(p,t)=1 then it forces e(L1) to be less or equal to t. This will make it a lowerbound on all times in which you move a product. I'm saying "lowerbound" because it doesn't necessarily represent the earliest time but may be smaller than that. Combined with your w(L2)<=e(L1) that should not be a problem. Now there's a product of a binary and a continuous variable in your constraint, but there are tricks to linearize this, e.g. see our webinar.

    0

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