fmincon constraining some variables and not others
8 ビュー (過去 30 日間)
古いコメントを表示
Hello,
I am trying to optimise a function depending on 6 optimisable variables using fmincon(). Some of the variables should be under inequality linear constrains, while others shouldn't have any constrain at all. Is there the possibility to enforce this with fmincon()?
I know that linear inequality constrains should be enforced by defining the system A · x ≤ b, but this forces me to impose a constrain over every element in x. Setting A(i,i) and b(i) as 0 seems a waste of CPU since fmincon() will probably keep using a constrain that actually is not.
One could think to define (A,b) and make their indices empty where no constrain should be, but of course this just concatenates A and b if they are vectors or is an error if A is a matrix.
Thank you for your answers.
0 件のコメント
採用された回答
Matt J
2020 年 12 月 1 日
編集済み: Matt J
2020 年 12 月 1 日
Setting A(i,i) and b(i) as 0 seems a waste of CPU since fmincon() will probably keep using a constrain that actually is not.
In theory, you can make A of type sparse, so that multiplications A(i,j)*x(j) for A(i,j)=0 will not be done explicitly. However, for such a small 6-variable problem, it doesn't make much sense. It is unlikely that these computations will consume noticeable additional CPU time.
その他の回答 (1 件)
Ameer Hamza
2020 年 12 月 1 日
編集済み: Ameer Hamza
2020 年 12 月 1 日
"I know that linear inequality constrains should be enforced by defining the system A · x ≤ b, but this forces me to impose a constrain over every element in x. Setting A(i,i) and b(i) as 0 seems a waste of CPU since fmincon() will probably keep using a constrain that actually is not."
Why do you think so?
Conside the constraint
You will define it like this
A = [1 0 0 0 1 0];
B = 2;
This does not impose any constraint on x2, x3, x4, and x6.
3 件のコメント
Matt J
2020 年 12 月 1 日
Simple bounds like x1<=3, x5<=68 should not be expressed using the A,b matrices. You should use the lb, ub arguments for those. In any case, recent versions of Matlab will pre-analyze your A,b matrices to see if they contain any simple bounds and rewrite your constraints automatically.
参考
カテゴリ
Help Center および File Exchange で Linear Least Squares についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!