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

infeasible results without t0 constraints, errors with using t 0 constraints

回答済み

コメント

4件のコメント

  • 正式なコメント
    Simranjit Kaur
    • Gurobi Staff
    This post is more than three years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum. Or why not try our AI Gurobot?.
  • Jaromił Najman
    • Gurobi Staff

    Hi Nelly,

    The list \(\texttt{fct}\) holds the item \(\texttt{(1,1,0)}\). Thus when you iterate over it in this specific constraint, your program tries to access \(\texttt{alloc[1,1,-1]}\) which is not present causing the \(\texttt{KeyError}\).

    Additionally, you are building the quicksum incorrectly. Your code

    (gp.quicksum(alloc[f, c, t]  <= (capacityTOStorePerGP - (alloc[f,c,t-1] - adm[c,t-1])) for f,c,t in fct))

    would try to produce the constraint

    \[\sum_{f,c,t} \left (a_{f,c,t} \leq c - (a_{f,c,t-1} - a_{c,t-1}) \right )\]

    which is not a valid constraint. Do you mean to construct the constraint

    \[\sum_{f,c,t} \left (a_{f,c,t} - (c - (a_{f,c,t-1} - a_{c,t-1})) \right ) \leq 0\]

    If yes, then the code should read

    (gp.quicksum(alloc[f, c, t]  - (capacityTOStorePerGP - (alloc[f,c,t-1] - adm[c,t-1])) for f,c,t in fct) <= 0)

    Best regards,
    Jaromił

    0
  • Nelly V
    • Gurobi-versary
    • First Comment
    • First Question

    Hi Jaromił Najman,

     

    Thank you for your detailed response. The constraints is so that the allocated doses of vaccines for a clinic needs to be less than the clinic's total storage capacity minus what they already have in their refridgator.

     

    Basically if the storage capacity is 399 and they already have 99 left from the previous allocation,

    this new allocation should be less or equal 300 which doesn't seem to be the outcome from the constraint you suggested?

    In terms of the alloc[1,1,-1], how do you suggest someone to lay out their constraints for p in period? As in, in my example, I want the vaccination process from production to administering the doses to be 2 weeks (14days) and minimise the objective funtion based on that, I hope that makes sense?

    0
  • Jaromił Najman
    • Gurobi Staff

    Hi Nelly,

    Basically if the storage capacity is 399 and they already have 99 left from the previous allocation,

    this new allocation should be less or equal 300 which doesn't seem to be the outcome from the constraint you suggested?

    My point was not referring to the meaning of the constraint but rather to the implementation. You are using the \(\texttt{<=}\) sign inside of the \(\texttt{quicksum}\) function which is not allowed.

    In terms of the alloc[1,1,-1], how do you suggest someone to lay out their constraints for p in period? As in, in my example, I want the vaccination process from production to administering the doses to be 2 weeks (14days) and minimise the objective funtion based on that, I hope that makes sense?

    When working with time periods one usually fixes the first time period, i.e., sets an explicit equality constraint for the 0th time point and then uses constraints depending on the previous time point. An example would be

    \[\begin{align}
    x_0 &= 1\\
     x_{i} &= f(x_{i-1}) \quad \forall i \in {1,\dots,I} \\
    x_{i} &\in \{0,\dots,I\}
    \end{align}\]

    You are using two \(\texttt{t}\) variables in your \(\texttt{for}\)-loop. One is in \(\texttt{period}\) and the other is in \(\texttt{fct}\). The formulation using the \(\texttt{t}\) from the \(\texttt{period}\) set looks promising. You should try to loop over \(\texttt{fc}\) only when constructing constraints.

    Best regards,
    Jaromił

    0

投稿コメントは受け付けていません。