# Getting the upper and lower bounds in MILP - JuMP

**URL:** https://discourse.julialang.org/t/getting-the-upper-and-lower-bounds-in-milp-jump/84293
**Category:** Optimization (Mathematical)
**Created:** [July 15, 2022, 11:16pm UTC](https://discourse.julialang.org/t/getting-the-upper-and-lower-bounds-in-milp-jump/84293 "2022-07-15T23:16:37Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![angeloaliano1](https://avatars.discourse-cdn.com/v4/letter/a/7ea924/32.png) [@angeloaliano1](https://discourse.julialang.org/u/angeloaliano1)
#### Post date: [July 15, 2022, 11:16pm UTC](https://discourse.julialang.org/t/getting-the-upper-and-lower-bounds-in-milp-jump/84293/1 "2022-07-15T23:16:37Z")

</div>

Hello everyone,  
When I use `JuMP v0.21.7` with the `Gurobi` solver and optimize a MILP, how do I get, after optimization:

1. The value of the first upper bound (of the first incumbent solution).
2. The value of the first lower bound (from the first incumbent solution).
3. The value of the upper limiter at the end of the run.
4. The value of the lower limiter at the end of the run.  
(see the figure below in a maximization problem)

 ![image](https://global.discourse-cdn.com/julialang/original/3X/e/9/e9ce9200e2d47b2ae4b5866ecf8f7bbdf95d6a6a.png)

My intention is to study how the lower and upper bounds change as the Gurobi optimizes.  
Thank you very much!

---

<div class="post-metadata">

### Author: ![mtanneau](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mtanneau/32/17787_2.png) [@mtanneau](https://discourse.julialang.org/u/mtanneau)
#### Post date: [July 16, 2022, 12:13am UTC](https://discourse.julialang.org/t/getting-the-upper-and-lower-bounds-in-milp-jump/84293/2 "2022-07-16T00:13:03Z")

</div>

There is no function in JuMP that allows you to query the _first_ primal / dual bound.  
The functionalities that are exposed are the following:

- Querying the [objective value of the best solution](https://jump.dev/JuMP.jl/stable/manual/solutions/#Objective-values)
- Querying the [best dual bound](https://jump.dev/JuMP.jl/stable/manual/solutions/#Objective-values)
- Querying the value of [multiple solutions](https://jump.dev/JuMP.jl/stable/manual/solutions/#Multiple-solutions), when multiple solutions are available. Note that this means _the value of the variables_ in those solutions. You will not be able to access _when_ such solutions were found, not the order in which they were obtained.

All three are valid only _after_ the optimization is done. Check JuMP’s [recommended workflow](https://jump.dev/JuMP.jl/stable/manual/solutions/#Recommended-workflow) for how to query them.

If you want to track the progress of the primal / dual bound over time, I can think of two options (assuming you use Gurobi):

- Use a [Gurobi-specific callback](https://github.com/jump-dev/Gurobi.jl#callbacks): this will allow you to query information such as current upper and lower bound each time your callback is called. You will have to hook into Gurobi’s API directly.
- Outside JuMP: if you’re OK with plotting progress after the fact, you may find Gurobi’s [grblogtools](https://github.com/Gurobi/grblogtools) useful.
