fminicon optimization function and NaN problem

조회 수: 16 (최근 30일)
sal
sal 2017년 8월 28일
댓글: sal 2017년 8월 28일
fminicon optimization and NaN problem ,
I have a function that i am trying to minimize it using the fminicon optimization function and the results return are always NaN, i have debugged the program and checked the reason of the NaN it was because i have some results in the function equal to zero then in the function this results should take log and it will give -inf the when multiplied by zero it will give NaN,
my question is that can i do anything to make the fminicon function overcome the problem of the NaN?
i would really appreciate your help
thanks in advance

답변 (1개)

Alan Weiss
Alan Weiss 2017년 8월 28일
If you give a starting point that is feasible (no NaN values), and use the interior-point algorithm, then fmincon should be able to handle the issue.
You could also write your objective function to explicitly look for the issue and return proper values.
Alan Weiss
MATLAB mathematical toolbox documentation
  댓글 수: 1
sal
sal 2017년 8월 28일
Thank you so much for your reply, Regarding my initial it is feasible because it comes from a searching algorithm.
and for the rewriting the objective function i don't have an idea about how to write the objective function in a way that when it find (log(0)) turn it into a very small value not -inf to avoid the problem in the next step of multiplying the -inf by 0 which produces the NaN problem,
I wonder if there is anyway to put such condition in the objective function code since i have tried multiple ways but still none o them worked.
i would really appreciate if you suggest some way to deal with this issue.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by