Can I see the parameters that fminunc generate in each try of the optimization search?

Hi,
I am using fminunc to optimize a likelihood function which inside has other functions which makes the problem a bit complicated.
When I try the values of all the matrices inside this likelihood with the initial parameters all is correct. With this I mean that I have correct covariance matrices, no zero determinants etc.
However, when I start the optimization process at a certain parameter values I get a singular matrix in one of the equations inside the likelihood.
Therefore, what I would like to do is to observe the vector of parameters being chosen by the fminunc in the iterations.
Is there a way to do this?
Thanks in advance.
Barbara

 採用された回答

Alan Weiss
Alan Weiss 2014 年 5 月 14 日

0 投票

You can write an output function to obtain almost everything you want. However, fminunc takes finite difference steps that the output function will not report; output functions get called at each iteration, not at each step in the process.
If what you really want is to have the solver continue past a singularity, you might try using a different solver. The fmincon interior-point and sqp algorithms are robust to some failures in function evaluation. You need a constraint to run fmincon; feel free to use lb = -Inf, which fmincon accepts as a constraint but which has no bearing on the solution.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation

その他の回答 (2 件)

Barbara
Barbara 2014 年 5 月 15 日
Dear Alan,
so I have dived into this issue and I found that it is quite simple to get the outputs of each iteration. For the case of the likelihood values at each iteration inside the fminsearch (for instance) (it is a simple change of definition for the parameters case) things goes like this:
//create empty matrix global_likelihood_vector = [];
//Settings and call to "fminsearch" ... ...
function [current_likelihood] = myLikelihood(x);
//Calculate likelihood
current_likelihood = ...
//Concatenate current likelihood to vector
//of all likelihoods
global_likelihood_vector = [global_likelihood_vector ; current_likelihood];
end;
And thats it :)

カテゴリ

質問済み:

2014 年 5 月 14 日

回答済み:

2014 年 5 月 15 日

Community Treasure Hunt

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

Start Hunting!

Translated by