Thanks @mike_k ! Yes, this would work for this simple example, but I am not sure if it will extend to other container types in https://jump.dev/JuMP.jl/stable/manual/containers/#Containers, as eachindex(.)
seems like the unified way to loop over a generic container.
For example, consider the more complicated case (this particular code snippet runs fine, because I have used the vec
operation for Z
), where each variable is of a different type:
JuMP_variables = vcat(
# λ is a dense axis array over a dictionary of custom types
[BnB_PEP_model[:λ][i_j_λ] for i_j_λ in eachindex(BnB_PEP_model[:λ])],
# ν is a scalar
BnB_PEP_model[:ν],
# Z is a symmetric matrix
vec([BnB_PEP_model[:Z][i_j] for i_j in eachindex(BnB_PEP_model[:Z])]),
# α is sparse axis array that ranges over (i = 1:5, j in 1:i-1)
[BnB_PEP_model[:α][i_j] for i_j in eachindex(BnB_PEP_model[:α]) ]
)
In this particular case, your suggestion will not extend to \lambda and \alpha. I was wondering if there is a unified way to construct these vcat
objects over different types of containers?