How to set running time in Matlab use Yalmip?

1,026 views
Skip to first unread message

Xuhong Yang

unread,
Jun 7, 2016, 3:45:57 AM6/7/16
to YALMIP
Hi, everyone,

I just finished a yalmip code. I can solve small instance very well. I want to solve a larger instance, but I can't find solution after 10 hours. I want to set a running time to stop the programming, for example 300s or 600s, to find a lower bound. I used these code:

tstart =tic;
……………………  

tused
= toc(tstart)  
if tused > 3600    
     
return
end


but I was failed. Do you know how can I solve this problem. Thanks!

mohsen ghalehnoie

unread,
Jun 7, 2016, 4:07:13 AM6/7/16
to YALMIP
Dear Richard,

some of solvers have the maxtime property. for example please see the following code for BMIBNB solver

opt = sdpsettings;
opt.bmibnb

this simple code show the properties of BMIBNB. So, do the similar process for your Solver.

Richard Yang

unread,
Jun 7, 2016, 4:39:59 AM6/7/16
to YALMIP
Dear Mohsen,


Thank you for your fast reply,

Do you know how should I do using  Mosek, Gurobi or CPLEX? I don't understand very clearly.

Thanks!

Richard Yang

mohsen ghalehnoie

unread,
Jun 7, 2016, 4:45:10 AM6/7/16
to YALMIP
you are welcome,

for gurobi it is possible via the following code

opt = sdpsettings;
opt.gurobi.TimeLimit = 3600;
sol = optimize(constraint,obective,opt)

for cplex it think it is available via the code follows,
opt = sdpsettings;
opt.cplex.tilim = 3600;
sol = optimize(constraint,obective,opt)

but, really I do not know about mosek, please see its manual

Richard Yang

unread,
Jun 7, 2016, 5:16:15 AM6/7/16
to YALMIP
I used Gurobi and tried following statements:

opt = sdpsettings;
opt.gurobi.TimeLimit = 3600;
sol = optimize(constraint,obective,opt)

It can't work. Could you please help me check it?

Thank you!

Richard Yang

Richard Yang

unread,
Jun 8, 2016, 5:38:37 AM6/8/16
to YALMIP
I emailed to Johan.  He gave me a method to solve this problem. I just added some part of my code. 

ops = sdpsettings('solver','gurobi','gurobi.TimeLimit',100);
output
=solvesdp(F,obj,ops);

Thanks Johan and Mohsen.


mohsen ghalehnoie

unread,
Jun 8, 2016, 5:44:00 AM6/8/16
to YALMIP
Johan is really a gentleman. I also appreciate his efforts.

Thank you again, Johan.

Johan Löfberg

unread,
Jun 8, 2016, 5:46:43 AM6/8/16
to YALMIP
setting options through sdpsettings is always recommended, as small spelling mistakes and similiar stuff can cause the setting to not be changed when manually editing the options structure. By doing it through sdpsettings, any error will be detect by sdpsettings

mohsen ghalehnoie

unread,
Jun 8, 2016, 5:49:03 AM6/8/16
to YALMIP
Big Like

Richard Yang

unread,
Jun 8, 2016, 5:53:51 AM6/8/16
to YALMIP
Thank you very much! It is helpful!
Reply all
Reply to author
Forward
0 new messages