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

A bug of setting warm-start basis using gurobipy

回答済み

コメント

3件のコメント

  • 正式なコメント
    Simranjit Kaur
    • Gurobi Staff
    This post is more than two 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.
  • Riley Clement
    • Gurobi Staff

    Hi Cheng,

    Numpy uses its own types, eg

    >>> type(np.array([1])[0])
    numpy.int64

    Numpy is not a dependency of gurobipy (unless matrix API is used) and so we cannot check for this type.  You can however convert individual numpy ints to standard ints using .item()

    >>> type(np.array([1])[0].item())
    int

    but the best course of action in your example is to convert the numpy arrays to lists and set all vbasis and cbasis information in one step, rather than using the enumeration approach which is slow

    model.setAttr("VBasis", model.getVars(), basis.vbasis.tolist())
    model.setAttr("CBasis", model.getConstrs(), basis.cbasis.tolist())

    Depending on your application, it may make sense to convert to lists within your dataclass.

    - Riley

    1
  • Chengwenjian Wang
    • Gurobi-versary
    • First Question
    • First Comment

    Hi Riley,

    Thank you very much for your detailed explanation. It works now!

    Best regards,

    Cheng

    0

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