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 CenterFile Exchange에서 Nonlinear Optimization에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by