# SOS use on multidimensional arrays

**URL:** https://discourse.julialang.org/t/sos-use-on-multidimensional-arrays/24282
**Category:** Optimization (Mathematical)
**Created:** [May 16, 2019, 1:31pm UTC](https://discourse.julialang.org/t/sos-use-on-multidimensional-arrays/24282 "2019-05-16T13:31:10Z")
**Posts on this page:** 1
**Showing post:** 3

<div class="post-metadata">

### Author: ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)
#### Post date: [May 16, 2019, 2:25pm UTC](https://discourse.julialang.org/t/sos-use-on-multidimensional-arrays/24282/3 "2019-05-16T14:25:40Z")

</div>

In your code, `test` is an `Array{VariableRef, 2}`. But `test[p]` just selects one element, not a vector. This isn’t specific to JuMP. See:

```nohighlight
julia> x = rand(3, 3)
3×3 Array{Float64,2}:
 0.0576085 0.285097 0.125166
 0.701127 0.35993 0.462062
 0.727124 0.182186 0.378751

julia> x[1]
0.05760854662389847

```

As @leethargo says, you need a slice: `test[p, :]` 🙂

p.s. You might want to read [Please read: make it easier to help you](https://discourse.julialang.org/t/psa-make-it-easier-to-help-you/14757). It has some advice of formatting the code in questions and making a minimum working example.

---

_[View the full topic](https://discourse.julialang.org/t/sos-use-on-multidimensional-arrays/24282)._
