# JuMP package: Cannot display the values of decision variable

**URL:** <https://discourse.julialang.org/t/jump-package-cannot-display-the-values-of-decision-variable/5745>\
**Category:** Optimization (Mathematical)\
**Tags:** question, announcement, jump\
**Created:** [September 6, 2017, 3:32pm UTC](https://discourse.julialang.org/t/jump-package-cannot-display-the-values-of-decision-variable/5745 "2017-09-06T15:32:24Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Halil1](https://avatars.discourse-cdn.com/v4/letter/h/d9b06d/32.png) [@Halil1](https://discourse.julialang.org/u/Halil1)\
**Post date:** [September 6, 2017, 3:32pm UTC](https://discourse.julialang.org/t/jump-package-cannot-display-the-values-of-decision-variable/5745/1 "2017-09-06T15:32:24Z")

</div>

Hello everyone,

I have coded a mixed-integer linear optimization model.  
I am having trouble displaying the decision variable results.

I have a decision variable:  
@variable(m, 0 \<= Y[i in I,j in J] \<=1)

It is optimally solved and I get results for my other binary decision variable X[i]. However Y does not display. (Which is only 300 by 300 matrix).

Thus, I have tried the following and it is also not working:  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/a/d/ad64333d4cc4ad883c5738dfc1a74b5091149460.png)

Could you please help me with this?  
I need to write Y values in excel file eventually.

Thanks!

---

<div class="post-metadata">

**Author:** ![rdeits](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rdeits/32/286_2.png) [@rdeits](https://discourse.julialang.org/u/rdeits)\
**Post date:** [September 6, 2017, 4:11pm UTC](https://discourse.julialang.org/t/jump-package-cannot-display-the-values-of-decision-variable/5745/2 "2017-09-06T16:11:38Z")

</div>

You have `getvalue(Y[i, j] > 0)`, but you should have `getvalue(Y[i, j]) > 0`.

---

<div class="post-metadata">

**Author:** ![Halil1](https://avatars.discourse-cdn.com/v4/letter/h/d9b06d/32.png) [@Halil1](https://discourse.julialang.org/u/Halil1)\
**Post date:** [September 6, 2017, 7:09pm UTC](https://discourse.julialang.org/t/jump-package-cannot-display-the-values-of-decision-variable/5745/3 "2017-09-06T19:09:59Z")

</div>

Thank you rdeits for the prompt help. You are right.

One code that still does not work  
getvalue(Y) takes forever. On the other side, getvalue(X) works perfect.

As an alternative, when I use the code below, it works:

Matrix=zeros(size(I)[1],size(J)[1])  
for i in I  
for j in J  
Matrix[i,j]=getvalue(Y[i,j])  
end  
end  
Matrix

Any thought what could be the reason for not getting anything from getvalue(Y) ?

---

<div class="post-metadata">

**Author:** ![rdeits](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rdeits/32/286_2.png) [@rdeits](https://discourse.julialang.org/u/rdeits)\
**Post date:** [September 6, 2017, 11:57pm UTC](https://discourse.julialang.org/t/jump-package-cannot-display-the-values-of-decision-variable/5745/4 "2017-09-06T23:57:25Z")

</div>

It’s difficult to answer that without being able to see your code. Can you post a minimal reproducible example that shows the difference in timing?

---

<div class="post-metadata">

**Author:** ![tkoolen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkoolen/32/1603_2.png) [@tkoolen](https://discourse.julialang.org/u/tkoolen)\
**Post date:** [September 7, 2017, 12:58am UTC](https://discourse.julialang.org/t/jump-package-cannot-display-the-values-of-decision-variable/5745/5 "2017-09-07T00:58:35Z")

</div>

I can’t reproduce those performance results. In fact, that appears to be significantly slower than `getvalue(Y)`.

```julia
julia> using JuMP, Clp, BenchmarkTools

julia> m = Model(solver = ClpSolver());

julia> I = 1 : 300; J = 1 : 300;

julia> @variable(m, 0 <= Y[i in I, j in J] <=1)
0 ≤ Y[i,j] ≤ 1 ∀ i ∈ {1,2,…,299,300}, j ∈ {1,2,…,299,300}

julia> solve(m);

julia> @benchmark getvalue($Y)
WARNING: JuMP._getValue has been called on a collection of variables a large number of times. For performance reasons, this should be avoided. Instead of JuMP._getValue(x)[a,b,c], use JuMP._getValue(x[a,b,c]) to avoid temporary allocations.
BenchmarkTools.Trial: 
  memory estimate: 706.77 KiB
  allocs estimate: 52
  --------------
  minimum time: 1.315 ms (0.00% GC)
  median time: 1.438 ms (0.00% GC)
  mean time: 1.690 ms (12.55% GC)
  maximum time: 128.004 ms (97.99% GC)
  --------------
  samples: 2952
  evals/sample: 1

julia> function getvalue_alt(Y, I, J)
              Matrix=zeros(size(I)[1],size(J)[1])
              for i in I
              for j in J
              Matrix[i,j]=getvalue(Y[i,j])
              end
              end
              Matrix
              end
getvalue_alt (generic function with 1 method)

julia> @benchmark getvalue_alt($Y, $I, $J)
BenchmarkTools.Trial: 
  memory estimate: 703.20 KiB
  allocs estimate: 2
  --------------
  minimum time: 3.267 ms (0.00% GC)
  median time: 3.601 ms (0.00% GC)
  mean time: 3.689 ms (1.63% GC)
  maximum time: 7.498 ms (31.97% GC)
  --------------
  samples: 1352
  evals/sample: 1

```

---

<div class="post-metadata">

**Author:** ![Halil1](https://avatars.discourse-cdn.com/v4/letter/h/d9b06d/32.png) [@Halil1](https://discourse.julialang.org/u/Halil1)\
**Post date:** [September 7, 2017, 3:38pm UTC](https://discourse.julialang.org/t/jump-package-cannot-display-the-values-of-decision-variable/5745/6 "2017-09-07T15:38:20Z")

</div>

Thank you both!

getvalue(X) is working but getvalue(Y) is not working at all. In fact, I don’t know how long it is suppose to take to display the results so I kill it after a few minutes. However, assigning its values to Matrix works.

1. 

getvalue(Y) \>\> This does not display anything, it keeps processing it for a long time without any output.

1. This code below works:  
Matrix=zeros(size(I)[1],size(J)[1])  
for i in I  
for j in J  
Matrix[i,j]=getvalue(Y[i,j])  
end  
end  
Matrix
