JuMP: save SOL file for MILP

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?

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.

1 Like

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

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

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:

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