# Current status with callbacks

**URL:** <https://discourse.julialang.org/t/current-status-with-callbacks/29942>\
**Category:** Optimization (Mathematical)\
**Created:** [October 15, 2019, 2:13pm UTC](https://discourse.julialang.org/t/current-status-with-callbacks/29942 "2019-10-15T14:13:59Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lefteris\_Manousakis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lefteris_manousakis/32/10832_2.png) [@Lefteris\_Manousakis](https://discourse.julialang.org/u/Lefteris_Manousakis)\
**Post date:** [October 15, 2019, 2:13pm UTC](https://discourse.julialang.org/t/current-status-with-callbacks/29942/1 "2019-10-15T14:13:59Z")

</div>

Hi everyone!

I am using JuMP 0.19 and I tried to set up an information callback to retrieve the relaxation value of the root node. After a lot of searching I think I got the picture with the non solver independent callbacks.  
Do you suggest working with 0.18 and MPB or 0.19 MOI and try to set up the callbacks specifically for Gurobi. Is there any drawback if i continue with 0.18?

Thank you in advance,  
Lefteris

---

<div class="post-metadata">

**Author:** ![leethargo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/leethargo/32/6004_2.png) [@leethargo](https://discourse.julialang.org/u/leethargo)\
**Post date:** [October 15, 2019, 2:42pm UTC](https://discourse.julialang.org/t/current-status-with-callbacks/29942/2 "2019-10-15T14:42:47Z")

</div>

There was some recent activity related to solver-independent callbacks (in particular GLPK and Gurobi). But I think these were focused on the functionality of lazy constraints, user cuts and heuristics.

So, if you want something else, I’d guess it would have to be solver-specific in JuMP 0.19 (or 0.20).

The drawback for sticking with 0.18 (while starting a new project) is that this version is no longer actively maintained, I guess.

---

<div class="post-metadata">

**Author:** ![blegat](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/blegat/32/217090_2.png) [@blegat](https://discourse.julialang.org/u/blegat)\
**Post date:** [October 15, 2019, 3:06pm UTC](https://discourse.julialang.org/t/current-status-with-callbacks/29942/3 "2019-10-15T15:06:28Z")

</div>

You can try Gurobi callbacks with [https://github.com/JuliaOpt/Gurobi.jl/pull/258](https://github.com/JuliaOpt/Gurobi.jl/pull/258)  
To use the Gurobi-specific callback with JuMP v0.19 or v0.20, do

```julia
using JuMP
model = direct_model(Gurobi.Optimizer())
...
MOI.set(model, Gurobi.CallbackFunction(), (cb_data, cb_where) -> begin
    ...
end)
optimize!(model)

```

---

<div class="post-metadata">

**Author:** ![Lefteris\_Manousakis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lefteris_manousakis/32/10832_2.png) [@Lefteris\_Manousakis](https://discourse.julialang.org/u/Lefteris_Manousakis)\
**Post date:** [October 15, 2019, 3:43pm UTC](https://discourse.julialang.org/t/current-status-with-callbacks/29942/4 "2019-10-15T15:43:01Z")

</div>

Thank you very much! So, does this mean that we have the complete functionality we had with jump 0.18 for heuristic, user and lazy constraint callbacks?

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [October 15, 2019, 4:01pm UTC](https://discourse.julialang.org/t/current-status-with-callbacks/29942/5 "2019-10-15T16:01:58Z")

</div>

At a high level: yes. In addition, you will have complete access to the low level solver dependent callback.

---

<div class="post-metadata">

**Author:** ![fa-bien](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fa-bien/32/5559_2.png) [@fa-bien](https://discourse.julialang.org/u/fa-bien)\
**Post date:** [January 27, 2020, 8:01am UTC](https://discourse.julialang.org/t/current-status-with-callbacks/29942/6 "2020-01-27T08:01:57Z")

</div>

Thanks for the great work, this functionality is very useful!

Is there a mechanism to control when the callback is called? For instance I would like to try using the callback only when an integer solution is found (typically made possible with Gurobi and CPLEX). Is there any chance to extract that information from the callback’s parameter? (usually called cb\_data)

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [January 27, 2020, 3:52pm UTC](https://discourse.julialang.org/t/current-status-with-callbacks/29942/7 "2020-01-27T15:52:00Z")

</div>

If you use the solver-dependent callbacks, you have this control. If you use the solver-independent callbacks, you don’t. Although we’re considering adding an attribute that you can query to ask.
