Optimizing a function with many many arguments
17 ビュー (過去 30 日間)
古いコメントを表示
I have a function which has many outputs. I would like to find the minimum of one of the outputs by optimizing the function. Since I have many outputs I suspect that the optimization will not be successful. So my function is of the form:
function [A, B, C]=myfun(a,b,c)
and I would like to find the minimum only of the output A. Then since I the optimized values for a,b,c I would like to call again the function to find the values also of B and C.
So I would like to do:
[Amin, Bopt, Copt]=myfun(aopt, bopt, copt)
Do you know how can implement it?
0 件のコメント
回答 (3 件)
Matt J
2013 年 1 月 25 日
編集済み: Matt J
2013 年 1 月 25 日
Any of the solvers can do this, e.g.
fun=@(x) myfun(x(1), x(2), x(3));
initialpoint=[aguess,bguess, cguess];
x = fminsearch(fun , initialpoint);
[Amin, Bopt, Copt]=fun(x);
3 件のコメント
Matt J
2013 年 1 月 25 日
Inside my fun there is only one output which I would like to optimize and depends on the vector x. The thing is that myfun is saved in separate script and has lots of outputs. Since I want the minimization of only one of the outputs I guess that the way I showed is not correct.
As long as the first output of myfun is the value you are optimizing, and as long as you are not using the option 'GradObj'='on', it should be fine.
Matt J
2013 年 1 月 25 日
Well I could place it first but that is not what I am looking for.
Then wrap it in a function that does place it first.
参考
カテゴリ
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!