Ordering of OptimizationVariables in an OptimizationProblem
이전 댓글 표시
When I use the problem-based optimization framework to create an OptimizationProblem, e.g.,
r=optimvar('r',5,'LowerBound',0,'UpperBound',1);
B= optimvar('B', 3);
prob=optimproblem('Constraints', sum(r)<=1,'Objective', sum(r)+sum(B));
the ordering of the variables in prob appears to be alphabetical,
prob.Variables
However, I would prefer the ordering to be r first, then B. I thought I might be able to use orderfields() to change it, but no luck:
prob.Variables=orderfields(prob.Variables,{'r','B'})
Is there a supported way of doing this?
The reason I want to do this is so that when I use,
s=prob2struct(prob);
the sub-matrix partitions of s.lb, s.ub, s.Aeq, etc... corresponding to r and B will have an ordering that I can know and control in advance. I'm assuming this ordering is dictated by the ordering of the fields in prob.Variables.
댓글 수: 3
Bjorn Gustavsson
2021년 5월 25일
Is it worth the hassle to use this modern/automatic "problem-based framework"? I've always shied away from this type of automatic parsing just because of not knowing/not being sure about how these things are handled. What are the benefits you see/expect?
Bjorn Gustavsson
2021년 5월 26일
So, I might be better off if I learn a new trick...
답변 (0개)
카테고리
도움말 센터 및 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!