# HiGHS duals for MIPs

**URL:** https://discourse.julialang.org/t/highs-duals-for-mips/88817
**Category:** Optimization (Mathematical)
**Tags:** question, jump
**Created:** [October 17, 2022, 3:22am UTC](https://discourse.julialang.org/t/highs-duals-for-mips/88817 "2022-10-17T03:22:24Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![adow031](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/adow031/32/16403_2.png) [@adow031](https://discourse.julialang.org/u/adow031)
#### Post date: [October 17, 2022, 3:22am UTC](https://discourse.julialang.org/t/highs-duals-for-mips/88817/1 "2022-10-17T03:22:24Z")

</div>

I’m testing out the HiGHS optimizer in JuMP, and have found that HiGHS returns duals (they all seem to be 0) for MIPs. All other optimizers that I’ve used return errors when attempting to find duals of MIPs:

```julia
ERROR: AssertionError: !(model.last_solved_by_mip)

```

I guess my question is whether this is an oversight that will be corrected, or if HiGHS will return valid marginal costs at the MIP solution. (Without the need to fix the integer variables and re-solve.)

The reason that this matters (to me) is that I have code that attempts the fix and resolve approach, but only does so if the model didn’t have any valid duals. So my code thinks that HiGHS is returning valid duals, but it is not.

Thanks.

---

<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 17, 2022, 3:39am UTC](https://discourse.julialang.org/t/highs-duals-for-mips/88817/2 "2022-10-17T03:39:18Z")

</div>

HiGHS does not return duals for MIPs.

You should not query `dual(con)` without first checking `dual_status(model)` to see if a dual solution is available.

If a dual solution is not available, for example, because `dual_status(model) == NO_SOLUTION`, the querying `dual(con)` is undefined behavior that depends on the solver. It might error, or return a placeholder value like `0.0`.

---

<div class="post-metadata">

### Author: ![adow031](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/adow031/32/16403_2.png) [@adow031](https://discourse.julialang.org/u/adow031)
#### Post date: [October 17, 2022, 5:15am UTC](https://discourse.julialang.org/t/highs-duals-for-mips/88817/3 "2022-10-17T05:15:25Z")

</div>

Thanks; I should have probably ‘read the docs’.

I think, at some point, I presumed that the `has_duals(m)` check was to avoid the code crashing, but I had a `try` statement for that…

HiGHS is now passing all my tests – or to be more accurate, my code now has a few fewer bugs.
