How do I set the initial value of an MVar?
AnsweredIf I'm reading the docs correctly, MVars don't have a Start attribute. Is there an ergonomic way to set their initial values? Do I have to loop over the constituent Vars? Working with the Python version.
0
-
Official comment
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. -
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
Post is closed for comments.
Comments
2 comments