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

An indice problem: TypeError: tuple indices must be integers or slices, not tuple

回答済み

コメント

5件のコメント

  • 正式なコメント
    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,

    You are using \(\texttt{math.inf}\) which is not compatible with Gurobi objects. You have to replace \(\texttt{math.inf}\) with \(\texttt{GRB.INFINITY}\). Still, the equality constraints you construct would be infeasible in this case, thus it would be best to omit the constraints were \(\texttt{b = inf}\).

    m.addConstrs( gp.quicksum([x[j,t] for t in time]) == 
    normal_durations[activities.index(j)] - b[activities.index(j)]*activity_decrease[j]
    for j in activities if b[activities.index(j)] != math.inf )

    Best regards,
    Jaromił

     

    0
  • Cevat Enes Karaahmetoğlu
    • Gurobi-versary
    • First Comment
    • First Question

    Hi Jaromil, 

    Thanks for your correction. But there must be some other mistakes, since I've still got this error message after the correction. 

    I tried to reach out x values from console and got following:

    x

    Here is the some part of the output:

    But when I reach out an object with clarifying its indices, I got the same error as well. Is there any mistake about calling the object ?

     

    Best,

    Cevat Enes

     

    0
  • Jaromił Najman
    • Gurobi Staff

    Hi Cevat,

    I am not sure what you mean by "reach out an object with clarifying its indices" but could you try calling the model.update() after adding the variables?

    Best regards,
    Jaromił

    0
  • Cevat Enes Karaahmetoğlu
    • Gurobi-versary
    • First Comment
    • First Question

    Hi Jaromil,

    Sorry for not clear explanation..

    I realized a difference in object type of these variables.Then I saw a comma after defining x variables. After I removed it, it seems OK, I got no error from there. So, thank you for all help :)

     

     

    Best,

    Cevat Enes

    0

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