problem with optimoptions with fmincon
Show older comments
Dear All,
I am using fmincon within Matlab and I am trying to set options. I give the command
options=optimoptions('fmincon','Display','iter-detailed','Maxiter',100)
before calling fmincon
but it neither displays anything and does not stop after 100 iterations.
What am I doing wrong?
Help! And thanks.
John Hey
5 Comments
Darren Wethington
on 25 Mar 2019
Did you pass the options structure as an argument to fmincon?
Matt J
on 25 Mar 2019
John's comment moved here:
Dear Darren,
Yes, indeed. I should have said earlier that followed that options command with
x=fmincon(llfun,pars0,[],[],[],[],lb,ub,[],options)
Thanks for replying. I do hope you can discover what I am doing wrong.
John
Darren Wethington
on 25 Mar 2019
I think it will be difficult to help without more information. Can you share some of your code?
Torsten
on 26 Mar 2019
John's comment moved here:
Dear Darren,
I really do appreiciate your offer of help. I attach the main program. It reads data and calls a likelihood function which works. There must be a fault in the main program.
Thanks a lot. I do hope that you find out what I am doing wrong.
John
Darren Wethington
on 26 Mar 2019
I don't have the data you try to load or the LogLikelihood11 function, so I commented out the if statement that reads the data and switched the function to:
llfun = @(x)sum(x);
This should give me an idea of what's going wrong. Unfortunately (or fortunately, depending on how you view it), this code correctly displayed the output and stopped after 2 iterations. Thus it may in fact be a problem with the LogLikelihood11 function or your data.
Answers (3)
John Hey
on 26 Mar 2019
0 votes
John Hey
on 26 Mar 2019
0 votes
Darren Wethington
on 26 Mar 2019
0 votes
Your problem is working as you expect it on my machine. The problem for me is the LogLikelihood11 function is iterating at ~2 seconds per iteration over variable sjn on my machine. The problem is that you are iterating this outer loop nsj=124 times. This means that each evaulation of LogLikelihood11 will take ~4 minutes. To get through the 2 iterations you've specified will take 8 minutes, the 100 you specified in your original post will take ~7 hours. See if replacing nsj=124 with nsj=2 behaves as you'd expect.
5 Comments
Darren Wethington
on 26 Mar 2019
Additionally, just a note: You may have seen moderators have moved some of your "answers" to comments on the question. If you'd like to reply to anything someone writes, please use the comments space rather than posting an answer to your question. Thanks!
John Hey
on 26 Mar 2019
Darren Wethington
on 26 Mar 2019
If you are asking if this is the correct way to comment, then yes!
If you are asking if my answer is correct, then possibly!
John Hey
on 27 Mar 2019
Darren Wethington
on 27 Mar 2019
No problem, good luck! My quick advice on how to proceed:
Stop displaying output from LogLikelihood11 if you can; it'll be easier to see where you are in the optimization by only displaying the output from fmincon. Also, check out the Matlab profiler, it can identify the spots your program is taking the longest. Maybe there's a way to save 50% of your time by replacing function calls to fzero? You could get pretty clever with optimization strategies, and this will point you in the right direction. https://www.mathworks.com/help/matlab/ref/profile.html
Categories
Find more on Surrogate Optimization in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!