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

Error when using addConstrs to construct vector constraints

回答済み

コメント

1件のコメント

  • Riley Clement
    • Gurobi Staff

    Hi Magnus,

    The best way to debug this is to set intermediate variables to some values:

    b = B[0]
    t = T[0]
    i = 0

    Then play around with the expression:

    np.transpose(C) @ gamma[b,t,i,:].tolist() - [x_L[b,t], x_S[b,t]] <= normPsi[b,t,:]

    Where does it fail?  What's the smallest piece of it that fails? What are the types of these things?  What are their shapes?  Which pieces are not compatible with each other?

    Do this, and you will find there are incompatibilities between gurobipy.MVar and numpy.matrix.  You can't simply use them interchangeably.  If you use the following then you will not have errors.

    np.transpose(C) @ gamma[b,t,i,:] - gp.hstack([x_L[b,t], x_S[b,t]]) <= normPsi[b,t,:]

    Note that gurobipy.hstack was introduced in v11.

    - Riley

     

    0

サインインしてコメントを残してください。