# writeMPS()

**URL:** <https://discourse.julialang.org/t/writemps/21669>\
**Category:** General Usage\
**Tags:** question\
**Created:** [March 9, 2019, 9:59am UTC](https://discourse.julialang.org/t/writemps/21669 "2019-03-09T09:59:30Z")\
**Posts on this page:** 1\
**Showing post:** 4

<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 9, 2019, 7:01pm UTC](https://discourse.julialang.org/t/writemps/21669/4 "2019-03-09T19:01:51Z")

</div>

I will add some documentation, but in the mean time:

```julia
using JuMP, MathOptFormat
jump_model = JuMP.Model()
@variable(jump_model, x)
@constraint(jump_model, con1, 2x <= 1)

mps_model = MathOptFormat.MPS.Model()
MOI.copy_to(mps_model, JuMP.backend(jump_model))
MOI.write_to_file(mps_model, "my_model.mps")

```

@mlubin If we wanted to streamline things, we could make MathOptFormat a dependency of JuMP, and then have an API like

```julia
JuMP.write_to_file(model::Model, filename::String)

```

We could detect the file extension and dispatch to the appropriate MathOptFormat model type.

---

_[View the full topic](https://discourse.julialang.org/t/writemps/21669)._
