CPU time vs Wallclock

Hello there
solve_time does not return the CPU time even if I set set_optimizer_attribute(model, “CPXPARAM_ClockType”, 1) # CPU clock time
when using CPLEX.
is there any way to get CPU time in Jump from whatever solver it is being used !
Thank you in advance.

If by solve_time you mean JuMP.solve_time(model), then yes, this returns the wall clock time.

Yeah but how to get the cpu time?

I’m not aware of any functionality in CPLEX that can return the elapsed CPU time.

See this page from IBM support:

If you can find a way to query it via the C API then please post it below and I can help translate it to Julia.

not sure how relates to my question.
The question is not CPLEX itself which indeed provided the functionality to do that if used via C++ interface.
The question concerns Jump, how it can get me CPU time.
Thank you anyway.

relevant to my question?

JuMP does not provide tools to query CPU time. We provide access to wall time.

To get the CPU time, you would need to query the solver. JuMP does not know, for example, how many cores the solver used. CPLEX does not provide this information. (But other solvers may do.)

Why do you need CPU time? In almost every case, wall time is a better measure.

CPLEX itself which indeed provided the functionality to do that if used via C++ interface.

What was the syntax? Is it available via the C API?

Ilocplex: getCplexTime.
The clock type also needs to be set.
It is only for C++ interface as far as I know

It looks like there is https://www.ibm.com/docs/en/icos/20.1.0?topic=g-cpxxgettime-cpxgettime, so you could do:

julia> using JuMP, CPLEX

julia> function get_time(model::JuMP.Model)
           cpx = unsafe_backend(model)
           timestamp_p = Ref{Cdouble}()
           ret = CPLEX.CPXgettime(cpx.env, timestamp_p)
           @assert ret == 0
           return timestamp_p[]
       end
get_time (generic function with 1 method)

julia> model = Model(CPLEX.Optimizer)
A JuMP Model
Feasibility problem with:
Variables: 0
Model mode: AUTOMATIC
CachingOptimizer state: EMPTY_OPTIMIZER
Solver name: CPLEX

julia> @variable(model, x >= 0)
x

julia> set_attribute(model, "CPXPARAM_ClockType", 1)

julia> start_time = get_time(model)
13.19

julia> optimize!(model)
CPLEX Error  3003: Not a mixed-integer problem.
Version identifier: 12.10.0.0 | 2019-11-26 | 843d4de
CPXPARAM_ClockType                               1
Tried aggregator 1 time.
LP Presolve eliminated 0 rows and 1 columns.
All rows and columns eliminated.
Presolve time = 0.00 sec. (0.00 ticks)

julia> run_time = get_time(model) - start_time
0.0

I don’t know what the resolution is though.