I am running an optimization model using the Python API of CPLEX, docplex.mp.
Right now it looks like this:
from docplex.mp.model import Model
import time
mdl = Model()
# variables, constraints and objective function here
mdl.context.cplex_parameters.threads = 5
mdl.parameters.timelimit.set(3600)
start = time.time()
sol = mdl.solve()
end = time.time()
solver_time = sol.solve_details.time
print("Time directly from solver: ",cpu_time)
print("Time from time.time(): ",end-start)
My goal is to obtain the CPU time, which, since I am using more than 1 thread, I believe it should be different from elapsed time. However, the “print()” operations are returning the same value. How can I obtain the CPU time here instead of the elapsed time? For instance, with docplex.cp it is possible to change the “TimeMode” to “CPUTime”, but it didn’t work here.