problem with optimoptions with fmincon
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Torsten
el 26 de Mzo. de 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
el 26 de Mzo. de 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.
Respuestas (3)
Darren Wethington
el 26 de Mzo. de 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 comentarios
Darren Wethington
el 27 de Mzo. de 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
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!