How to get ticks elapsed by CPLEX solver with JuMP?

I would like to call the getDetTime function from IBM Docs on a model, in order to get the amount of deterministic ticks that have elapsed during a call to optimize!. I cannot figure out how to use the new CPLEX.jl API to call this C function. This is my current code:

# set up the model m in direct mode
optimize!(m)

env = backend(m).env
dettime_P = Ref{Cint}()
CPLEX.CPXgetdettime(env, dettime_P)

This returns:

MethodError: no method matching unsafe_convert(::Type{Ptr{Float64}}, ::Base.RefValue{Int32})
Closest candidates are:
  unsafe_convert(!Matched::Type{Ptr{Nothing}}, ::Base.RefValue{T}) where T at refvalue.jl:30
  unsafe_convert(::Type{T}, !Matched::T) where T<:Ptr at essentials.jl:391
  unsafe_convert(::Type{Ptr{T}}, !Matched::Ptr{Tuple{Vararg{T,N}}}) where {N, T} at refpointer.jl:136

How do I fix this?

1 Like

It seems like the number of ticks is stored in a Float64 not a Cint, so you probably should be using dettime_P = Ref{Float64}(), instead of dettime_P = Ref{Cint}(), or something like that.

1 Like