Writing equations in a matrix form

5 ビュー (過去 30 日間)
Susan
Susan 2019 年 4 月 19 日
コメント済み: Susan 2019 年 4 月 24 日
Hi MATLAB experts,
Could any one please help me to write-down the following equations into a matrix form? the initial value of c = zeros(I, L, K, M)
0<= c(i, j, k, m) <= 1 for all k= {1, 2, ...., K} and m = {1, 2, ..., M} and i = {1,...., I} and j = {1,..., L}
0<=sum_{j} sum_{i} c(i,j,k,m) <= 1 for all k= {1, 2, ...., K} and m = {1, 2, ..., M}
  4 件のコメント
Walter Roberson
Walter Roberson 2019 年 4 月 19 日
編集済み: Walter Roberson 2019 年 4 月 19 日
Yes, those should be okay lb and ub.
Which release are you using? Which optimizer are you using?
Your task might be easier to express with Problem Based Optimization.
Do not use nonlinear constraints for those sum constraints: you only need linear constraints for those. It is just a nuisance to write out the matrices.
Susan
Susan 2019 年 4 月 19 日
Thanks for your reply.
I am using R2016b and trying to use fmincom.
I am not familiar with Problem Based Optimization. But I will take a look to see how I can use that.
Do you know how I should write the second constraint? Thanks
sum(sum(c(:, :, k,m))) <= 1 for all k and m.

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2019 年 4 月 19 日
For any one particular scalar k and scalar m, you can express sum_{j} sum_{i} c(i,j,k,m) in range 0 to 1 as a linear constraint. The portion relevant to that k and m would be in the A matrix like
A(something,:) = [zeros(1, SOMETHING), ones(1, I*J), zeros(1,SOMETHINGELSE)];
b(something) = 1;
A(something+1,:) = [zeros(1, SOMETHING), -ones(1,I*J), zeros(1,SOMETHINGELSE)];
b(something) = 0;
You would have to walk this through K by M iterations, increasing the value of SOMETHING by I*J each time, and decreasing the value of SOMETHINGELSE by the same value.
An easier way of generating this would be something like:
blk = repmat({[ones(1, I*J); -ones(1, I*J)]}, 1, K*M);
A = blkdiag(blk{:});
b = zeros(size(A,1));
b(1:2:end) = 1;
  21 件のコメント
Walter Roberson
Walter Roberson 2019 年 4 月 23 日
Yes, 'vars', {c} should work for that.
Susan
Susan 2019 年 4 月 24 日
Thanks for your reply.

サインインしてコメントする。

その他の回答 (1 件)

Susan
Susan 2019 年 4 月 22 日
@ Walter, I am trying to write-down the following linear constraint according to the way you taught me above.
sum_{m} sum_{i} p(i, j,j,k,m) <=P_{k, j} for all k = 1: K and j = 1 : J
m = 1: M and i = 1 : I and P_{k, j} is given and fixed for each specific k and j
I wrote this constraint in the format of
A(something,:) = [zeros(1, SOMETHING), ones(1, I), zeros(1,SOMETHINGELSE)];
b(something) = P_{k,j};
However, I wasn't able to find a specific relationship between the rows of A.
What I found is sth like
A(1, :) = [ones(1, I) zeros(1, (J*J*K -1)*I) ones(1, I) zeros(1, (J*J*K -1)*I) ]
A(2, :) = [zeros(1,K) ones(1, I) zeros(1,(J*J*K -1)*I) ones(1, I) zeros(1,(J*J*K -1)*I) zeros(1,(J*J*K -1)*I -K)]
the pattern "ones(1, I) zeros(1, (J*J*K -1)*I) ones(1, I) zeros(1, (J*J*K -1)*I) " is repeated in all rows but I wasn't able to figure out what is the formulation of the begining zeros(1, SOMETHING), and correspondingly the zeros(1,SOMETHINGELSE) in order to write matrix A.
Could you please let me know what would be the format of A? Thank you so much in advance.
  2 件のコメント
Walter Roberson
Walter Roberson 2019 年 4 月 22 日
Use the blkdiag() method I posted as "easier way of generating this". It generates the entire A and b matrix in a small number of lines.
Susan
Susan 2019 年 4 月 22 日
Great! Thanks for all your help. Appreciate that.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSurrogate Optimization についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by