In using mode_compute=5 with a problematic model it often happens that we get “Predicted improvement: NaN” then csminit takes forever before the “Try diaogonal Hessian” kicks in.
I have devised this little fix to forgo the csminit computations. It speeds things significantly.
The following two files have been modified from the 4.1.0 version.
In newrat.m, the input badg is set to -1 so csminit knows we’re using newrat (so as not to screw up mode_compute=4).
In csminit.m, lines (at 62)
if badg == -1 %Fix NaN
ratto = 1;
badg = 0 ;
ratto = 0;
are added to put badg back.
then lines (at 114)
** if isnan(dfhat) & ratto %Fix NaN
fhat = f0;
retcode = 99;
are added to return early.
All changes are marked with: %Fix NaN
Hope this helps. Feel free to use that as you like.