Saving status and restart fminsearch

5 views (last 30 days)
Hi,
so here's the situation. I use fminsearch to optimize a function. The computation of this function is long so each iteration takes a while. (The function itself is pretty simple.) The total optimization process usually takes about 1 month. The problem is that, once in a while, there is a power shortage, or some other stuff that shuts downs my computer !
I'm looking for a way to save the status of fminsearch in order to "restart it where it was". From what I understand, there is no automated way to do this (although it could be added in future releases!). I've looked at the code and, from what I understand, it might be possible to save a few matrices (x, v and fv, if I'm not mistaken) every once in a while. My problem is how to restart fminsearch with specifically those matrices...
any suggestions ?
thanks,
Vincent btw, I'm using Matlab R2013a

Accepted Answer

Matt J
Matt J on 22 Jan 2014
Edited: Matt J on 22 Jan 2014
You can use fminsearch's OutputFcn option to save the results of the most recent iteration to disk.
However, I find it highly suspicious that your computation takes a full month. Fminsearch is designed for solving for a small number of variables. It won't give good results if you have more than 6 unknowns or so. Therefore, if it's taking a month to solve, I imagine that either you have huge amount of data or a highly sub-optimal implementation of your objective function. If your data size is huge, I question whether you need that much data to solve for such a small number of unknowns. Seems to me like you could throw some away in the interest of speeding things up.
  8 Comments
John D'Errico
John D'Errico on 10 Mar 2017
Matt is completely correct here. fminsearch with restarts is not better. However, if you have a problem with many local minima then don't use fminsearch. Here a stochastic solver may be better, as they are explicitly designed to overcome that problem. In terms of convergence, fminsearch will be slow for large numbers of variables. If you are willing to wait a few months for a solution, then sure, use fminsearch on a 25 variable problem.
Walter Roberson
Walter Roberson on 10 Mar 2017
I have created an experimental optimizer that uses fminsearch for part of its work. I find that it is often useful in finding the right major "catch basin", but not so good at resolving the last few bits to find the true local optimum; it tends to dance around it.

Sign in to comment.

More Answers (0)

Categories

Find more on Systems of Nonlinear Equations in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!