Note that there are some explanatory texts on larger screens.

plurals
  1. POBest way to get the highest sum from a Matrix (using Java but algorithm is the issue here)
    primarykey
    data
    text
    <p>Sorry I dont know the correct terminology to use but I have a 3x3 matrix like this</p> <pre><code>1 3 4 5 4 5 2 2 5 </code></pre> <p>and I want get the highest score by picking a value from each row/column but I cant pick the same row or column more than once , so the answer in this case is</p> <p>3 + 5 + 5 = 13 (row0,col1 + row1,col0 + row2,col2)</p> <p>4 + 5 + 5 = 14 is not allowed because would have picked two values from col2</p> <p>I'm using Java, and typically the matrix would be 15 by 15 in size.</p> <p>Is there a name for what Im trying to do, and whats the algorithm </p> <p>thanks Paul</p> <p>EDIT:Note:the hungarian algorithm only works when no of rows equals no of cols, and in my case this is not always the case I regularly have cases of 10x12 or 11x13. But it appears you can get round this by adding extra dummy rows.</p> <p>EDIT hmm, trying out one of these implmentations and it doesnt alwasy seem to work, unless Im misreading it</p> <pre> 100.0,100.0,100.0,100.0,30.0,80.0,80.0,100.0,100.0,80.0, 80.0,100.0,100.0,100.0,80.0,80.0,25.0,100.0,100.0,80.0, 80.0,100.0,100.0,100.0,80.0,25.0,80.0,100.0,100.0,80.0, 100.0,25.0,80.0,100.0,100.0,100.0,100.0,100.0,100.0,100.0, 0.0,100.0,100.0,100.0,100.0,80.0,80.0,100.0,100.0,100.0, 100.0,100.0,100.0,100.0,100.0,100.0,100.0,100.0,25.0,100.0, 100.0,100.0,100.0,25.0,100.0,100.0,100.0,75.0,100.0,100.0, 100.0,80.0,30.0,100.0,75.0,100.0,100.0,100.0,100.0,100.0, 100.0,100.0,100.0,100.0,80.0,80.0,80.0,100.0,100.0,25.0, 100.0,100.0,100.0,75.0,100.0,100.0,100.0,25.0,100.0,100.0, Results calculated 0:4,0, 1:3,1, 2:7,2, 3:6,3, 4:0,4, 5:2,5, 6:1,6, 7:9,7, 8:5,8, 9:8,9, </pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload