# Reading xpress problem from .lp file into Julia

**URL:** <https://discourse.julialang.org/t/reading-xpress-problem-from-lp-file-into-julia/78664>\
**Category:** Optimization (Mathematical)\
**Tags:** jump\
**Created:** [March 29, 2022, 10:01am UTC](https://discourse.julialang.org/t/reading-xpress-problem-from-lp-file-into-julia/78664 "2022-03-29T10:01:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marie](https://avatars.discourse-cdn.com/v4/letter/m/bc8723/32.png) [@Marie](https://discourse.julialang.org/u/Marie)\
**Post date:** [March 29, 2022, 10:01am UTC](https://discourse.julialang.org/t/reading-xpress-problem-from-lp-file-into-julia/78664/1 "2022-03-29T10:01:42Z")

</div>

I’m reading a problem from .lp into Julia. I’ve tried various xpress.optimizer params - the problem is infeasible. The reason is b/c the model isn’t read exactly as it’s defined in the .lp file - some constraints get modified. I’ve tried enforcing LP format when reading .lp file using:

_model = MOI.FileFormats.Model(format = MOI.FileFormats.FORMAT\_LP)_  
_MOI.read\_from\_file(model, probPath)_

but then set\_optimizer doesn’t like that model as a parameter…so that the code doesn’t run:  
_set\_optimizer(model, ()-\>Xpress.Optimizer(DEFAULTALG = 1, PRESOLVE = 1, logfiset\_optimizerle = “lp.log”))_ - and i’ve tried different options for the optimizer…

Appreciate experts help!!!

---

<div class="post-metadata">

**Author:** ![jdlara-berkeley](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jdlara-berkeley/32/4096_2.png) [@jdlara-berkeley](https://discourse.julialang.org/u/jdlara-berkeley)\
**Post date:** [March 29, 2022, 6:17pm UTC](https://discourse.julialang.org/t/reading-xpress-problem-from-lp-file-into-julia/78664/2 "2022-03-29T18:17:11Z")

</div>

Did you try to load the same LP file with the Xpress API directly. You can do something like this

```julia
using Xpress
prob = Xpress.XpressProblem()
Xpress.readprob(prob, file_name, "")
Xpress.lpoptimize(prob, "")

```

if the problem is still infeasible then it isn’t a JuMP problem.

---

<div class="post-metadata">

**Author:** ![Marie](https://avatars.discourse-cdn.com/v4/letter/m/bc8723/32.png) [@Marie](https://discourse.julialang.org/u/Marie)\
**Post date:** [March 29, 2022, 6:52pm UTC](https://discourse.julialang.org/t/reading-xpress-problem-from-lp-file-into-julia/78664/3 "2022-03-29T18:52:43Z")

</div>

That was extremely helpful. But how can i see the log file or the details from the solver - to make sure that indeed it was solved successfully and obj cost makes sense? i.e. with jump i’m able to do both - specify the log file and to call/output: solution\_summary(model)  
outputting println(prob) is not sufficient:  
Xpress Problem:  
type : LP  
sense : minimize  
number of variables = 248  
number of linear constraints = 113  
number of quadratic constraints = 0  
number of sos constraints = 0  
number of non-zero coeffs = 1365  
number of non-zero qp objective terms = 0  
number of non-zero qp constraint terms = 0  
number of integer entities = 0  
Appreciate your help!

---

<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:** [March 29, 2022, 6:59pm UTC](https://discourse.julialang.org/t/reading-xpress-problem-from-lp-file-into-julia/78664/4 "2022-03-29T18:59:09Z")

</div>

You need

```nohighlight
using JuMP, Xpress
model = read_from_file(probPath)
set_optimizer(model, () -> Xpress.Optimizer(log file = "lp.log"))
optimize!(model)

```

Docs: [Models · JuMP](https://jump.dev/JuMP.jl/stable/manual/models/#Read-a-model-from-file)

If that doesn’t work, can you provide the LP file?

---

<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:** [March 29, 2022, 7:07pm UTC](https://discourse.julialang.org/t/reading-xpress-problem-from-lp-file-into-julia/78664/5 "2022-03-29T19:07:26Z")

</div>

Ah, I see you’ve opened [https://github.com/jump-dev/MathOptInterface.jl/issues/1786](https://github.com/jump-dev/MathOptInterface.jl/issues/1786). Please upload the LP file there.
