Search code examples
pythonpulpglpk

How to set a time limit or relaxation parameter for objective function using GLPK in Python?


I am using pulp interface to run GLPK MIP solver. To solve an objective function I put this: GLPK().solve(problem)

What parameter and how should I use to set time limit or relaxation parameter.


Solution

  • You can use the list options when calling the solver to specify all the options you would like to use.

    For example, with

    prob.solve(pulp.GLPK_CMD(msg=1, options=["--tmlim", "10","--interior"]))
    

    I set the time limit to 10 seconds and I ask explicitly for the interior point method when solving the LP.

    For a complete list of parameters you can check glpsol --help.