optimal solution of a matrix
Afficher commentaires plus anciens
Hey everyone, Im working on my thesis and need to find the min. cost solution within my project. However, I got stuck! Hope you can help me!
1.1095 1.1112 0 0 1.1120 1.1122 0
1.2292 1.2275 0 0 1.2286 1.2295 0
0 0 1.1567 0 0 1.1590 0
0 0 0 1.0988 0 0 1.1008
1.1369 1.1355 0 0 1.1345 0 0
1.0695 1.0688 1.0690 0 0 1.0668 0
0 0 0 1.1082 0 0 1.1062
The previous matrix is my output. Rows are defined as j, Colums are defines as i. I need to min. cost at i, while providing producst to every j. Example: i = 1 could provide for j = {1,2,5,6}, i = 3 could provide for j = 3 (it is possible to provide for yourself) and i =4 could provide for j= {4,7}. What i need matlab to do is calculate all the different options (only 1 i is allowed for each j, but 1 i can supply multiple j's) and to give me the lowest cost and the i,j combinations that correspont with this.
I hope someone can help me! It's the last part I need to do to graduate, but matlab is very new to me, so would appreciate the help!
Thanks, Arjan
Réponses (2)
Roger Stafford
le 9 Sep 2014
Modifié(e) : Roger Stafford
le 9 Sep 2014
It isn't entirely clear what you are asking. If it is allowed to select only a portion of the non-zero values in a column, then the problem is easy. For each row select the minimum non-zero value in it. Let your 7 x 7 matrix be called M.
ji = zeros(7,2);
s = 0;
for j = 1:7
p = find(M(j,:)>0);
[c,q] = min(M(j,p));
s = s + c;
ji(j,:) = [j,p(q)];
end
Then ji contains the seven j,i index pairs of the optimum selection and s is the sum of their total "costs" in M.
(I can see without even using matlab that the solution for your particular example happens to be the pairs along the main diagonal of M.)
1 commentaire
Roger Stafford
le 9 Sep 2014
Modifié(e) : Roger Stafford
le 9 Sep 2014
Your explanation is still somewhat unclear to me. Here are some of my uncertainties:
1) The phrase "one-time fixed cost" is confusing me because it seems to hint that your other costs could occur many times. Or to put it another way, is the quantity 13.4108 in your example the actual amount you wish to minimize, or do the costs in the 7.9108 figure apply multiple times? It is important to be precise in defining what it is you wish to minimize. Changes in this definition can seriously affect the algorithm needed for the problem.
2) There was no mention of the "fixed cost" aspect in your original description. Do you have a list of all these amounts? You mention three of them in your example: 2, 3, and 0.5. What are the others? Is there a fixed list of them for each optimization?
3) In your example, {1,1;1,2;1,5;1,6;3,3;7,4;4,7}, there occurs the pair i = 7, j = 4, and in the matrix the corresponding cost would be 1.1008 which you included in the figure 7.9108. However, you did not list a corresponding one-time fixed cost amount for this i = 7 case. Was that a mistake on your part, or is this something further that I don't understand about your problem?
Catégories
En savoir plus sur Surrogate Optimization dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!