# Get presolved model from Gurobi

**URL:** https://discourse.julialang.org/t/get-presolved-model-from-gurobi/103827
**Category:** Optimization (Mathematical)
**Tags:** question, gurobi
**Created:** [September 13, 2023, 8:11pm UTC](https://discourse.julialang.org/t/get-presolved-model-from-gurobi/103827 "2023-09-13T20:11:51Z")
**Posts on this page:** 1
**Showing post:** 6

<div class="post-metadata">

### Author: ![jd-foster](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jd-foster/32/35824_2.png) [@jd-foster](https://discourse.julialang.org/u/jd-foster)
#### Post date: [September 15, 2023, 1:11am UTC](https://discourse.julialang.org/t/get-presolved-model-from-gurobi/103827/6 "2023-09-15T01:11:14Z")

</div>

There is an internal function to create a “standard form” version for inspecting the problem

```julia
## JuMP.jl/src/lp_sensitivity2.jl:
# Docstring:
# Given a problem:
#
# r_l <= Ax <= r_u
# c_l <= x <= c_u
#
# Return the standard form:
#
# [A -I] [x, y] = 0
# [c_l, r_l] <= [x, y] <= [c_u, r_u]
# 

```

If you have an integral problem first do:

```julia
undo_relax = relax_integrality(rmodel);

```

then you can do

```julia
s = JuMP._standard_form_matrix(rmodel)

```

```julia
julia> keys(s)
(:columns, :lower, :upper, :A, :bounds, :constraints)

```

and

```julia
A = s.A

# If n is the number of variables in the original problem
# and m is the number of affine constraints in the problem
# then
m, p = size(s.A)
# where p == n + m.

# Hence, we can recover the "original" constraint matrix as
rA = A[:,1:(p-m)]

## Restore the original integral problem if necessary with:
undo_relax()

```

In the case of an existing equality constraint at row i, we have that  
`0 = r_l[i] <= y[i] <= r_u[i] = 0`; i.e. `y[i] == 0`.

---

_[View the full topic](https://discourse.julialang.org/t/get-presolved-model-from-gurobi/103827)._
