Blending Problem / Weighted Average

조회 수: 4 (최근 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 CenterFile Exchange에서 Linear 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