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

Error in Setting Objective

回答済み

コメント

1件のコメント

  • Jaromił Najman
    • Gurobi Staff

    Hi Prachi,

    The issue you encounter is because you are adding the variables to Model \(\texttt{m}\) instead of Model \(\texttt{linear}\). The variable addition step should read

    x = linear.addMVar(N, vtype=GRB.CONTINUOUS, lb=0, name='x')

    Moreover, the matrix returned by the getA method is already of type \(\texttt{scipy.sparse}\) in CSR format. Thus, you don't need the line where you convert it to an \(\texttt{np.array}\)

    linear = Model("LP")
    m = read("myLP.lp")
    B = m.getA()
    [...]
    linear.addMConstr(B, x, optr, b)

    Best regards, 
    Jaromił

    0

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