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

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

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.

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

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