# Getting value from unregistered variables

**URL:** https://discourse.julialang.org/t/getting-value-from-unregistered-variables/129869
**Category:** Optimization (Mathematical)
**Tags:** jump
**Created:** [June 13, 2025, 9:17pm UTC](https://discourse.julialang.org/t/getting-value-from-unregistered-variables/129869 "2025-06-13T21:17:23Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![nhebel](https://avatars.discourse-cdn.com/v4/letter/n/53a042/32.png) [@nhebel](https://discourse.julialang.org/u/nhebel)
#### Post date: [June 13, 2025, 9:17pm UTC](https://discourse.julialang.org/t/getting-value-from-unregistered-variables/129869/1 "2025-06-13T21:17:23Z")

</div>

Sorry if this has already been asked - I tried searching and re-reading the documentation and couldn’t find anything. I have a model with unregistered variables (though we did assign base names/strings) and I’m trying to figure out if there’s a way for me to access the solution values for those variables. I can’t tell if it’s possible, or if I need to rewrite the variable assignments so that they have registered names.

Thanks!

---

<div class="post-metadata">

### Author: ![slwu89](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/slwu89/32/217323_2.png) [@slwu89](https://discourse.julialang.org/u/slwu89)
#### Post date: [June 13, 2025, 10:02pm UTC](https://discourse.julialang.org/t/getting-value-from-unregistered-variables/129869/2 "2025-06-13T22:02:13Z")

</div>

I’m not sure what your larger goal is but usually I tend to use anonymous variables when I am storing the variables in another data structure, and you can index into a different data structure to naturally retrieve them. For example:

```julia
model = JuMP.Model()

data = DataFrame(i=[1])
data.x = @variable(model, [1:1]) # anon var

# you would optimize it before calling value()

JuMP.value.(data.x)

```

---

<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 13, 2025, 10:43pm UTC](https://discourse.julialang.org/t/getting-value-from-unregistered-variables/129869/3 "2025-06-13T22:43:40Z")

</div>

Hi @nhebel, welcome to the forum 😄

As @slwu89 alludes to, you need _some_ sort of data structure to hold your variables if you want to access them later. You can either use the built-in `model[:x]` data structure if you name your variables like `@variable(model, x)`.

If you use anonymous variables, then you must maintain some sort of external data structure.

There is `variable_by_name(model, "x")`, but you’re probably much better off using your own data structure.

---

<div class="post-metadata">

### Author: ![nhebel](https://avatars.discourse-cdn.com/v4/letter/n/53a042/32.png) [@nhebel](https://discourse.julialang.org/u/nhebel)
#### Post date: [June 16, 2025, 5:13pm UTC](https://discourse.julialang.org/t/getting-value-from-unregistered-variables/129869/4 "2025-06-16T17:13:22Z")

</div>

thank you so much, this is super helpful!
