Solve_time is not working - JuMP

I have updated Julia version to 1.0 and I have tried to find the new way to get the solve time reported by the solver, in my case Clp.
I have tried to use the fonction solve_time(model::Model) as described in documentation but I got the following error:

UndefVarError: solve_time not defined
top-level scope at Main.jl:2525

Other fonctions like numvar() and num_constraints() works well.

Could you give a more complete example, and share what version of JuMP you’re using?

I have been using Julia 1.2.0 in Atom. The version of JuMP is “0.19.2”. I cannot updated JuMP because I have to use Clp solver that it’s not available to newest versions.
My problem is a LP. I could get the number of variables and constraints easily but when I have tried to apply the function


I got the error…

solve_time was added in JuMP v0.20, it’s not accessible in JuMP v0.19.x

1 Like

Do you know how i could get the information about solve time in this version then ? I didn’t find it in the documentation…I could alternatively use
elapsed = time() - start
but if there is another option, it could be better.

You could try the implementation of solve_time directly.


I have done as suggested and I have tested in a huge LP problem, it takes about 3 hours to finish to solve but this function solve time indicates only 29.3 seconds…

function solve_time(model::Model)
    return MOI.get(model, MOI.SolveTime())
solvetime = solve_time(model)

It’s an error in my interpretation?

MOI.SolveTime only measures the time spent inside the solver. It does not measure the time JuMP spends building your model.

However, it shouldn’t take 3 hours to build if it only takes 30 seconds to solve. Can you share more details about your problem? Which solver are you using? (Take a look at the log and check that the times make sense.) How are you building the model? How many variables/constraints etc?

I have been using Clp solver.
My problem has about 500k variables and 900kconstraints.
I have made it to compare the time:

start = time()
status = optimize!(model)
elapsed = time() - start

And the variable elapsed at the end of the simulation is


that it’s about 3 hours.
I have constructed my problem with many AffExpressions.

I have also experienced a large slowdown in Clp model building in the JuMP 0.19 series (versus 0.18). There are already a few PRs for Clp and MathOptInterface that look like they might address performance in the future, so I’ve been waiting for those before trying to produce MWE and filing issues.

In the meantime, a simple workaround for me has been to use Cbc instead. Cbc still uses Clp for LPs, but has a different JuMP interface package that is much faster for building models in my experience.

1 Like

The slow-down in the Clp wrapper is a known issue. It needs to be re-written from scratch for the latest version of MOI, and to remove LinQuadOptInterface, similar to recent rewrites of Gurobi and GLPK.

The underlying problem was that MOI changed considerably since the wrappers were first written, and the changes focused on correctness rather than performance. Now that MOI is stable, we can re-write to focus on performance.


@jayce_ram consider using GLPK instead to see if that makes a difference.

1 Like

I have switched to Cbc as suggested and I had a very expressive gain. My problem is solved now with Cbc in some seconds, instead of 3 hours with Clp. Thanks!