# Accessing JuMP variables after reading model from file

**URL:** <https://discourse.julialang.org/t/accessing-jump-variables-after-reading-model-from-file/143020>\
**Category:** Optimization (Mathematical)\
**Tags:** question, jump\
**Created:** [November 19, 2026, 6:38am UTC](https://discourse.julialang.org/t/accessing-jump-variables-after-reading-model-from-file/143020 "2026-11-19T06:38:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jd-foster](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jd-foster/32/35824_2.png) [@jd-foster](https://discourse.julialang.org/u/jd-foster)\
**Post date:** [November 19, 2026, 6:38am UTC](https://discourse.julialang.org/t/accessing-jump-variables-after-reading-model-from-file/143020/1 "2026-11-19T06:38:25Z")

</div>

I haven’t looked into this before now, but when I read an LP file into a JuMP model as e.g.

```julia-auto
m = JuMP.read_from_file("model_test.lp")

```

then [the docs](https://jump.dev/JuMP.jl/stable/manual/models/#Read-a-model-from-file) tell me that the constraints or variable names in the LP file will not be registered or available for accessing as `m[:SomeName]`. Fair enough, but if I don’t really know how the original model is represented in the file, then how should I best work with the model after solving to access variable values?

I can get all the global information on constraint or variable names using

```julia-auto
m.moi_backend.model_cache.model.name_to_con

```

or

```julia-auto
m.moi_backend.model_cache.model.name_to_var

```

but this seems like too much relying on internals? Is there a functional way to pull out sets of variables or constraints (maybe after using some text pattern matching)?

---

<div class="post-metadata">

**Author:** ![jd-foster](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jd-foster/32/35824_2.png) [@jd-foster](https://discourse.julialang.org/u/jd-foster)\
**Post date:** [November 19, 2026, 6:49am UTC](https://discourse.julialang.org/t/accessing-jump-variables-after-reading-model-from-file/143020/2 "2026-11-19T06:49:08Z")

</div>

Ok, so Discourse showed me this answer as soon as I posted: [JuMP : how to read a lp problem from file (lp FORMAT) with variables names?](https://discourse.julialang.org/t/jump-how-to-read-a-lp-problem-from-file-lp-format-with-variables-names/133008)

with Oscar’s nice solution:

```julia-auto
solution = Dict(name(x) => value(x) for x in all_variables(model))

```

or use

```julia-auto
all_constraints(model; include_variable_in_set_constraints=true)

```

I think this is just about ‘findability’ - possibly a good inclusion in the docs in Solutions section and/or Models.
