# Using Juniper with Pyomo

**URL:** <https://discourse.julialang.org/t/using-juniper-with-pyomo/19694>\
**Category:** Optimization (Mathematical)\
**Created:** [January 16, 2019, 1:13pm UTC](https://discourse.julialang.org/t/using-juniper-with-pyomo/19694 "2019-01-16T13:13:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Utkarsh\_Konge](https://avatars.discourse-cdn.com/v4/letter/u/eb9ed0/32.png) [@Utkarsh\_Konge](https://discourse.julialang.org/u/Utkarsh_Konge)\
**Post date:** [January 16, 2019, 1:13pm UTC](https://discourse.julialang.org/t/using-juniper-with-pyomo/19694/1 "2019-01-16T13:13:25Z")

</div>

I want to know whether is there a way to use Juniper to solve optimization models generated by Pyomo. Pyomo can generate model file (`problem.lp` or `problem.nl`) which can be passed to some solvers. Does Juniper have such functionality?

---

<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:** [January 16, 2019, 2:29pm UTC](https://discourse.julialang.org/t/using-juniper-with-pyomo/19694/2 "2019-01-16T14:29:50Z")

</div>

Not to my knowledge. Reader/writers for various file formats are in progress at [https://github.com/odow/MathOptFormat.jl](https://github.com/odow/MathOptFormat.jl). Once an NL reader is implemented, and once Juniper updates to MathOptInterface ([MathOptInterface and upcoming breaking changes in JuMP 0.19](https://discourse.julialang.org/t/mathoptinterface-and-upcoming-breaking-changes-in-jump-0-19/4874)), it will be possible.

---

<div class="post-metadata">

**Author:** ![miles.lubin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/miles.lubin/32/279_2.png) [@miles.lubin](https://discourse.julialang.org/u/miles.lubin)\
**Post date:** [January 16, 2019, 2:52pm UTC](https://discourse.julialang.org/t/using-juniper-with-pyomo/19694/3 "2019-01-16T14:52:04Z")

</div>

I demo’d calling a Julia solver using nl files at ISMP 2015: [Jupyter Notebook Viewer](https://nbviewer.jupyter.org/github/JuliaOpt/juliaopt-notebooks/blob/master/notebooks/MathProgBase%20Newton%20solver.ipynb) using [AmplNLReader](https://github.com/JuliaSmoothOptimizers/AmplNLReader.jl). (The code is not ready for serious use and is rendered obsolete by MathOptInterface.)

---

<div class="post-metadata">

**Author:** ![abelsiqueira](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/abelsiqueira/32/47269_2.png) [@abelsiqueira](https://discourse.julialang.org/u/abelsiqueira)\
**Post date:** [January 16, 2019, 3:23pm UTC](https://discourse.julialang.org/t/using-juniper-with-pyomo/19694/4 "2019-01-16T15:23:06Z")

</div>

For continuous problems, you can use [AmplNLReader.jl](https://github.com/JuliaSmoothOptimizers/AmplNLReader.jl) to open the problem and pass it to a solver like **Ipopt** using the function `NLPtoMPB` from package [NLPModelsJuMP.jl](https://github.com/JuliaSmoothOptimizers/NLPModelsJuMP.jl). This only works with `MathProgBase` at the moment (though efforts to update NLPModelsJuMP to use MOI are appreciated).  
MWE:

```julia
using MathProgBase, Ipopt, AmplNLReader, NLPModelsJuMP

nlp = AmplModel("dixmaane.jl")
mpb_model = NLPtoMPB(nlp, IpoptSolver())
MathProgBase.optimize!(mpb_model)

```

The file `dixmaane.nl` can be download [here](https://github.com/JuliaSmoothOptimizers/Optimize.jl/tree/master/examples/ampl).

However, none of this was tested for integer variables and it may require some tinkering.
