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

attribute error '__cindex__' using absolute value and square root

回答済み

コメント

3件のコメント

  • 正式なコメント
    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 try Gurobot, our chatbot interface offering instant, expert-level support.
  • Marika Karbstein
    • Gurobi Staff

    Hi María,

    How did you add your auxiliary variables?
    Doing like this

    import gurobipy as gp
    m = gp.Model("abs")

    x = m.addVars(5, vtype = gp.GRB.CONTINUOUS, name = "x")
    Iabs = m.addVar(vtype = gp.GRB.CONTINUOUS, lb = 0, name = "Iabs")
    I = gp.quicksum(x[i] for i in range(4))
    m.addGenConstrAbs(Iabs, I, "abs")

    would result in the error you mentioned.

    You need to add the auxiliary variable and the constraint also to the model:

    import gurobipy as gp
    m = gp.Model("abs")

    x = m.addVars(5, vtype = gp.GRB.CONTINUOUS, name = "x")
    Iabs = m.addVar(vtype = gp.GRB.CONTINUOUS, lb = 0, name = "y")
    I = m.addVar(vtype = gp.GRB.CONTINUOUS, name = "I")
    m.addConstr(I == gp.quicksum(x[i] for i in range(4)))
    m.addGenConstrAbs(Iabs, I, "abs")

    I hope this helps,
    Marika

    0
  • María Ciudad Alañón
    • Gurobi-versary
    • First Comment
    • First Question

    Thank you very much! It has been very helpful!

    0

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