Identify the coefficients of each constraint separately
조회 수: 3 (최근 30일)
이전 댓글 표시
I have 4 restrictions below. I would like to make an array of coefficients for each constraint separately. I did the first two, I would like to know if it is correct, first, and I would like help to do the remaining two. My ideia is used the linprog function later.

A = [Xk(1) Xk(2) Xk(3) Xk(4) zeros(1,ncolunas)
B= [0 0 0 0 Xk(1) Xk(2) Xk(3) Xk(4)]
댓글 수: 1
Walter Roberson
2023년 4월 21일
I suggest that you use Problem Based Optimization https://www.mathworks.com/help/optim/problem-based-approach.html
답변 (1개)
Walter Roberson
2023년 4월 22일
You want to operate over rows of Y and over colums of Y.
What you do is reshape() Y to be a row vector, and start creating row entries that correspond. For example, if Y is 3 x 5, then one row of coefficients would be like [zeros(1,0), ones(1,3), zeros(1,12)] and another would be [zeros(1,3), ones(1,3), zeros(1,9)], another would be [zeros(1,6), ones(1,3), zeros(1,6)] and so on. You are creating matrices of selectors of which coefficients are to be used in a particular summation.
Once you have the 2D array of selectors, do element-by-element multiplication against reshape(Y,1,[]) -- so each selector 1 in the temporary variable is replaced by the corresponding Yik value. The result becomes your "A" matrix. The b matrix becomes [P(:); L(:)] (at least with respect to the first two variables.)
I need to think a bit more about how to handle the third condition smoothly.
댓글 수: 2
Walter Roberson
2023년 4월 24일
I recommend that you use Problem Based Optimization to construct the constraint matrices. It should also be able to figure out that linprog() can be used as the solver.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!