solver time issue

266 views
Skip to first unread message

Mohamed Heteba

unread,
May 11, 2015, 10:46:48 AM5/11/15
to yal...@googlegroups.com
Hi Johan,

    when i was trying to calculate the time which is taken to construct and solve my MILP optimization problem using YALMIP with Cplex as a solver which is very critical for my application. i used tic in the main code before calling the method which i give the data need to construct the function and this method construct my objective and the constraints using YALMIP and then solve the problem and the method returns the optimized variables. after that in the main code i used toc to get the time elapsed inside the method. something very weird happens which is that time calculated using toc is very very small ' 0.1 s' but the real sensible elapsed time is 4 s and to make sure where all this time difference is elapsed i used the matlab profiler. which also recorded around 4 s for the call of the function and it shows that most of the elapsed time is in the solver option and the solve commands. i run my code for about 25 steps, in each steps this happens but with different values of time but always the real time is much much larger that the calculated time using tic/toc. i tried to change the tic/toc position in the code to be at the start and at the end of the function but also the same results were obtained. so what i want to know, is there something wrong between YALMIP and the tic/toc commands and I used AMPL with Cplex and also Cplex toolbox to solve my problem and i calculated the computation time using tic/toc command and this never happens ? another thing is there another way to calculate the time elapsed in a function without tic/toc commands and the profiler ?

Thanks in advance ... i would really appreciate your help :)

Johan Löfberg

unread,
May 11, 2015, 1:37:53 PM5/11/15
to yal...@googlegroups.com
use

t = tic;
...
toc
(t)


Mohamed Heteba

unread,
May 12, 2015, 10:51:46 AM5/12/15
to yal...@googlegroups.com
yes it works correctly but can i know what was exactly wrong?  as i use tic/toc directly and it always work except this time

Johan Löfberg

unread,
May 12, 2015, 10:54:05 AM5/12/15
to yal...@googlegroups.com
yalmip uses tic/toc internally when calling some solvers, but messes up things. It is a known bug about to be fixed. Safe use of tic/toc (which YALMIP should use internally of course) is to use the toc(t) logic, as it then becomes independent of any other use of tic/toc

Johan Löfberg

unread,
May 12, 2015, 12:05:29 PM5/12/15
to yal...@googlegroups.com
BTW, it sounds as if you are running the code several times but redefining the options structure all the time. Why don't you move that outside the loop? Furthermore, perhaps your code can be improved by using the optimizer framework for precompiled models

Mohamed Heteba

unread,
May 18, 2015, 2:10:43 PM5/18/15
to yal...@googlegroups.com
thank you regarding the hint of moving solver options outside the loop it really make some improvement regarding the computational time but could you please give me a hint regarding 'the optimizer framework for precompiled models' or a keyword to search about it online as i don't know anything about it ... 

Johan Löfberg

unread,
May 18, 2015, 2:13:03 PM5/18/15
to yal...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages