# MPB Callback for both heuristic solution and lazy constraint

**URL:** <https://discourse.julialang.org/t/mpb-callback-for-both-heuristic-solution-and-lazy-constraint/12815>\
**Category:** Optimization (Mathematical)\
**Tags:** jump\
**Created:** [August 2, 2018, 9:36am UTC](https://discourse.julialang.org/t/mpb-callback-for-both-heuristic-solution-and-lazy-constraint/12815 "2018-08-02T09:36:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mbesancon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbesancon/32/6528_2.png) [@mbesancon](https://discourse.julialang.org/u/mbesancon)\
**Post date:** [August 2, 2018, 9:36am UTC](https://discourse.julialang.org/t/mpb-callback-for-both-heuristic-solution-and-lazy-constraint/12815/1 "2018-08-02T09:36:17Z")

</div>

Is it possible to have a callback add a heuristic solution and a constraint using MathProgBase?  
It seemed unclear how to register it in that case, using `setlazycallback!` or `setheuristiccallback!`

---

<div class="post-metadata">

**Author:** ![miles.lubin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/miles.lubin/32/279_2.png) [@miles.lubin](https://discourse.julialang.org/u/miles.lubin)\
**Post date:** [August 2, 2018, 11:50pm UTC](https://discourse.julialang.org/t/mpb-callback-for-both-heuristic-solution-and-lazy-constraint/12815/2 "2018-08-02T23:50:21Z")

</div>

By default, no, the callbacks need to be separate. It may or may not be possible to work around this restriction depending on what the underlying solver supports. If you generate solutions inside the lazy constraint callback, you could store them and give them to the solver in the next heuristic callback. That’s what [Pajarito](https://github.com/JuliaOpt/Pajarito.jl) does.
