fmincon and the Objective function returned NaN warning
13 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I minize the negative of a log-likehood function to estimate the parameters of a mixed logit regression model. I use fmincon to estimate the parameters which are the minizing values of the function. Please see the code below.
options = optimset('MaxFunEvals',10000,'TolFun',1e-9,'TolX',1e-9,'Algorithm','sqp','GradObj','off','DerivativeCheck','on','Display','iter');
[theta_hat,fval,exitflag,output,~,grad,hessian] = fmincon(obj,theta_ig,[],[],[],[],lb,ub,[],options);
During the iterations of fmincon, I see the warning "Objective function returned NaN..." few times. At the end, the minimizing values are found. But I still wonder whether I should take the warning as a sign of something going wrong. Am I supposed to never see this warning during the iterations or would it be fair to say that this can happen and does not necesserily point to a problem. In short, how much should I be concerned about the warning?
Objective function returned NaN; trying a new point...
3 93 1.320737e+04 0.000e+00 8.235e-02 2.297e+01 5.692e+04
4 99 1.176385e+04 0.000e+00 1.000e+00 2.141e+01 1.676e+04
5 105 1.162947e+04 0.000e+00 1.000e+00 2.265e+00 2.635e+03
6 111 1.162639e+04 0.000e+00 1.000e+00 4.153e-01 5.914e+01
7 117 1.162633e+04 0.000e+00 1.000e+00 1.436e-01 8.179e+01
8 123 1.162604e+04 0.000e+00 1.000e+00 8.893e-01 4.767e+02
0 Kommentare
Akzeptierte Antwort
Matt J
am 13 Okt. 2021
Bearbeitet: Matt J
am 13 Okt. 2021
The sqp algorithm can recover from NaNs and Infs if your objective and constraint functions are finite on an open domain of x (I don't know about closed domains). The warning is probably just to alert you that the algorithm strayed outside the non-NaN domain of the objective and had to backtrack.
2 Kommentare
Matt J
am 15 Okt. 2021
Bearbeitet: Matt J
am 15 Okt. 2021
There are no conclusions that can be drawn knowing only when in the iteration sequence the NaNs occur. We would need to see the objective function.
However, you say that the minimum is reached regardless of when the NaNs occur. That seems to suggest that the solver is doing its job, and demonstrating the capability that it advertises of recovering from NaNs.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Get Started with Optimization Toolbox finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!