fmincon and the Objective function returned NaN warning
조회 수: 19 (최근 30일)
이전 댓글 표시
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
채택된 답변
Matt J
2021년 10월 13일
편집: Matt J
2021년 10월 13일
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
Matt J
2021년 10월 15일
편집: Matt J
2021년 10월 15일
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.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Get Started with Optimization Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!