problem with optimoptions with fmincon

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 Commenti

Did you pass the options structure as an argument to fmincon?
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
I think it will be difficult to help without more information. Can you share some of your code?
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
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.

Accedi per commentare.

Risposte (3)

John Hey
John Hey il 26 Mar 2019
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 il 26 Mar 2019
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 il 26 Mar 2019
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 Commenti

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!
Dear Darren,
Is this correct?
John
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!
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
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

Accedi per commentare.

Prodotti

Release

R2016b

Richiesto:

il 25 Mar 2019

Community Treasure Hunt

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

Start Hunting!

Translated by