# Show all linear constraints after building JuMP model

**URL:** <https://discourse.julialang.org/t/show-all-linear-constraints-after-building-jump-model/18536>\
**Category:** Optimization (Mathematical)\
**Created:** [December 10, 2018, 8:17pm UTC](https://discourse.julialang.org/t/show-all-linear-constraints-after-building-jump-model/18536 "2018-12-10T20:17:27Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rasoul](https://avatars.discourse-cdn.com/v4/letter/r/bb73d2/32.png) [@Rasoul](https://discourse.julialang.org/u/Rasoul)\
**Post date:** [December 10, 2018, 8:17pm UTC](https://discourse.julialang.org/t/show-all-linear-constraints-after-building-jump-model/18536/1 "2018-12-10T20:17:27Z")

</div>

Hi all,

I want to visualize all linear constraint in my JuMP model. I used ( model.linconstr) command but it gives only a portion of my constraints. I have 454 constraints but (model.linconstr) shows only 36 of these constraints. There is a question mark in the middle of the screen which I think is the sign for not showing all constraints. Can you please let me know how I can visualize all the constraints in my model. Thanks in advance!

All the best,  
Rasoul

---

<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:** [December 10, 2018, 9:18pm UTC](https://discourse.julialang.org/t/show-all-linear-constraints-after-building-jump-model/18536/2 "2018-12-10T21:18:30Z")

</div>

See `JuMP.writeLP` in the [JuMP docs](http://www.juliaopt.org/JuMP.jl/0.18/refmodel.html#methods) for how to write a JuMP model as an LP file.

Alternatively,

```julia
for con in model.linconstr
    println(con)
end

```

---

<div class="post-metadata">

**Author:** ![Rasoul](https://avatars.discourse-cdn.com/v4/letter/r/bb73d2/32.png) [@Rasoul](https://discourse.julialang.org/u/Rasoul)\
**Post date:** [December 12, 2018, 3:02pm UTC](https://discourse.julialang.org/t/show-all-linear-constraints-after-building-jump-model/18536/3 "2018-12-12T15:02:26Z")

</div>

Thanks for the response.  
Is there any way to show variables with their corresponding bounds in JuMP model.  
I tried following but I got an error (i.e., ERROR: type Model has no field variables).

```julia
for var in model.variables
    println(var)
end

```

Thanks in advance!

---

<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:** [December 12, 2018, 3:15pm UTC](https://discourse.julialang.org/t/show-all-linear-constraints-after-building-jump-model/18536/4 "2018-12-12T15:15:58Z")

</div>

`linconstr` is a field in the JuMP `Model` struct. `variables` isn’t. If you’re interested, you can read the source to find what fields are in `Model`. That source is here: [JuMP.jl/JuMP.jl at 7057a02fc28f58fb6aff9db9981a2a79c9b5ffc9 · jump-dev/JuMP.jl · GitHub](https://github.com/JuliaOpt/JuMP.jl/blob/7057a02fc28f58fb6aff9db9981a2a79c9b5ffc9/src/JuMP.jl#L86-L160)

Note that this is an internal implementation detail, and so you shouldn’t rely on these fields staying the same between JuMP versions. In fact, in JuMP 0.19 (the next release), virtually all of these fields change!

The best way to query variable bounds is with [`JuMP.getupperbound`](http://www.juliaopt.org/JuMP.jl/0.18/refvariable.html#methods) (also `getlowerbound`).

If you want to visually inspect the model, writing it out as an LP file is best.

---

<div class="post-metadata">

**Author:** ![Rasoul](https://avatars.discourse-cdn.com/v4/letter/r/bb73d2/32.png) [@Rasoul](https://discourse.julialang.org/u/Rasoul)\
**Post date:** [December 13, 2018, 6:56am UTC](https://discourse.julialang.org/t/show-all-linear-constraints-after-building-jump-model/18536/5 "2018-12-13T06:56:03Z")

</div>

> [@odow](#):
>
> il, and so you shouldn’t rely on these fields staying the same between JuMP versions. In fact, in JuMP 0.19 (the next release), virtually all of these fields change!
> 
> The best way to query variable bounds is w

Thanks for the response!  
I tried “JuMP.getupperbound(x) where x is a variable in my model” but I encountered an error (i.e., x not defined). Can you please explain a little more how I can visually inspect variable bounds after building the model.  
Thanks in advance!

---

<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:** [December 13, 2018, 2:16pm UTC](https://discourse.julialang.org/t/show-all-linear-constraints-after-building-jump-model/18536/6 "2018-12-13T14:16:22Z")

</div>

`getupperbound(x)` will only work if you have a variable called `x`:

```julia
model = Model()
@variable(model, x >= 1)
JuMP.getlowerbound(x) # 1.0

```

The best way to visually inspect the model is to write it to an LP file.
