How to pass to the objective function just the elements of a matrix that satisfy my constraints

2 ビュー (過去 30 日間)
Hi everybody,
I'm working with fmincon function. My objective function operates on matrices and at the end it makes the std dev of such matrices. Therefore, it comes out with a number that need to be minimized through the fmincon function. Constraints work on elements of the matrices (< or > of a certain threshold). At this point I would like to know how to pass to the objective function just the values of matrices that satisfy my constrains or another method to pass to the objective function just the indexes of the values that satisfy constraints.
Thank you in advance.
N.

採用された回答

Matt J
Matt J 2015 年 7 月 22 日
編集済み: Matt J 2015 年 7 月 22 日
Well, extracting the elements of a matrix M that satisfy a threshold is easy
indicesLogical = M>threshold;
values = M(indicesLogical)
but the objective function needs to receive the entire matrix you are optimizing over as input. If it needs to process some elements differently than others you would index/extract them as above, but inside the objective function, not prior to it.
  2 件のコメント
Nelson
Nelson 2015 年 8 月 18 日
編集済み: Nelson 2015 年 8 月 18 日
Thanks Matt for your answer.
Is it correct then to use the fminunc function inserting some controls into the objective function in order to avoid the use of constraints? I mean, if I include controls inside the objective function I don't need the definition of constraints anymore.
Thanks.
Regards
Matt J
Matt J 2015 年 8 月 19 日
編集済み: Matt J 2015 年 8 月 19 日
No, that is not correct.
Nothing that you've mentioned in your posted question appears to have anything to do with actual constraints. A constraint is something that the unknown variables must satisfy in order to be considered a possible solution. All you've told us is that your objective function has a different dependence on different elements x(i) of the vector x depending on whether x(i) is greater than some threshold.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSolver Outputs and Iterative Display についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by