# JuMP : how to read a lp problem from file (lp FORMAT) with variables names?

**URL:** <https://discourse.julialang.org/t/jump-how-to-read-a-lp-problem-from-file-lp-format-with-variables-names/133008>\
**Category:** Optimization (Mathematical)\
**Tags:** question, jump\
**Created:** [October 9, 2025, 12:50pm UTC](https://discourse.julialang.org/t/jump-how-to-read-a-lp-problem-from-file-lp-format-with-variables-names/133008 "2025-10-09T12:50:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![LaurentPlagne](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/laurentplagne/32/10103_2.png) [@LaurentPlagne](https://discourse.julialang.org/u/LaurentPlagne)\
**Post date:** [October 9, 2025, 12:50pm UTC](https://discourse.julialang.org/t/jump-how-to-read-a-lp-problem-from-file-lp-format-with-variables-names/133008/1 "2025-10-09T12:50:35Z")

</div>

Hi,

I read a linear problem:

```julia-auto
my_model = JuMP.read_from_file("toto.lp")

```

but it seems that the variable names used in the file are lost and I wonder how to display the solution:

```julia-auto
A JuMP Model
├ solver: none
├ objective_sense: MIN_SENSE
│ └ objective_function_type: JuMP.AffExpr
├ num_variables: 295
├ num_constraints: 639
│ ├ JuMP.AffExpr in MOI.EqualTo{Float64}: 105
│ ├ JuMP.AffExpr in MOI.LessThan{Float64}: 31
│ ├ JuMP.VariableRef in MOI.EqualTo{Float64}: 85
│ ├ JuMP.VariableRef in MOI.GreaterThan{Float64}: 209
│ └ JuMP.VariableRef in MOI.LessThan{Float64}: 209
└ Names registered in the model: none

```

```julia-auto
JuMP.set_optimizer(mrg_model,HiGHS.Optimizer)
optimize!(problem.model)
LP has 136 rows; 295 cols; 522 nonzeros
Coefficient ranges:
  Matrix [1e-02, 1e+01]
  Cost [3e-03, 1e+00]
  Bound [6e-04, 7e+00]
  RHS [3e-04, 6e+00]
Solving LP without presolve, or with basis, or unconstrained
Model status : Optimal
Objective value : -8.0420908334e-01
P-D objective error : 1.2768923006e-16
HiGHS run time : 0.00

```

Any idea ?

---

<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:** [October 9, 2025, 6:59pm UTC](https://discourse.julialang.org/t/jump-how-to-read-a-lp-problem-from-file-lp-format-with-variables-names/133008/2 "2025-10-09T18:59:58Z")

</div>

So “Names registered in the model: none” means that we didn’t store anything in `object_dictionary(model)`, so you can’t do, for example, `model[:x]`.

But variable and constraint names are read, so you can do `variable_by_name(model, "x")`.

To display the solution, you could do:

```Julia
solution = Dict(name(x) => value(x) for x in all_variables(model))

```

---

<div class="post-metadata">

**Author:** ![LaurentPlagne](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/laurentplagne/32/10103_2.png) [@LaurentPlagne](https://discourse.julialang.org/u/LaurentPlagne)\
**Post date:** [October 9, 2025, 7:17pm UTC](https://discourse.julialang.org/t/jump-how-to-read-a-lp-problem-from-file-lp-format-with-variables-names/133008/3 "2025-10-09T19:17:49Z")

</div>

Thank you very much !
