resuming fminsearch from where it's left

3 ビュー (過去 30 日間)
Gorkem
Gorkem 2016 年 12 月 5 日
コメント済み: Alan Weiss 2016 年 12 月 5 日
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?

回答 (1 件)

Alan Weiss
Alan Weiss 2016 年 12 月 5 日
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 件のコメント
Gorkem
Gorkem 2016 年 12 月 5 日
編集済み: Gorkem 2016 年 12 月 5 日
so you are saying that I can do the following?
options = optimset('MaxFunEvals',50,'MaxIter',50);
x = fminsearch(fun,x0,options);
Alan Weiss
Alan Weiss 2016 年 12 月 5 日
Alan Weiss
MATLAB mathematical toolbox documentation

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeNonlinear Optimization についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by