JuMP: reuse solver objects?

I’m using JuMP to solve lots of (fairly) small problems sequentially. Is there a major reason for/against reusing solver objects? I.e. better (A) or (B):

A

for i in 1:50
   m = Model(solver = CbcSolver())
   ...
   solve(m)
   ...
end

B

s = CbcSolver()
for i in 1:50
   m = Model(solver = s)
   ...
   solve(m)
   ...
end

No, solver objects are lightweight and there’s no performance benefit from reusing them. The main use case for reusing solver objects would be if there are license restrictions on how many concurrent solves you can do, e.g., with Gurobi.

1 Like