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

Decision variable indices as a tuple or a list

回答済み

コメント

4件のコメント

  • 正式なコメント
    Simranjit Kaur
    • Gurobi Staff
    This post is more than two 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 try Gurobot, our chatbot interface offering instant, expert-level support.
  • Matthias Miltenberger
    • Gurobi Staff

    Hi Maide,

    You can pass multiple lists as indices to Model.addVars(). I suggest you try this with a smaller list to understand how the indexing works.

    I hope that answers your question.

    Cheers,
    Matthias

    0
  • Maide Ceren Kaymaz
    • Gurobi-versary
    • First Comment
    • First Question

    Hi Matthias, Matthias Miltenberger thank you for your answer. Is there a way to set tuple indices while adding in a constraint instead of defining as a variable? I'd like to define this variable as Zm,r,t,i but I'd like to use it as Zm,r,t,p(r,l) in the constraint like in the picture above.

    Best,
    Maide

    0
  • Matthias Miltenberger
    • Gurobi Staff

    Hi Maide,

    You can restrict the use of your variables in a conditional sense, by just querying your condition while formulating the constraint:

    addConstrs(x[i] + y[k] = 1 for i in I for k in K if i==k)

    Is this what you're after? Please consider that you cannot rely on (partly) solutions to your problem when formulating the model because this information will only be available after the solving process.

    Cheers,
    Matthias

    0

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