# Help me with repeated index

**URL:** https://discourse.julialang.org/t/help-me-with-repeated-index/35339
**Category:** Optimization (Mathematical)
**Created:** [February 29, 2020, 8:53pm UTC](https://discourse.julialang.org/t/help-me-with-repeated-index/35339 "2020-02-29T20:53:04Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![varun\_yaramasu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/varun_yaramasu/32/10336_2.png) [@varun\_yaramasu](https://discourse.julialang.org/u/varun_yaramasu)
#### Post date: [February 29, 2020, 8:53pm UTC](https://discourse.julialang.org/t/help-me-with-repeated-index/35339/1 "2020-02-29T20:53:04Z")

</div>

```julia
using JuMP,SCS

m=Model(with_optimizer(SCS.Optimizer))

branch=[1 2 0.1
        3 4 0.1 
        4 5 0.2
        4 6 0.3
        5 6 0.1
       ]

```

If we want only the first column of the branch, what we have to do ?

I mean , if I write like this this

```julia
S=[(branch[r,1]) for r= 1:size(branch,1)]
@variable(m,v[S])

```

I’m getting the error.

Like this

```julia
ERROR: LoadError: Repeated index 4.0. Index sets must have unique elements.

```

Please help me

---

<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 29, 2020, 9:49pm UTC](https://discourse.julialang.org/t/help-me-with-repeated-index/35339/2 "2020-02-29T21:49:27Z")

</div>

You cannot create a JuMP variable with duplicate indices. See, e.g.,

```nohighlight
model = Model()
@variable(model, x[[:a, :a, :b]])
x[:a] # Which `:a` is this referring to?

```

As [I said in the other post](https://discourse.julialang.org/t/help-me-with-indexing/35203/2), you probably intend

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

```

p.s. Please don’t open multiple posts with the same question: [Help me with indexing - #4 by varun\_yaramasu](https://discourse.julialang.org/t/help-me-with-indexing/35203/4). It can lead to the answers being split over multiple posts.
