Clear Filters
Clear Filters

Decrease step size in lsqnonlin() for presentation.

1 view (last 30 days)
I am using the lsqnonlin optimization function to minimize an objective function with ~50 variables. I'm also making a movie (using OutputFcn with getFrame) to show what is happening the these variables at each iteration (for presentation purposes).
Currently, the algorithm does ~20 iterations before it stops so my video ends up with 20 frames. 20 frames isn't enough if I want a nice smooth movie that is at least 5 seconds long. I figure I need roughly 120 frames (5 sec. * 24 FPS) to get a nice smooth video. The only way I can think to do this is to force the optimization algorithm to do at least 120 iterations.
What options could I play with to force more iterations from lsqnonlin? DiffMaxChange maybe? Note that I don't want to just have it continue doing iterations after a solution is found. Rather, I want the objective function to change less between iterations.
Any help or insight would be greatly appreciated. I don't know much about how these optimization algorithms work.
Regards, Justin

Accepted Answer

Alan Weiss
Alan Weiss on 29 Jan 2013
So you want a less efficient solver, one that takes more function evaluations to find an optimum? I think you are making a mistake in your thinking. You should be happy that lsqnonlin takes so few steps.
You have many options for making a movie. You could show 6 frames of each current frame. Or you could interpolate results, if that makes sense for what you are trying to do, perhaps coloring things different for the interpolated frames.
If you really want to mess up lsqnonlin, and have it converge slowly, or not at all, give an erroneous Jacobian and set the 'Jacobian' option to 'on'. But I think this will not show how the solver works when it is working well.
Alan Weiss
MATLAB mathematical toolbox documentation
  1 Comment
Justin Solomon
Justin Solomon on 30 Jan 2013
Obviously I'm happy that lsqnonlin converges quickly. Thats why I'm using it! As I said above, I just want to make a nice looking movie to demonstrate the process. I thought there might be some way to control the maximum change in x at each iteration. Thanks for your suggestions!
a) Showing repeated frames is the same is just showing a single frame six times as long. This results in a jumpy movie.
b) Interpolating between iterations is good idea. I might try to do this.
c) I agree that providing a bad Jacobian is not a good idea. Basically I want to get from A to B along the same path but with more steps. Changing the Jacobian might take me from A to C.
Thanks again for your thoughts.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!