# Help me with indexing

**URL:** https://discourse.julialang.org/t/help-me-with-indexing/35203
**Category:** Optimization (Mathematical)
**Tags:** jump, indexing, optimization
**Created:** [February 27, 2020, 12:07am UTC](https://discourse.julialang.org/t/help-me-with-indexing/35203 "2020-02-27T00:07:44Z")
**Posts on this page:** 1
**Showing post:** 2

<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: [February 27, 2020, 2:00am UTC](https://discourse.julialang.org/t/help-me-with-indexing/35203/2 "2020-02-27T02:00:43Z")

</div>

`@variable(model, x[1:2, 1:2])` makes a 2-by-2 matrix of variables. It looks like you want

```nohighlight
@variable(model, P[1:size(branch, 1)])
P[3] # Corresponds to (4, 5, 0.2)

```

or

```nohighlight
S = [(branch[r, 1], branch[r, 2]) for r = 1:size(branch, 1)]
@variable(model, P[S])
P[(3, 4)] # Corresponds to (3, 4, 0.1)

```

---

_[View the full topic](https://discourse.julialang.org/t/help-me-with-indexing/35203)._
