How to know the current input for fminsearch?

4 ビュー (過去 30 日間)
Siavash
Siavash 2020 年 7 月 25 日
コメント済み: Alan Weiss 2020 年 8 月 7 日
I'm using fminsearch for an optimization problem.
I use 100 random inputs and run fminsearch hoping that it doesn't get trapped in local minimas.
Sometimes, fminsearch takes more than usual. I suspect this is because of some bad behavior of some function in my problem that I haven't overseen earlier. I am wondering if I can somehow display the x (input) that fminsearch is working on right now (in real time). This will help me to find out why my problem takes longer around this particular point and if there is some issue with how I defined my problem, correct it (with some if,else,etc).
Thank you!

採用された回答

Matt J
Matt J 2020 年 7 月 25 日
編集済み: Matt J 2020 年 7 月 25 日
You can use an OutputFcn,
or simply add a line of code to your objective function to display x, or pause under certain conditions. You could also possibly set conditional or non-conditional breakpoints,
However, I feel I should mention that fminsearch uses the Nelder-Mead algorithm, which is not designed for problems with a large number unknowns. In theory, it is only guaranteed to converge for 1 unknown, and in practice its performance starts to degrade significantly beyond about 6 unknowns. In your case, with 100 unknowns, I am suprised you ever see good fminsearch behavior.
  3 件のコメント
Matt J
Matt J 2020 年 7 月 25 日
Do you have a suggestion on which method you think may work better?
Not without seeing your cost function. Presumably you've already tried fminunc?
Siavash
Siavash 2020 年 7 月 25 日
Yes.
My cost function is a long code and includes some numerical integrations and for loops.

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

その他の回答 (1 件)

Alan Weiss
Alan Weiss 2020 年 7 月 26 日
For optimizing a simulation or ODE, you may want to try patternsearch and surrogateopt. For surrogateopt you will need to bound all of the variables. These solvers have informative plot functions available.
Alan Weiss
MATLAB mathematical toolbox documentation
  6 件のコメント
Siavash
Siavash 2020 年 8 月 7 日
Where should I send it to?
An email address or something...?
Alan Weiss
Alan Weiss 2020 年 8 月 7 日
You can attach it to this discussion or send it to me at aweiss@mathworks.com .
Alan Weiss
MATLAB mathematical toolbox documentation

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

カテゴリ

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

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by