# Recommended way to do callbacks in MIP root node

**URL:** <https://discourse.julialang.org/t/recommended-way-to-do-callbacks-in-mip-root-node/99617>\
**Category:** Optimization (Mathematical)\
**Tags:** jump, gurobi\
**Created:** [May 30, 2023, 5:06pm UTC](https://discourse.julialang.org/t/recommended-way-to-do-callbacks-in-mip-root-node/99617 "2023-05-30T17:06:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![felipecordera](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/felipecordera/32/43701_2.png) [@felipecordera](https://discourse.julialang.org/u/felipecordera)\
**Post date:** [May 30, 2023, 5:06pm UTC](https://discourse.julialang.org/t/recommended-way-to-do-callbacks-in-mip-root-node/99617/1 "2023-05-30T17:06:01Z")

</div>

Hi everyone,

I would like to know whether there are any recommendations in the workflow for the following situation:

I have defined a MIP model along with a solver-independent lazy callback function, and I would like the callback to at least generate “a bunch” of lazy constraints in the root node, and then “normally” during the tree exploration.

To achieve this, what I am doing right now is:

1. I define the MIP model.
2. I add the lazy callback.
3. I relax the MIP model (with relax\_integrality), and I solve it many times (with optimize!) iteratively to manually generate new lazy constraints (added through @constraint).
4. When I am done, I undo the relaxation and call optimize! one last time.

My two questions are:

- Is there any way to perform step 3 “less manually”?
- Should I be concerned about internal modifications/reductions to my model (e.g., due to presolve maybe) because of solving the LP relaxation first, that could impact the correcteness of the callbacks in the subsequent tree exploration, once I undo the relaxation?

Thanks in advance!

---

<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:** [May 30, 2023, 8:47pm UTC](https://discourse.julialang.org/t/recommended-way-to-do-callbacks-in-mip-root-node/99617/2 "2023-05-30T20:47:29Z")

</div>

> Is there any way to perform step 3 “less manually”?

Not really. Solvers do not support callbacks for continuous problems.

> Should I be concerned about internal modifications/reductions to my model

No. If an incorrect solution is returned then that is a bug in the solver. (But you should verify the final solution satisfies all constraints etc because bugs can happen, even in Gurobi.)

> I would like the callback to at least generate “a bunch” of lazy constraints in the root node, and then “normally” during the tree exploration.

Any reason why? I’d just add the lazy constraints during the search process.

---

<div class="post-metadata">

**Author:** ![felipecordera](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/felipecordera/32/43701_2.png) [@felipecordera](https://discourse.julialang.org/u/felipecordera)\
**Post date:** [May 31, 2023, 1:20am UTC](https://discourse.julialang.org/t/recommended-way-to-do-callbacks-in-mip-root-node/99617/3 "2023-05-31T01:20:33Z")

</div>

Thanks for your response.

I am implementing Benders cuts for an integer master problem with continuous subproblem (i.e., the cut-generator LP). I read that good performance can be achieved if “a first wave of cuts” is added considering the linear relaxation of the master problem (i.e., the root node) before restoring integrality requirements (i.e., tree exploration).

---

<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:** [May 31, 2023, 1:36am UTC](https://discourse.julialang.org/t/recommended-way-to-do-callbacks-in-mip-root-node/99617/4 "2023-05-31T01:36:26Z")

</div>

Ah so in the MIP solve you’re still doing Benders decomposition with callbacks, you just want to warm-start the solve with initial set of cuts at fractional first-stage points?

Then yes, that’s a reasonable way to go about the problem.
