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

How do I set the initial value of an MVar?

回答済み

コメント

2件のコメント

  • 正式なコメント
    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.
  • Jaromił Najman
    • Gurobi Staff

    One way of setting the Start attribute for MVar objects is

    import gurobipy as gp
    import numpy as np

    m = gp.Model()

    x = m.addMVar(2)
    A = np.random.rand(2,2)

    m.addConstr(A @ x <= 1)

    start = [0,1]
    x.Start = start
    m.update()
    print(x.Start)

    You could alternatively use the tolist() method and assign each Start value one by one. You could also use a solution file, see How do I use MIP starts?

    Best regards, 
    Jaromił

    1

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