I’m interested in the X per se, as a container of a set of Float64 numbers (not depending on some JuMP variable x built beforehand).
julia> import JuMP, Gurobi
julia> model = JuMP.direct_model(Gurobi.Optimizer());
julia> x = JuMP.@variable(model, [i = 1:3, j = i:3], lower_bound = i-j)
JuMP.Containers.SparseAxisArray{JuMP.VariableRef, 2, Tuple{Int64, Int64}} with 6 entries:
[1, 1] = _[1]
[1, 2] = _[2]
[1, 3] = _[3]
[2, 2] = _[4]
[2, 3] = _[5]
[3, 3] = _[6]
julia> JuMP.set_silent(model); JuMP.optimize!(model)
julia> X = JuMP.value.(x)
JuMP.Containers.SparseAxisArray{Float64, 2, Tuple{Int64, Int64}} with 6 entries:
[1, 1] = 0.0
[1, 2] = -1.0
[1, 3] = -2.0
[2, 2] = 0.0
[2, 3] = -1.0
[3, 3] = 0.0
I wonder how could I build such an object easily, e.g. via some syntax resembling [i-j for i=1:3, j=i:3]? Or I’m also okay with standard instatiating procedure such as
X = Vector{Float64}(undef, 6) # instantiate
for i = 1:6 # fill in the entries with concrete numbers
X[i] = rand()
end