resuming fminsearch from where it's left
3 views (last 30 days)
Show older comments
Hi everyone,
I am using fminsearch on simulink real-time system. It's called once in a while not peridoically but can say roughly every 1 s.
My real time sampling period is 1 ms. However, fminsearch takes about 2.5-3.5 ms causing system overload. That's not a problem for me because I don't need the optimizer result in the next 10 mseconds.
My problem is that there are some tasks that has to be executed every 1 ms. When overload occurs, this cannot be fulfilled for the next 3 iterations.
As a resolution, I was think of limiting the max number of function evaluations and max number of iterations to a value satisfying 1 ms execution period. Then, starting fminsearch from where it's left at the previous step. Currently, an optimization is completed in nearly 150 function evaluations.
However, I can't manage to change MaxFunEvals and MaxIter. By default, they are both set as '200*numberofvariables'. Matlab doesn't allow me to change MaxFunEvals or MaxIter to 50 (for example), It gives an error. So I tried '50*numberofvariables' but that doesn't limit the number of function evaluations to 50. What's the proper way of doing this?
0 Comments
Answers (1)
Alan Weiss
on 5 Dec 2016
To set options, set an options structure using optimset, and then make sure that you pass the options structure to fminsearch, as in this example. Don't use optimset inside a loop.
You can definitely set MaxFunEvals and MaxIter to positive integer values. If you find that you cannot, then you are most likely not passing the options structure to fminsearch.
Alan Weiss
MATLAB mathematical toolbox documentation
2 Comments
Alan Weiss
on 5 Dec 2016
See Also
Categories
Find more on Nonlinear Optimization in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!