How to pass to the objective function just the elements of a matrix that satisfy my constraints
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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.
0 commentaires
Réponse acceptée
Matt J
le 22 Juil 2015
Modifié(e) : Matt J
le 22 Juil 2015
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 commentaires
Matt J
le 19 Août 2015
Modifié(e) : Matt J
le 19 Août 2015
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.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Solver Outputs and Iterative Display dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!