Is there a one line code solution to generate a matrix of permutations
이전 댓글 표시
I am looking for a single-line matlab code to solve the following problem:
There are five consultants, and five projects to be done. Any consultants can carry out any the project, but at a different cost to the company. The cost matrix is as follows:

The business manager is trying to allocate one project each to the five sonsultants such that the overall cost to the company is the minimum.
Obviously, there are 5! (=120) possibilities, and total costs can be calculated, and combination with minimum cost can be selected.
The challenge is to do it in single line of matlab code, however complex.
For your ease: costs=[24 10 21 11 16; 14 22 10 15 15; 15 17 12 20 14; 11 19 14 13 13; 23 13 13 18 12]; Thank you.
채택된 답변
추가 답변 (2개)
The PERMS command.
댓글 수: 2
Matt J
2012년 11월 5일
No, it's not all that you require, but it's the main thing that you require. I don't see why you think you need to shuffle the matrix and sum the diagonal.
As a hint, here are a few other commands that might be useful: SUB2IND, REPMAT
Matt Fig
2012년 11월 4일
0 개 추천
The cheapest rate I find is 59 units. I can find the minimum cost in one line. But I cannot find this and also return the job assignments in one line. Fun little project!
댓글 수: 5
Matt Fig
2012년 11월 4일
I'll give that a try.... SUBSREF is not my favorite function.
Amit
2012년 11월 5일
Matt J
2012년 11월 5일
If the goal is just the minimum cost, you probably don't need SUBSREF.
Walter Roberson
2012년 11월 5일
Remember, one line, not one expression.
카테고리
도움말 센터 및 File Exchange에서 File Operations에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!