Results 1 to 6 of 6
Thread: The Assignment Problem
 02262009, 10:58 PM #1Member
 Join Date
 Feb 2009
 Posts
 9
 Rep Power
 0
The Assignment Problem
Hello,
I'm trying to figure out how to create a program that will solve the assignment problem. The idea I have is to create a 2D array, with each element holding a cost. Only certain costs would be added up and stored in variables. To calculate the sum of the costs I need to come up with a way to generate all the combinations.
I don't know how to explain it very well, so I made tables to show what I mean.
For example, a 3x3 matrix will produce 6 possible combinations, here are 2 of the combinations:
Java Code:0 1 2 0 X 1 X 2 X cost1 = Matrix[0][0] + Matrix[1][1] + Matrix[2][2]
Java Code:0 1 2 0 X 1 X 2 X cost2 = Matrix[0][0] + Matrix[1][2] + Matrix[2][1]
(Sorry for the code fragments, couldn't think of anything else.)
Would appreciate any help, thx!
I'll try to explain more. I'm trying to generate all solutions where only 1 element in each row is chosen. The element in the next row cannot be in that same column. For example, (0,0) + (1,1) + (2,2) is one combination. (0,2) + (1,1) + (2,0) is another and so on.. Two elements cannot be chosen from the same rows or the same columns. I just can't figure out how to write an algorithm that will be able to give me all combinations correctly. There are a total of 6 combinations for a 3x3 matrix.Last edited by bumblyb33; 02272009 at 12:26 PM.
 02262009, 11:42 PM #2Member
 Join Date
 Feb 2009
 Location
 Romania
 Posts
 11
 Rep Power
 0
 02272009, 05:36 AM #3
uhmm try using a List either ArrayList or LinkedList .. but i im not 100% sure on what you are trying to do can you provide a more detailed explanation?
 02272009, 07:49 AM #4Senior Member
 Join Date
 Sep 2008
 Posts
 564
 Rep Power
 7
pretend you have a onedimensional array of { 0, 1, 2 }. how would you find all permutations? same principle.
 03032009, 10:24 PM #5Member
 Join Date
 Feb 2009
 Posts
 10
 Rep Power
 0
more details required....
 03042009, 05:21 AM #6
Similar Threads

Problem with an assignment: Backgammon game
By Poddy in forum New To JavaReplies: 6Last Post: 02052009, 06:32 AM 
GUI First AssignmentDUE 8/1/08
By ljk8950 in forum AWT / SwingReplies: 2Last Post: 08012008, 04:23 AM 
Jtable duplicates through Hashtable (JTable condition problem) my assignment plz help
By salmanpirzada1 in forum Advanced JavaReplies: 2Last Post: 05152008, 10:15 AM 
assignment problem help needed
By tiggz1980 in forum New To JavaReplies: 2Last Post: 02072008, 12:14 AM 
Cannot solve the coding problem of my assignment
By elimmom in forum New To JavaReplies: 3Last Post: 08132007, 11:33 AM
Bookmarks