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?

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

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

```
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.

1 Like