Identify the coefficients of each constraint separately

조회 수: 3 (최근 30일)
JOVANI
JOVANI 2023년 4월 21일
댓글: Walter Roberson 2023년 4월 24일
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
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
JOVANI
JOVANI 2023년 4월 24일
Thanks for the reply! Walter, a few days ago I posted a complete question that involves the same constraints I put in this question. I posted it here: https://math.stackexchange.com/questions/4672610/using-linprog-function-for-a-linear-program. Based on this question, do you think the same reasoning as your answer applies?
Walter Roberson
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Solver 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