Search code examples
pythonscipmixed-integer-programming

Set MIP termination gap with PySCIPOpt


I cannot figure out how to set a MIP gap threshold such that the solver will terminate when the relative difference between the primal and dual solutions is within some value. I am using PySCIPOpt to interact with SCIP.

I am sure there is a simple way (for example if I were using Gurobi's python interface it is just m.Params.MIPGap = x, where m is the model instance).

Any help is greatly appreciated!


Solution

  • The MIP gap is a parameter in SCIP (and also PySCIPOpt) and can be set like any other:

    m = pyscipopt.Model()
    m.setRealParam('limits/gap', 0.1)
    

    For the complete list of available parameters either check the SCIP documentation or run this Python code:

    m.writeParams('default.set', onlychanged=False)
    

    To set a paramter you always need to specify the appropriate type in the function call, i.e., Bool, Int, Longint, Real, Char, or String.