Skip to main content

Gurobi Constraints - 'gurobipy.LinExpr' object has no attribute 'shape'

Answered

Comments

2 comments

  • Riley Clement
    • Gurobi Staff Gurobi Staff

    Hi Yutian,

    If you're not creating constraints using matrix multiplication, then you're better off not using MVars (because using MVars in this way is very slow).  Just use ordinary variables:

    x = mQ.addVars(N,H, vtype = GRB.BINARY, name = "x")
    pi= mQ.addVars(K, Q, N, H, vtype=GRB.CONTINUOUS,lb=0, name="pi")

    This may be enough to resolve the issue.

    If you still have an issue then try adding just one constraint, for some value of l,k,q,i,h.  Then remove pieces of the constraint and try to make it as small as possible while still producing an error.  This will make it easier for you to debug.

    - Riley

    0
  • Yutian He
    • Gurobi-versary
    • Curious
    • Conversationalist

    Hi Riley,

    That works! Thank you so much!

    Best regards,

    Yutian

    0

Please sign in to leave a comment.