# Trouble trying to serialize JuMP Models to .mps, .lp, .rew formats

**URL:** <https://discourse.julialang.org/t/trouble-trying-to-serialize-jump-models-to-mps-lp-rew-formats/117425>\
**Category:** Optimization (Mathematical)\
**Tags:** jump, serialization\
**Created:** [July 24, 2024, 3:43pm UTC](https://discourse.julialang.org/t/trouble-trying-to-serialize-jump-models-to-mps-lp-rew-formats/117425 "2024-07-24T15:43:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![gangway](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gangway/32/205243_2.png) [@gangway](https://discourse.julialang.org/u/gangway)\
**Post date:** [July 24, 2024, 3:43pm UTC](https://discourse.julialang.org/t/trouble-trying-to-serialize-jump-models-to-mps-lp-rew-formats/117425/1 "2024-07-24T15:43:05Z")

</div>

I am trying to serialize JuMP Models to .mps, .lp, .rew formats via write\_to\_file method. But I am facing the same error with all three conversion while the .nl conversion is successful:

MathOptInterface.UnsupportedConstraint{MathOptInterface.ScalarNonlinearFunction, MathOptInterface.EqualTo{Float64}}: `MathOptInterface.ScalarNonlinearFunction`-in-`MathOptInterface.EqualTo{Float64}` constraint is not supported by the model.

The models that I am using are PGLIB models instantiated as JuMP models.

Would appreciate any support/insight. Thanks!

---

<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:** [July 24, 2024, 9:24pm UTC](https://discourse.julialang.org/t/trouble-trying-to-serialize-jump-models-to-mps-lp-rew-formats/117425/2 "2024-07-24T21:24:18Z")

</div>

Hi @gangway, welcome to the forum!

It looks like your model has a nonlinear equality constraint.

The `.mps`, `.lp`, and `.rew` file formats do not support nonlinear constraints, so you cannot write this model to one of those file formats.

---

<div class="post-metadata">

**Author:** ![gangway](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gangway/32/205243_2.png) [@gangway](https://discourse.julialang.org/u/gangway)\
**Post date:** [July 25, 2024, 4:48pm UTC](https://discourse.julialang.org/t/trouble-trying-to-serialize-jump-models-to-mps-lp-rew-formats/117425/3 "2024-07-25T16:48:32Z")

</div>

I read  
“[Gurobi AddGenConstrPoly() in JuMP](https://discourse.julialang.org/t/gurobi-addgenconstrpoly-in-jump/107123)”

Since my main objective is to solve these models to solve using Gurobi, but trying to solve this JuMP model directly with Gurobi.Optimizer generates the same error.  
Is there any way to bypass this error by working with Gurobi C api during direct\_model()?  
I tried:  
model = direct\_model(Gurobi.Optimizer())  
instantiate model(filepath, model) #To load the model  
JuMP.optimize!(model)

It runs and log indicate that Gurobi is being used, terminal status is 1 but objective function is zero.

“Barrier solved model in 0 iterations and 0.01 seconds (0.00 work units)  
Optimal objective 0.00000000e+00.”

The model works perfectly well with Ipopt and other solvers.

---

<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:** [July 25, 2024, 8:21pm UTC](https://discourse.julialang.org/t/trouble-trying-to-serialize-jump-models-to-mps-lp-rew-formats/117425/4 "2024-07-25T20:21:17Z")

</div>

You cannot read a model from file that contains nonlinear constraints and pass it to Gurobi. You must build it manually.

Gurobi are working on an upcoming version that will support this, but it isn’t ready yet. Perhaps in 6 or 12 months 🙂
