Search code examples
optimizationtimejuliajulia-jump

Is there a way to know how much time is spent in Gurobi usercuts?


I am using JuMP Mathematical Optimization Interface user cuts Callbacks with Gurobi

MOI.set(m, MOI.UserCutCallback(), callback_benders_usercuts)

And I would like to know if there is a way to know how much time is spent in my usercut function callback_benders_usercuts?

usercuts_time = 0
callback_benders_usercuts(arguments)
    usercuts_time += time()
    # ... computing
    usercuts_time += time() - usercuts_time
    return

Doesn't work because, I think, callback_benders_usercuts is called at many nodes and my variable interconnects itself.

I get the following obviously incorrect:

 [ Info: Spent 1.614e9s in User cuts

Solution

  • You want instead

    callback_benders_usercuts(arguments)
        t = time()
        # ... computing
        usercuts_time += time() - t
        return