Access to CBC's relative mip gap parameter from Python

1,331 views
Skip to first unread message

Ron Kaminsky

unread,
Aug 9, 2013, 2:11:33 PM8/9/13
to or-tools...@googlegroups.com
Hi,

Am I missing something, or is it impossible from the Python interface to access/change the underlying CBC MIP solver's "relative mip gap" parameter?

(Even if this blemish is real, OR-tools is a really useful resource and I'd like to thank everyone responsible for developing it and releasing it to the public!)

Thanks,
Ron

Laurent Perron

unread,
Aug 16, 2013, 7:42:37 PM8/16/13
to or-tools-discuss
Hello, 

This should be straightforward.

mpsolver.SetDoubleParam(MPSolver.RELATIVE_MIP_GAP, <new_value>)
gap = mpsolver.GetDoubleParam(MPSolver.RELATIVE_MIP_GAP)
or the swig part is broken :-)

--Laurent

Laurent Perron | Operations Research | lpe...@google.com | (33) 1 42 68 53 00



--
You received this message because you are subscribed to the Google Groups "or-tools-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to or-tools-discu...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Dmitry Savransky

unread,
Jan 18, 2017, 10:44:32 AM1/18/17
to or-tools-discuss
I'm sorry - I must be missing something really basic here, but how do you actually associate the parameters with a solver instance?

If I have:

from ortools.linear_solver import pywraplp
s1 = pywraplp.Solver('myprob1',pywraplp.Solver.CBC_MIXED_INTEGER_PROGRAMMING)
... (set up of problem) ...
p1 = pywraplp.MPSolverParameters()
p1.SetDoubleParam(p.RELATIVE_MIP_GAP,0.001)
sol1 = s1.Solve()

Regardless of the numerical value used in the SetDoubleParam line, the solution is the same (even for ridiculously high values).  So I'm clearly not associating the parameter with the actual solver instance, but I can't see how that should be done.

Also:  is there a list somewhere of which actual parameters are exposed for each solver?  For CBC, it looks like it's only RELATIVE_MIP_GAP and PRESOLVE?  For SCIP I guess it's everything via SetSolverSpecificParametersAsString?  But how about GLPK?

Thanks for a great piece of software.

Dmitry Savransky

unread,
Jan 23, 2017, 2:04:09 PM1/23/17
to or-tools-discuss
Okay, answering myself:  the params object should be passed as an argument to the Solve() method.  Setting RELATIVE_MIP_GAP still apparently has no effect on my particular problem - will have to keep digging.
Reply all
Reply to author
Forward
0 new messages