Return solve time of intlinprog

3 次查看(过去 30 天)
James Usevitch
James Usevitch 2022-3-30
回答: Ninad 2023-9-22
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.)

回答(1 个)

Ninad
Ninad 2023-9-22
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.

类别

Help CenterFile Exchange 中查找有关 Linear Least Squares 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by