I am very new to Julia and JuMP. I am using CPLEX 12.8 together with my optimization problem.

Instead of using self-defined time function to capture the total time spent in the optimization process, is there a direct way to print out the total time (root+branch-and-cut) of CPLEX?

I try to use SolveTime() in MathOptInterface (v0.8.4) but it didn’t work.

When I typed MathOptInterface.SolveTime(), the result just give me

MathOptInterface.SolveTime().

And when I typed MathOptInterface.SolveTime(problem1), the error said

MethodError: no method matching MathOptInterface.SolveTime(::Model)
Closest candidates are:
MathOptInterface.SolveTime() at path

It would be nice if someone can show me how to correctly use the code since I also need to get the information of relative gap as well.

In MathOptInterface, you should use the get method to query different results from a model (or variable etc.). See the example in the docs where TerminationStatus is queried. SolveTime should work in the same way.

Thank you for your reply. However, I tried the example code, it gave me error again.

Here is what I typed

optimize!(problem1) status = MOI.get(problem1, TerminationStatus()) total_time = MOI.get(problem1, SolveTime())

The error is like this:

UndefVarError: TerminationStatus not defined UndefVarError: SolveTime not defined

I am pretty sure I declare the package already, but I don’t know why I can’t use the get method of MathOptInterface. Could you give me some insight? Thank you.

When I tried the same way to retrieve MIP relative gap, it gave me error again.

gap_info = MOI.get(model, MOI.RelativeGap())

The error message is

MethodError: no method matching get_relative_mip_gap(::CPLEX.Optimizer) Closest candidates are: get_relative_mip_gap(!Matched::LinQuadOptInterface.MockLinQuadOptimizer) at

However, I used the same code to retrieve ObjectiveBound() it works. It seems like some of the attributes are not working. Could you give me some insight about why would this happen? Thank you.

I guess we need to calculate by ourselves. Just use the definition of Gap and manually record the best incumbent and best bound.

I really hope this issue can be solved. It would make things easier to get the value of incumbent, best bound, root relaxation gap and computational time for people who work in MIP problems…Is there anything I can do?