# Gurobi Error 10005: Unable to retrieve attribute 'Slack'

**URL:** <https://discourse.julialang.org/t/gurobi-error-10005-unable-to-retrieve-attribute-slack/68067>\
**Category:** Optimization (Mathematical)\
**Created:** [September 12, 2021, 11:59pm UTC](https://discourse.julialang.org/t/gurobi-error-10005-unable-to-retrieve-attribute-slack/68067 "2021-09-12T23:59:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![gleyland](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gleyland/32/15339_2.png) [@gleyland](https://discourse.julialang.org/u/gleyland)\
**Post date:** [September 12, 2021, 11:59pm UTC](https://discourse.julialang.org/t/gurobi-error-10005-unable-to-retrieve-attribute-slack/68067/1 "2021-09-12T23:59:04Z")

</div>

Hi,

I’m getting the above error when using Gurobi to solve an LP and then querying the value of a constraint. The LP has been solved such that `@assert(termination_status(𝓜) == MOI.OPTIMAL)` passes. Unfortunately, I haven’t been able to replicate the problem with a small test case yet, so this is more of a “has anyone else seen this?” than a helpful report.

Code that _doesn’t_ exhibit the problem is:

```julia
using JuMP, Gurobi

M = Model(Gurobi.Optimizer)

@variable M a >= 0
@variable M b >= 0

@constraint M c a + b <= 1
@constraint M d a + b <= 1
@constraint M e a + b <= 2
@objective M Max a + 2 * b

optimize!(M)

value(M[:c])
value(M[:d])
value(M[:e])

```

Where I was guessing that perhaps it would have a problem with one of the constraints, but it doesn’t. The model causing the problem works with GLPK, and, until a recent change that I can’t pin down, seemed to work with Gurobi.

Sorry for the vague report, but, any ideas?

Thanks!  
Geoff

---

<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:** [September 13, 2021, 3:06am UTC](https://discourse.julialang.org/t/gurobi-error-10005-unable-to-retrieve-attribute-slack/68067/2 "2021-09-13T03:06:10Z")

</div>

What is `primal_status(M)`? What type was the constraint that it failed on? Do you have a complete stack trace of the error?

This error can arise if you modify a model after optimizing, and then try to query.

---

<div class="post-metadata">

**Author:** ![gleyland](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gleyland/32/15339_2.png) [@gleyland](https://discourse.julialang.org/u/gleyland)\
**Post date:** [September 13, 2021, 3:22am UTC](https://discourse.julialang.org/t/gurobi-error-10005-unable-to-retrieve-attribute-slack/68067/3 "2021-09-13T03:22:25Z")

</div>

> This error can arise if you modify a model after optimizing, and then try to query.

D’oh! That’s it. This is a sequential objective problem and I dropped the last objective because I don’t have any good data on it for this case, but I didn’t remove the bit that added the constraint from the (new) last solve.

This is the second time this stuff has bitten me.

Thanks, as always, @odow

---

<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:** [September 13, 2021, 3:35am UTC](https://discourse.julialang.org/t/gurobi-error-10005-unable-to-retrieve-attribute-slack/68067/4 "2021-09-13T03:35:24Z")

</div>

> This is the second time this stuff has bitten me.

I think in the next version of JuMP we’re going to error or throw a warning, because it’s a pain point that keeps coming up.
