fmincon function with vector inputs of different lengths?
3 ビュー (過去 30 日間)
古いコメントを表示
The general form of the function I'll be using is:
x= fmincon(objective, x0,A,b, Aeq,beq, lb,ub ,nonlcon);
YET the input are vectors and matricies of different lengths ( for example, I have 2 vectors that are 1 by 8 and one matrix that is 8 by 1000).
So my question is what is the correct way to type in the x0? I have tried an array, where each cell contains one vector, but it didn't work
0 件のコメント
採用された回答
Walter Roberson
2019 年 6 月 29 日
If the inputs are effectively constants for a minimization (such as weights that are given for a situation) then they should not form part of x and you should instead parameterize the function call
@(x)objective(x, a, b, c, d)
Where a b c d are the extra inputs
If instead your input x0 values all represent variables whose best value is to be found to minimize the function, then you need to bundle them all together into a single input variable
function cost = objective(allinputs)
a = allinputs(1:4);
b = reshape(allinputs(5:16),4,3);
With x0 = [a0(:) ; b0(:)] ;
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Systems of Nonlinear Equations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!