How does fmincon relate array parameters to constraints?
조회 수: 2 (최근 30일)
이전 댓글 표시
Hi-
I'm trying to use fmincon to minimize a function that takes an array input. I need to enforce a constraint on the values of the array such that if the array looks like:
[ a1 a2 a3 a4 a5; b1 b2 b3 b4 b5; c1 c2 c3 c4 c5]
then
c*a1 + a2 + d*a3 < ub1
c*a2 + a3 + d*a4 < ub1
and so on, and similarly,
c*b1 + b2 + d*b3 < ub2
c*b2 + b3 + d*b4 < ub2
My problem is that although it is clear that internally fmincon flattens the array, I can't figure out the order in which the flattening occurs, and hence I don't know how to shape the constraint matrix A. So, internally, does fmincon flatten my array as
[a1 a2 a3 a4 a5 b1 b2 b3 b4 b5 c1 c2 c3 c4 c5]
or
[a1 b1 c1 a2 b2 c2 a3 b3 c3 a4 b4 c4 a5 b5 c5]?
I know I could flatten the array before passing it to fmincon but that would require an enormous amount of rewriting of the objective function, which is seriously nontrivial.
댓글 수: 0
답변 (2개)
Matt J
2014년 7월 11일
편집: Matt J
2014년 7월 11일
So, internally, does fmincon flatten my array as...or...
It flattens the array as
[a1 b1 c1 a2 b2 c2 a3 b3 c3 a4 b4 c4 a5 b5 c5].'; %<--note transpose
I know I could flatten the array before passing it to fmincon but that would require an enormous amount of rewriting of the objective function, which is seriously nontrivial.
It would be highly trivial. You could just insert the following line at the beginning of the objective function and leave the rest as is.
unknowns=reshape(unknowns,3,5);
But... there is no need to pre-flatten.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!