Finding the minimum cost of a matrix

5 views (last 30 days)
Suppose i have cost matrix 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
Danish Nasir
Danish Nasir on 11 Sep 2021
Thanx for the help.
Please remember that output of the code (minimize cost) will be such that "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
Edited: 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 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.
and that means : the worker 1 assign to machie 1, worker 2 assign to machine 4, and worker 3 assign to machine 3.
  5 Comments
Danish Nasir
Danish Nasir on 11 Sep 2021
Thanx for the help. The code is working.

Sign in to comment.

More Answers (0)

Tags

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!