# Confusion with variable indices with JuMP/CPLEX

**URL:** <https://discourse.julialang.org/t/confusion-with-variable-indices-with-jump-cplex/119920>\
**Category:** Optimization (Mathematical)\
**Created:** [September 26, 2024, 1:30pm UTC](https://discourse.julialang.org/t/confusion-with-variable-indices-with-jump-cplex/119920 "2024-09-26T13:30:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mike\_k](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mike_k/32/211864_2.png) [@mike\_k](https://discourse.julialang.org/u/mike_k)\
**Post date:** [September 26, 2024, 1:30pm UTC](https://discourse.julialang.org/t/confusion-with-variable-indices-with-jump-cplex/119920/1 "2024-09-26T13:30:17Z")

</div>

I try to set branching priorities on variables using `CPXcopyorder(env, lp, cnt, indices, priority, direction)`. Particlularly I want to get the indices of the varialbes of the JuMP model in the CPLEX model. I tried:

```julia
index = model[:x].index.value - 1

```

and

```julia
index = CPLEX.column(backend(model), index(model[:x]))- 1

```

both returning the same values for each variable. Are the above statements equivalent or is this just a coincidence? Which one is correct (if any)?

---

<div class="post-metadata">

**Author:** ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)\
**Post date:** [September 26, 2024, 2:35pm UTC](https://discourse.julialang.org/t/confusion-with-variable-indices-with-jump-cplex/119920/2 "2024-09-26T14:35:15Z")

</div>

Accessing the fields of the variable struct directly is most certainly breaching the interface. You should probably be using [`JuMP.index`](https://jump.dev/JuMP.jl/stable/api/JuMP/#JuMP.index), i.e., the second option.
