Finding the minimum cost of a matrix

15 views (last 30 days)
假设我有成本矩阵M = [100 250 300 400
600 900 400 300
250 300 160 190].
The size of matrix 3x4. Let column represent machines and row represent worker.I want to minimize cost Matrix M. Each column should have only one cost. I didn't want to use matchpair function.
How can i use intlinprog function of Matlab for minimization cost?
5 Comments
丹麦纳西尔
丹麦纳西尔 on 11 Sep 2021
谢谢各位的帮助。
请记住,代码的输出(最小化成本)将是如此” any size matrix can be given as an input to the code".

Sign in to comment.

Accepted Answer

Abolfazl Chaman Motlagh
Abolfazl Chaman Motlagh on 10 Sep 2021
编辑:Abolfazl Chaman Motlagh on 10 Sep 2021
If i get that right, you have an assignment task.
so you want to solve this :
your constraint should be :
which i represent machines, and j represent workers. you have 3 workers and 4 machines. hence the constraints are not symmetric.
you also need boundery conditions.
i am going to linearize 2d index of x_i,j to a vector so we have
finally :
M= [ 100 250 300 400;
600 900 400 300;
250 300 160 190];
f = M(:)' ;
AEQ = [1 0 0 1 0 0 1 0 0 0 1 0 0;
0 1 0 0 1 0 0 1 0 0 1 0;
0 0 1 0 0 1 0 0 1 0 0 1];
beq = ones(3,1);
x = intlinprog(f,1:12,[],[],Aeq,beq,zeros(12,1),inf(12,1));
LP: Optimal objective value is 560.000000. Optimal solution found. Intlinprog stopped at the root node because the objective value is within a gap tolerance of the optimal value, options.AbsoluteGapTolerance = 0 (the default value). The intcon variables are integer within tolerance, options.IntegerTolerance = 1e-05 (the default value).
find(x)
ans = 3×1
1 9 11
which means X11 = 1, X33=1, X42=1.
这意味着:工人1分配给Machie 1,Worker 2分配给机器4,而Worker 3分配给机器3。
5 Comments
丹麦纳西尔
丹麦纳西尔 on 11 Sep 2021
谢谢各位的帮助。代码是有效的。

Sign in to comment.

更多的Answers (0)

Tags

s manbetx 845


发布

R2020a

Community Treasure Hunt

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

开始狩猎!

Translated by