fminsearch for existing simulation
이전 댓글 표시
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일
0 개 추천
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
Chris Topher
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.
카테고리
도움말 센터 및 File Exchange에서 Simulink Design Optimization에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!