I am trying to solve a mixed integer linear program via YALMIP using Gurobi optimizer. I solve a problem which has a specific result I know. However, when I start Matlab in my computer for the first time it is being solved in 0.5 seconds. I clear everything and run the code again. The same result is coming in 0.8 seconds. Then, 1 seconds and so on. How can I really fix this? I am clearing the workspace after each run!
Asked
Active
Viewed 50 times
0
-
Provide a [mcve]. Is there anything else running in the background that can affect this? – Sardar Usama Mar 02 '18 at 14:59
-
@SardarUsama Thank you for your answer. I found the reason. Even though Workspace is cleaned, YALMIP needs the following codes: list = whos;for i = 1:length(list);if strcmp(list(i).class,'sdpvar');clear(list(i).name);end;end yalmip('clear') – independentvariable Mar 02 '18 at 15:10
-
What's the reason? – Sardar Usama Mar 02 '18 at 15:12
-
https://groups.google.com/forum/#!topic/yalmip/cJCoBXUUF_4 https://groups.google.com/forum/#!topic/yalmip/VNoBeBKc9vM – independentvariable Mar 02 '18 at 15:30
-
I am using clear. you can be right, maybe clear all can help. However, now I added the yalmip clear command at the end of each iteration. Now it is very fast (and I dont need to clear other necessary variables) – independentvariable Mar 02 '18 at 15:37
-
1Glad to know. Btw you may be interested in knowing what `clear` does with various combinations: https://www.mathworks.com/help/matlab/ref/clear.html#input_argument_d119e123958 – Sardar Usama Mar 02 '18 at 15:40
-
thanks :) I will check that – independentvariable Mar 02 '18 at 16:00