How to get the current LP bound in an user callback (cplex)?

Dear community,

I have a MIP in which I add cuts in a user callback (using JuMP 0.18.5, CPLEX 0.5, MathProgBase 0.7.7). I would like to retrieve the LP bound in the current node of the B&B tree, e.g., by doing something like CPXgetcallbacknodeobjval().

In the documentation of MathProgBase I only found cbgetlpsolution which returns a vector of the current variable values, or cbgetbestbound which returns the objective value of the best remaining node by calling CPX_CALLBACK_INFO_BEST_REMAINING.

Did I miss something in the documentation? Do you have any other suggestions how to get the bound?

Thank you in advance, Michael

I’m not sure if there is a good solution. You could compute it from the LP solution.

We’ve had a lot of issues about missing specific functionality in the callbacks, which is one reason that they are missing from JuMP 0.19 until we can figure out a better solution.

Thank you, I also thought about just computing it, which is hopefully not too costly.

I also thought about manually calling the function I need, but I do not really know how. Essentially CplexSolverInterface.jl does the same. So assuming that cb::CPLEX.CplexCutCallbackData would not it be possible to call something like the following in the callback

val::Cdouble = 0.0
ret = @cpx_ccall(getcallbacknodeobjval, Cint, (Ptr{Cvoid},Ptr{Cvoid},Cint,Ptr{Cvoid}),
                              cb.cbdata.model.env.ptr, cb.cbdata.cbdata, cb.where, val)

?

Sure. There might be some subtle details to work through, but in general the approach you outline should work.

You probably need to pass

val = Ref{Cdouble}()

instead of val::Cdouble. There are other examples of this in the callbacks.jl file in CPLEX.jl.

1 Like

Finally, I had the time to test it. Thank you, it works with

val = Ref{Cdouble}()                                                      #pointer
ret = CPLEX.@cpx_ccall(getcallbacknodeobjval, Cint, (Ptr{Cvoid},Ptr{Cvoid},Cint,Ptr{Cvoid}),
                              cb.cbdata.model.env.ptr, cb.cbdata.cbdata, cb.where, val)

and then fetching the value from the pointer,

myval = val[]