フィルターのクリア

Blending Problem / Weighted Average

2 ビュー (過去 30 日間)
Ron
Ron 2016 年 2 月 27 日
コメント済み: Ron 2016 年 3 月 1 日
I have a blending problems where I have a selection of containers, each with a weight and a specific attribute. I have to combine the containers so that the weight is between a lower and upper value and that the weighted average of the attribute is between a lower and upper value. My objective is to minimize the containers that need to be opened.
The attribute in the first row of Att applies to all the containers in the first row of W and similarly for the rest of the rows.
W=[1,1,4,5;3,9,10,4;1,7,1,8]
Att=[4;1;3]
I have set up the A matrix so far as the top two rows being the W.*Att and the bottom two rows being the W matrices. The first and third rows are negative to account for greater than the lower attribute and weight constraints.
[m,n]=size(W);
W_column=W(:);
Att_column=repmat(Att,n,1);
A=[-W_column.*Att_column,W_column.*Att_column,-W_column,W_column]';
My problem is formulating the attribute weighted average in the "A" matrix for the intlinprog solver. In general it should be W1*Att1*X1+W2*Att2*X2.../sum(W) to get the weighted average. The X would either be a 1 if the container would be used and a 0 if not used. I cannot figure out how to do the sum(W) piece in a matrix format. Thank you for any help provided!

回答 (1 件)

Image Analyst
Image Analyst 2016 年 2 月 28 日
Try this:
W=[1, 1, 4, 5;
3, 9, 10, 4;
1, 7, 1, 8]
Att=[4;1;3]
X = [1;1;1]
[rows, columns] = size(W);
Att_column = repmat(Att, 1, columns);
A = W .* Att_column
% Now sum across columns, multiply by X,
% and divide by the sum of all W elements.
A= sum(A, 2) .* X / sum(W(:))
  1 件のコメント
Ron
Ron 2016 年 3 月 1 日
I think your matrix multiplication is a little more elegant than mine, and is a good idea. The idea in the example is that I have 12 binary variable (all the elements in W) that have to be chosen to meet the specifications of a blend. Some of them will not be chosen, which would removed their weights from the sum((W) portion. X should really be a 12,1 vector, using the optimization functions.

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

カテゴリ

Help Center および File ExchangeLinear Programming and Mixed-Integer Linear Programming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by