Start MIP
Answeredgood morning community,
I'm a beginner with gurobi and C++, and I'm having some basic difficulties on how to start a MIP solution, either via (.mst) or (.sol).
I've read the documentation a lot, but even so I'm still having difficulties with how to pass parameters to the variables of my model.
inside the callback I can use setsolution() and usesolution() normally. (I managed to do this)
But what I really need is to avoid presolver and immediately start a solution that I get via heuristics.
To avoid presolver I have used (Presolve=0 and PrePasses=0) inside the gurobi.env file
but it takes a long time to enter the condition if (where == GRB_CB_MIPNODE) { } that I use in the callback to use setsolution();
I can also use GRBvar.set(GRB_DoubleAttr_Start, 1.0); , but how to use .sol and .mst
Anyway, someone could help me with any example with few variables, it would be very useful for me, because from the example I can replicate it in a complete model.
Summing up the question, I need the gurubi to start from a solution that I get from a heuristic.
I am very grateful for all the help already received.
Att. Murilo O. MACHADO
-
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 why not try our AI Gurobot?. -
Hi Murilo,
You can provide a MIP start by using the Var set method and setting the Start attribute before starting the optimization. An example of a C++ code can be found in the sensitivity_c++.cpp example (line 112) and the multiscenario_c++.cpp example (lines 212 & 218).
Alternatively, you can create a .sol or .mst file and read it into the model by using the read method of the Model object.
Best regards,
Jaromił0
Post is closed for comments.
Comments
2 comments