Set ipopt options using matlab interface

1,539 views
Skip to first unread message

Tobia Marcucci

unread,
Mar 16, 2016, 1:21:35 PM3/16/16
to CasADi
Hi all,

a simple question: I would like to increase the maximum number of iterations in IPOPT using matlab. What is the syntax to do that?

I tried this:

nlp = struct('f',cost_fun, 'x',opt_var, 'g',const);
options = struct('max_iter', 5000);
sol = nlpsol('solver', 'ipopt', nlp, options);

but it does not work...

Best,
Tobia

Tobia Marcucci

unread,
Mar 16, 2016, 1:48:27 PM3/16/16
to CasADi
I found the solution:

nlp = struct('f',cost_fun, 'x',opt_var, 'g',const);
options = struct;
options.ipopt.max_iter = 50000;
sol = nlpsol('solver', 'ipopt', nlp, options);

Sorry!

Tobia

Tong Zhao

unread,
Oct 8, 2022, 4:21:55 PM10/8/22
to CasADi
Hi Tobia,

Thank you for sharing. I have a question. I did similar to what you did, and I changed my max_iter from whatever the default is to 200, but it seems that IPOPT still stuck to its original max limit (of 620). See below. Could you see what I did wrong?

Tong

ipopt_max_iter.PNG

Tong Zhao

unread,
Oct 8, 2022, 7:57:47 PM10/8/22
to CasADi
I found the problem. I was not using the struct syntax correctly. I learned this from Joris' youtube  video: https://youtu.be/7iQKhmx7gQA?t=814

The correct syntax is:

plugin_opts = struct('print_time',false);
solver_opts = struct('print_level',1,'max_iter',50);

Problem solved.

Reply all
Reply to author
Forward
0 new messages