# Post Processing JuMP results - Transforming JuMP variables

**URL:** https://discourse.julialang.org/t/post-processing-jump-results-transforming-jump-variables/11041
**Category:** Optimization (Mathematical)
**Created:** [May 21, 2018, 12:10pm UTC](https://discourse.julialang.org/t/post-processing-jump-results-transforming-jump-variables/11041 "2018-05-21T12:10:33Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![tfk17lstm](https://avatars.discourse-cdn.com/v4/letter/t/f0a364/32.png) [@tfk17lstm](https://discourse.julialang.org/u/tfk17lstm)
#### Post date: [May 21, 2018, 12:10pm UTC](https://discourse.julialang.org/t/post-processing-jump-results-transforming-jump-variables/11041/1 "2018-05-21T12:10:33Z")

</div>

Hi guys!

I have finished my implementation of my unit commitment problem and I would like to know if there is any possibility of including this kind of plot in my final results:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/e/0/e018b47b700c931b50e571afe290e101bb59b4f7.png)

Extracted from: [Unit commitment - YALMIP](https://yalmip.github.io/example/unitcommitment/)

Basically right know I am accessing to my results as:

for j in 1:T  
println("Dispatch Power in hour “,j,” = ", getvalue(p[:,j]))  
println("Hour “, j, " Startup Cost =”,getvalue(s[:,j]))  
end

But I would like to know if I there is any possibility of transforming the JuMP variable to a normal array o a dataframe in order to plot them.

---

<div class="post-metadata">

### Author: ![crinders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/crinders/32/8434_2.png) [@crinders](https://discourse.julialang.org/u/crinders)
#### Post date: [May 21, 2018, 3:42pm UTC](https://discourse.julialang.org/t/post-processing-jump-results-transforming-jump-variables/11041/2 "2018-05-21T15:42:57Z")

</div>

Have you looked at [Gadfly.jl](https://github.com/GiovineItalia/Gadfly.jl)?

---

<div class="post-metadata">

### Author: ![ExpandingMan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/expandingman/32/866_2.png) [@ExpandingMan](https://discourse.julialang.org/u/ExpandingMan)
#### Post date: [May 21, 2018, 3:48pm UTC](https://discourse.julialang.org/t/post-processing-jump-results-transforming-jump-variables/11041/3 "2018-05-21T15:48:55Z")

</div>

`getvalue` should work on `AbstractArray{JuMP.Variable}` directly, so there is no need to iterate over the elements. `getvalue` will give you an `AbstractArray{Float64}`, and at this point you can do absolutely anything with the data that you want.

---

<div class="post-metadata">

### Author: ![tfk17lstm](https://avatars.discourse-cdn.com/v4/letter/t/f0a364/32.png) [@tfk17lstm](https://discourse.julialang.org/u/tfk17lstm)
#### Post date: [May 22, 2018, 6:48am UTC](https://discourse.julialang.org/t/post-processing-jump-results-transforming-jump-variables/11041/4 "2018-05-22T06:48:11Z")

</div>

Just check it, it works like charm thank you so much 😃

---

<div class="post-metadata">

### Author: ![Vondoe79](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vondoe79/32/11790_2.png) [@Vondoe79](https://discourse.julialang.org/u/Vondoe79)
#### Post date: [June 25, 2018, 4:56am UTC](https://discourse.julialang.org/t/post-processing-jump-results-transforming-jump-variables/11041/5 "2018-06-25T04:56:16Z")

</div>

Hello ExpandingMan,  
Thanks for this tips, however, I tried “println(“solved model results”, getvalue(::AbstractArray{JuMP.Variable}))” but it did not work for me. I keep get the following error; “ERROR: LoadError: MethodError: no method matching getvalue(::Type{AbstractArray{JuMP.Variable,N} where N})”

I have tried searching for this error, but not finding any meaningful help. I shall appreciate your insight regarding this issue. Thank you.

---

<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: [June 25, 2018, 12:53pm UTC](https://discourse.julialang.org/t/post-processing-jump-results-transforming-jump-variables/11041/6 "2018-06-25T12:53:17Z")

</div>

@ExpandingMan meant that instead of

```julia
for j in 1:T
    println("Dispatch Power in hour ",j," = ", getvalue(p[:,j]))
    println("Hour ", j, " Startup Cost =",getvalue(s[:,j]))
end

```

You can go

```julia
@show typeof(p) # Array{JuMP.Variable, 2}
px = getvalue(p)
@show typeof(px) # Array{Float64, 2}
sx = getvalue(s)
for j in 1:T
    println("Dispatch Power in hour ",j," = ", px[:,j])
    println("Hour ", j, " Startup Cost =", sx[:,j])
end

```

---

<div class="post-metadata">

### Author: ![Vondoe79](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vondoe79/32/11790_2.png) [@Vondoe79](https://discourse.julialang.org/u/Vondoe79)
#### Post date: [June 25, 2018, 8:16pm UTC](https://discourse.julialang.org/t/post-processing-jump-results-transforming-jump-variables/11041/7 "2018-06-25T20:16:07Z")

</div>

Thank you clarifying this for me! Have a great week.
