I have a script that calculates the shortest (optical) path between a startpoint and a set of target points (given a set of arbitrary optically active surfaces between the points). This is done through an iterative process using the fminsearch function (with two optimization veriables, azimuth and elevation angles for the ray direction), and it works very well for the first iteration.
However, for the second iteration I use the azimuth and elevation angles found for the previous ray, which gives a very good initial guess. The fminsearch function still works, but it seems to start out behaving somewhat eratically and in a non-optimal manner. Basically, it seems it starts out taking "very large" initial steps, moving far away from the starting guess, and then optimizing from that point. This leads to the ~20 first iterations of fminsearch to be considerably worse than the starting guess.
I have attached three plots for the first, second, and third optimization iterations. As is seen the first iteration is very effective, while the second and third starts out with a large portion of "unnecessary" iterations (@optimplotfval doesn't seem to plot higher function values than the previous achieved minimum value, but all the intial plateau is the behaviour I've previously described)
Given that I have around 1 million or so points that I'm doing this for it would save a considerable amount of time to elimiate this behaviour. Is this something that anyone has any ideas on, or is it just something I have to live with using fminsearch?