problem with optimoptions with fmincon
4 次查看(过去 30 天)
显示 更早的评论
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 个评论
Torsten
2019-3-26
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
2019-3-26
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.
回答(3 个)
Darren Wethington
2019-3-26
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 个评论
Darren Wethington
2019-3-27
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
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!