# How to build a constraint with summation?

**URL:** <https://discourse.julialang.org/t/how-to-build-a-constraint-with-summation/41618>\
**Category:** Optimization (Mathematical)\
**Tags:** question, jump\
**Created:** [June 17, 2020, 6:20pm UTC](https://discourse.julialang.org/t/how-to-build-a-constraint-with-summation/41618 "2020-06-17T18:20:39Z")\
**Posts on this page:** 1\
**Showing post:** 14

<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:** [June 29, 2020, 8:57pm UTC](https://discourse.julialang.org/t/how-to-build-a-constraint-with-summation/41618/14 "2020-06-29T20:57:04Z")

</div>

The issue is that

```nohighlight
julia> Q = [8780; 11310; 8600; 12500; 925; 1918; 4026; 5076]
8-element Array{Int64,1}:
  8780
 11310
  8600
 12500
   925
  1918
  4026
  5076

julia> Q[1, 5]
ERROR: BoundsError: attempt to access 8-element Array{Int64,1} at index [1, 5]
Stacktrace:
 [1] getindex(::Array{Int64,1}, ::Int64, ::Int64) at ./array.jl:745
 [2] top-level scope at REPL[2]:1

```

`Q` is a vector with one dimension of length `8`:

```julia
julia> size(Q)
(8,)

```

You can index it `Q[5, 1]` (fifth row, first column), but not `Q[1, 5]` (first row, fifth column).

Here is the Julia documentation for arrays: [Multi-dimensional Arrays · The Julia Language](https://docs.julialang.org/en/v1/manual/arrays/)

---

_[View the full topic](https://discourse.julialang.org/t/how-to-build-a-constraint-with-summation/41618)._
