I am debugging optimization routine. I produce a log text file where I track objective function value at each iteration in optimization routine.
Here is the context: I work with a curve fitting problem, with a model that is linear in the four parameter, and polynomial in the X data
Y = PARAM1*X^3+PARAM2*X^2+PARAM3*X+PARAM4
and I run optimization routine on unnoised unbiased data generated from this model so as to test the algorithm.
In log file, first optimization step show no problem. Function evaluations have a double value. At each iteration, 5 function values are calculated (and displayed in log file). From a given iteration, things turn sour: one function evaluation becomes -1#INF although objective function has already been successfully evaluated at this very point (!). In the next iterations, the ‘bad point’ keeps evaluating at -1#INF, and one by one other points also end up evaluated at -1#INF. The calculation of Y at these points is no struggle given the formula and given the fact that they were properly evaluated before.
Also, I suspect another cause, like memory management. Would you have any idea about this, or any advice to track the problem closer?
Edit
I see the first occurrence of -1#INF in log file. Function is evaluated at 5 points at each iteration, but only one of those 5 points is a ‘new point’. When -1#INF first appears, function has already been successfully evaluated at this point.
It looks like
ITERATION N-1
f1 559.011
f2 560.034
f3 562.034
f4 560.342
f5 560.344
ITERATION N
f1 -1#INF
f2 560.034
f3 558.034
f4 560.342
f5 560.344
where at ITERATION N only f3 is a function evaluation at a new point, and f1 is the function evaluation at the same point than is f1 in ITERATION N-1.
Infinity propagates in calculations. The biggest odds are that the polynomial produced -Inf because X was already -Inf. With the biggest odds that this is caused by calculation for X that divided by zero. Work your way back and add code that checks for zero in divisions.