# JuMP, LinearProg, How to get problem data in form min (c^t)x s.t. Ax = b, x \>= 0

**URL:** <https://discourse.julialang.org/t/jump-linearprog-how-to-get-problem-data-in-form-min-c-t-x-s-t-ax-b-x-0/8100>\
**Category:** Optimization (Mathematical)\
**Tags:** jump, optimization\
**Created:** [January 2, 2018, 12:23am UTC](https://discourse.julialang.org/t/jump-linearprog-how-to-get-problem-data-in-form-min-c-t-x-s-t-ax-b-x-0/8100 "2018-01-02T00:23:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![pedroborgesmelo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pedroborgesmelo/32/9459_2.png) [@pedroborgesmelo](https://discourse.julialang.org/u/pedroborgesmelo)\
**Post date:** [January 2, 2018, 12:23am UTC](https://discourse.julialang.org/t/jump-linearprog-how-to-get-problem-data-in-form-min-c-t-x-s-t-ax-b-x-0/8100/1 "2018-01-02T00:23:07Z")

</div>

Hey Guys!

When I model a LP with JuMP, is it possible get the problem data in the form min (c^t)x s.t. Ax = b, x \>= 0 easily ? I mean, with a function already existing?

If not, what is an easy way?

Thanks in advance,

---

<div class="post-metadata">

**Author:** ![joehuchette](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joehuchette/32/32_2.png) [@joehuchette](https://discourse.julialang.org/u/joehuchette)\
**Post date:** [January 3, 2018, 1:39am UTC](https://discourse.julialang.org/t/jump-linearprog-how-to-get-problem-data-in-form-min-c-t-x-s-t-ax-b-x-0/8100/2 "2018-01-03T01:39:46Z")

</div>

You can get the problem data (in a slightly different form as \min\_x c^Tx such that l \leq Ax \leq u and xlb \leq x \leq xub) from the MathProgBase layer. See [this example](https://github.com/JuliaOpt/JuMP.jl/blob/38e8ca88f05b98b93f727d58abf255be2deb08da/examples/old/bnatt350.jl#L40-L47), where you can get it from the JuMP model `mod` with something like

```nohighlight
JuMP.build(mod)
m_internal = JuMP.internalmodel(mod)
c = MathProgBase.getobj(m_internal)
A = MathProgBase.getconstrmatrix(m_internal)
m, n = size(A)
xlb = MathProgBase.getvarLB(m_internal)
xub = MathProgBase.getvarUB(m_internal)
l = MathProgBase.getconstrLB(m_internal)
u = MathProgBase.getconstrUB(m_internal)
vtypes = MathProgBase.getvartype(m_internal)

```

---

<div class="post-metadata">

**Author:** ![pedroborgesmelo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pedroborgesmelo/32/9459_2.png) [@pedroborgesmelo](https://discourse.julialang.org/u/pedroborgesmelo)\
**Post date:** [January 3, 2018, 2:01am UTC](https://discourse.julialang.org/t/jump-linearprog-how-to-get-problem-data-in-form-min-c-t-x-s-t-ax-b-x-0/8100/3 "2018-01-03T02:01:16Z")

</div>

Thanks Joey, but I need to preserve the form for duality reasons…

Maybe this could be a good functionality for JuMP: deliver the problems in  
diferent equivalent formats…

---

<div class="post-metadata">

**Author:** ![miles.lubin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/miles.lubin/32/279_2.png) [@miles.lubin](https://discourse.julialang.org/u/miles.lubin)\
**Post date:** [January 3, 2018, 10:05pm UTC](https://discourse.julialang.org/t/jump-linearprog-how-to-get-problem-data-in-form-min-c-t-x-s-t-ax-b-x-0/8100/4 "2018-01-03T22:05:20Z")

</div>

Transforming between different formats is part of the game if you’re working with LPs. JuMP won’t do this for you, but we’re happy to collect code examples for future reference.

---

<div class="post-metadata">

**Author:** ![pedroborgesmelo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pedroborgesmelo/32/9459_2.png) [@pedroborgesmelo](https://discourse.julialang.org/u/pedroborgesmelo)\
**Post date:** [January 3, 2018, 10:12pm UTC](https://discourse.julialang.org/t/jump-linearprog-how-to-get-problem-data-in-form-min-c-t-x-s-t-ax-b-x-0/8100/5 "2018-01-03T22:12:22Z")

</div>

Hey mlubin!

Thanks… When I have it sufficiently tested I post here…

Best,
