fminsearch for existing simulation
1 回表示 (過去 30 日間)
古いコメントを表示
Hey guys,
I have recently created an aerodynamic trajectory model. The goal is to optimize for two Values for which i have an equation that should be mnimal. Now i want to use fminsearch (or something else if it fits better) to run over my whole simulation and calculate the value of the equation. To optimize it, there are plenty of other input values in the equation, that should be considered and changed by fminsearch. How can i do that without putting my whole simluation in one formula?
I dont use additional toolboxes, nor Simulink.
Thanks!
1 件のコメント
Walter Roberson
2020 年 9 月 14 日
You can pass the handle of a true function to fminsearch . You are not required to pass the handle to an anonymous function.
回答 (1 件)
Matt J
2020 年 9 月 14 日
As Walter said, fminsearch does not know or care how many lines of code are used to implement your objective function. Bear in mind, though, that fminsearch is not built for problems with many variables. With more than about 6 unknowns, it typically performs poorly.
3 件のコメント
Matt J
2020 年 9 月 14 日
編集済み: Matt J
2020 年 9 月 14 日
I also got a tip with fminsearchbnd which is perfect because you can easily define boundaries
Since you appear to have only a single unknown variable, the stock Matlab function fminbnd would work as well.
The only thing i dont like is that i have to change the original simulation by passing the Init-values so it doesnt work without being called by optimizer anymore.
No, that's quite unnecessary. Your objective function can call other functions, so there is no reason why the simulation code cannot reside in its own mfile. The only thing fminsearch/fminbnd/fminsearchbnd cares about is that it has access to some function which takes a guess for the unknown as input and spits an objective function value back as output. It doesn't know or care what code is used to obtain that output value, or how that code is structured.
Walter Roberson
2020 年 9 月 14 日
"To optimize it, there are plenty of other input values in the equation, that should be considered and changed by fminsearch"
To me that suggests that the number of variables to be optimized over is more than 1.
参考
カテゴリ
Help Center および File Exchange で Get Started with Optimization Toolbox についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!