I'm using CPLEX python API to solve an optimization problem. The model is named DOT. When I run DOT.solve(), many information occur in the python console:
Iteration log ...
...
Network - Optimal: Objective = 1.6997945303e+01
Network time = 0.48 sec. (91.93 ticks) Iterations = 50424 (8674)
...
My question is that is there an easy way to get value of the elapsed time (i.e., 0.48 in my case)? And not just for the network optimizer, but for dual method, barrier method too.
I'm very new to python and CPLEX, and I'm very grateful for any help.
To get the total solve time (in wall clock time), you can use the get_time method. To get the value for "Network time", as displayed in the log output, you'll have to parse the log output. Here's an example that demonstrates both of these:
That should give you an idea of how to parse out other pieces of information from the log (it is not meant to be an example of a sophisticated parser).
You may be interested in get_dettime as well; it can be used the same way as
get_time
(as above), but is not susceptible to the load on your machine.