# Save solution and warm start

**URL:** <https://discourse.julialang.org/t/save-solution-and-warm-start/70315>\
**Category:** Optimization (Mathematical)\
**Tags:** jump, cplex\
**Created:** [October 25, 2021, 3:01am UTC](https://discourse.julialang.org/t/save-solution-and-warm-start/70315 "2021-10-25T03:01:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brock](https://avatars.discourse-cdn.com/v4/letter/b/a8b319/32.png) [@Brock](https://discourse.julialang.org/u/Brock)\
**Post date:** [October 25, 2021, 3:01am UTC](https://discourse.julialang.org/t/save-solution-and-warm-start/70315/1 "2021-10-25T03:01:35Z")

</div>

I am using JuMP and CPLEX to solve an optimization problem.  
How can I save the best solution found after a certain time limit to a file?  
How can I then use this file as a warm start during another attempt to solve the same problem?

---

<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:** [October 27, 2021, 4:50am UTC](https://discourse.julialang.org/t/save-solution-and-warm-start/70315/2 "2021-10-27T04:50:49Z")

</div>

You can write the solution to a file using the regular Julia tools. There is no specific support in JuMP.

```julia
open("solution.txt", "w") do io
    for x in all_variables(model)
        println(io, value(x))
    end
end

```

```nohighlight
solutions = readlines("solution.txt")
for (line, x) in zip(solutions, all_variables(model))
    set_start_value(x, parse(Float64, line))
end

```

Note that this assumes the variables are in the same order.

p.s. I moved your question to the “Optimization (Mathematical)” section. It gets a little more visibility for JuMP-related questions.
