Gurobi: Starting from a solution for Mixed Integer Programming Problem by Using Interactive Shell

14 06 2012

As you may know, Gurobi is a powerful solver for MIP formulations. In this post, I will briefly explain how to start simplex algorithm by using an initial solution.

Gurobi can read and write files in “.mst” format for loading/saving solutions. Suppose, you have a formulation and know a good solution for starting. In order to load the solution, you need to write your own .mst file. MST format is easy to handle; click here for reference. You need to start with hash sign (#) and list variable names and their values by placing a space between. Then you can use the following code in interactive shell:

gurobi> m=read(“yourmodelname.lp”)
gurobi> m.read(“yourmstfile.mst”)
gurobi> m.optimize()

Simple, isn’t it? You will see that your solution will be loaded as initial solution.

Now, suppose you have two formulations where only objective functions are different. Then, you can record solution of the first one in mst format. Here:

gurobi> m=read(“yourfirstmodel.lp”)
gurobi> m.optimize()
… stuff stuff
gurobi> m.write(“mymstfile.mst”)
gurobi> n=read(“yoursecondmodel.lp”)
gurobi> n.read(“mymstfile.mst”)
gurobi> n.optimize()

Well you can interrupt first model at any time by pressing Ctrl+C and can apply the same procedure.

Hope it helps, you can ask your questions.

Advertisements

Actions

Information

2 responses

18 11 2016
Yasaman

Hi, thanks a lot for your helpful instructions. I set the format for mst file such as follows,

# Solution for model (null)
# Objective value = 109.17780
x 0
y 0
z 5

But I get the following error,

“Unknown variable ‘x’ in MIP start – ignored”

Can you help me?

Thanks,
Yasaman

21 11 2016
Sertalp Bilal Cay

Hi Yasaman,

I don’t have a working Gurobi version at the moment, but I advise you to post your question to OR-Exchange.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




%d bloggers like this: