Return solve time of intlinprog

4 views (last 30 days)
James Usevitch
James Usevitch on 30 Mar 2022
Answered: Ninad on 22 Sep 2023
Does intlinprog return the solve time of a MILP? I can't seem to find this in the documentation--the solve time is not one of the fields returned by the output struct. I realize that this information is displayed during the solve process, but I'd like to access it programmatically after a solution has been found.
(I'm aware that I can wrap the intlinprog call in tic / toc. But this seems redundant when intlinprog is itself tracking the solve time. There also seem to be issues with using tic / toc in a parfor loop, which I am planning on using.)

Answers (1)

Ninad
Ninad on 22 Sep 2023
Hi James,
As per my understanding you would like to find the solve time of a MILP problem solved using intlinprog’ in MATLAB, without relying on ‘tic’ and ‘toc’.
The intlinprog function in MATLAB does not explicitly track the solve time. It does not provide an output field specifically dedicated to the solve time. Instead, intlinprog relies on the underlying solver to handle the solve process and track the time internally.
You may use the ‘datetime’ function for the same if you are dealing with ‘parfor’ loop.
It returns an array that represents points in time. You can note the time at the begin of thread and note the time just prior to ending the thread and then use simple arithmetic operation to note the runtime of each thread.
I have attached a dummy code in the ‘solveTime.m’ file that uses the ‘datetime’ function to calculate the runtime of each thread created using a ‘parforloop.
You may find detailed documentation for the ‘datetime’ function here: https://in.mathworks.com/help/matlab/ref/datetime.html
I hope this helps.
Thanks,
Ninad.

Products


Release

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!