# JuMP: save SOL file for MILP

**URL:** <https://discourse.julialang.org/t/jump-save-sol-file-for-milp/101101>\
**Category:** Optimization (Mathematical)\
**Tags:** jump\
**Created:** [July 3, 2023, 1:36am UTC](https://discourse.julialang.org/t/jump-save-sol-file-for-milp/101101 "2023-07-03T01:36:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stuart\_Rogers](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stuart_rogers/32/10694_2.png) [@Stuart\_Rogers](https://discourse.julialang.org/u/Stuart_Rogers)\
**Post date:** [July 3, 2023, 1:36am UTC](https://discourse.julialang.org/t/jump-save-sol-file-for-milp/101101/1 "2023-07-03T01:36:21Z")

</div>

If JuMP solves a MILP using a solver like HiGHS, SCIP, COPT, etc., is it possible to save the solution in a SOL (.sol) file?

> **[SOL file format: solution files](https://www.ibm.com/docs/en/icos/20.1.0?topic=cplex-sol-file-format-solution-files)**
>
> The SOL file format supports solution files.

---

<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:** [July 3, 2023, 2:00am UTC](https://discourse.julialang.org/t/jump-save-sol-file-for-milp/101101/2 "2023-07-03T02:00:06Z")

</div>

There’s no existing code to do this, as far as I’m aware. Of course, it is possible to write your own XML files.

---

<div class="post-metadata">

**Author:** ![Stuart\_Rogers](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stuart_rogers/32/10694_2.png) [@Stuart\_Rogers](https://discourse.julialang.org/u/Stuart_Rogers)\
**Post date:** [July 3, 2023, 2:47am UTC](https://discourse.julialang.org/t/jump-save-sol-file-for-milp/101101/3 "2023-07-03T02:47:03Z")

</div>

An old post says this can be done for Gurobi by passing a parameter (ResultFile) through JuMP.

> <https://stackoverflow.com/questions/43507755/output-sol-file-gurobi-and-julia-jump>

---

<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 3, 2023, 2:52am UTC](https://discourse.julialang.org/t/jump-save-sol-file-for-milp/101101/4 "2023-07-03T02:52:11Z")

</div>

Gurobi’s `.sol` file is not the same as IBM’s:

> **[SOL format - Gurobi Optimization](https://www.gurobi.com/documentation/10.0/refman/sol_format.html)**
>
> SOL format

But sure, there are probably solver-specific ways of writing a solution file, but none that are solver-independent.

You’re better off writing something like this:

```julia
import JSON
solution = Dict(name(x) => value(x) for x in all_variables(model))
write("solution.json", JSON.json(solution))

```
