Jordi
Jordi

Reputation: 351

How to set Gurobi parameter in Pulp

I am using Pulp with Python to specify an LP problem. I want to solve this using Gurobi. The following does work:

prob.solve(pulp.GUROBI_CMD())

However, now I want to specify a MIP Gap. This should be a parameter of the Gurobi solver according to this page.

What is the syntax to define this parameter (at, say, 0.05)?

Edit: I checked this post, but none of the suggestions works:

Hope anyone can give any suggestions on how to tackle this problem!

Upvotes: 3

Views: 5657

Answers (2)

Hannes
Hannes

Reputation: 11

I had the issue myself, but none of the proposed solutions worked. Especially since I tried to pass several parameters, I couldn't figure out the syntax from the proposed solutions.

Deriving from the error message that we need tuples, the following worked for me:

prob.solve(pulp.GUROBI_CMD(options=[('MIPGap', '0.004'), ("TimeLimit", "300"), ("MIPFocus", "1")]))

Hope this helps other people with the same error.

Upvotes: 1

Jordi
Jordi

Reputation: 351

Brought to the idea in a previous comment that the syntax of the "options" parameter might by wrong (thanks!), I found that a correct syntax is:

prob.solve(pulp.GUROBI_CMD(options=[("MIPgap", 0.9)]))

This works! Thanks a lot.

Upvotes: 4

Related Questions