# Setting heuristic solution involving symmetric matrix in JuMP callback

**URL:** <https://discourse.julialang.org/t/setting-heuristic-solution-involving-symmetric-matrix-in-jump-callback/69621>\
**Category:** Optimization (Mathematical)\
**Tags:** jump\
**Created:** [October 12, 2021, 1:28pm UTC](https://discourse.julialang.org/t/setting-heuristic-solution-involving-symmetric-matrix-in-jump-callback/69621 "2021-10-12T13:28:50Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![Shuvomoy\_Das\_Gupta](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/shuvomoy_das_gupta/32/10069_2.png) [@Shuvomoy\_Das\_Gupta](https://discourse.julialang.org/u/Shuvomoy_Das_Gupta)\
**Post date:** [October 12, 2021, 2:36pm UTC](https://discourse.julialang.org/t/setting-heuristic-solution-involving-symmetric-matrix-in-jump-callback/69621/3 "2021-10-12T14:36:17Z")

</div>

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](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:

```julia
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?

---

_[View the full topic](https://discourse.julialang.org/t/setting-heuristic-solution-involving-symmetric-matrix-in-jump-callback/69621)._
