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
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
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 个)

John Hey
John Hey 2019-3-26
Dear Darren,
I could send you the data and the likelihood function, but I do no wish to burden you. It is already great that you are trying to help me.
John

John Hey
John Hey 2019-3-26
Dear Darren,
My need for a solution has overcaome my desire not to bother you unduly.
Here is the likelihood function and another function that it calls. Also here is the data which should be put in an appropriate sub directory ('data from experiment in february 2019') of where you are ruinning the main program.
If you can find the problem, I will buy you a beer!
John

Darren Wethington
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 个评论
John Hey
John Hey 2019-3-27
Dear Darren,
The first. Thanks for correcting me.
I do understand that the log-likelhood takes a hell of a long time to compute. I am not really worried about that. I would just like some intermediate output and for it to stop in my lifetime. We need a loop of size124 because there were 124 subjects in the experiment.
Thanks again.
John
Darren Wethington
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 CenterFile Exchange 中查找有关 Logical 的更多信息

产品


版本

R2016b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by