tag:blogger.com,1999:blog-3722233.post8642490628509638217..comments2024-11-14T17:42:16.782-06:00Comments on Computational Complexity: Partioning StudentsLance Fortnowhttp://www.blogger.com/profile/06752030912874378610noreply@blogger.comBlogger16125tag:blogger.com,1999:blog-3722233.post-2695242702558892432011-06-06T12:26:35.418-05:002011-06-06T12:26:35.418-05:00This partitioning is not at all an NP-complete pro...This partitioning is not at all an NP-complete problem, but is in fact an extension of the classic matchmaking algorithm and one that has a polynomial time solution.<br /><br />In this particular example, the students do not rank their potential collaborators in an absolute order of preference, but in fact, under-specify their preferred order (by listing their top three collaborators and their least favorite potential collaborator). Therefore the teacher is free to create an arbitrary preference order of potential collaborators for each student as long as it conforms to each student's specified constraints.<br /><br />Although it is true that the teacher cannot guarantee that each student will end up with their most preferred collaborators - it is nonetheless possible to define an optimal grouping of students: that is, for every student, there is no other possible grouping which that student would prefer over their assigned group, <b>and</b> in which the two other co-collaborators would also prefer to be in over their assigned groups.Gregnoreply@blogger.comtag:blogger.com,1999:blog-3722233.post-90191900597691666152011-06-05T22:31:32.292-05:002011-06-05T22:31:32.292-05:00I think Lance stumbled on to the solution to the t...I think Lance stumbled on to the solution to the two-teenage-daughter problem... whatever the issue that his daughters need help with; boyfriends, girlfriends, gossip at school, sports, what clothes to wear or not wear, etc. just say you can't help since its NP-complete, go ask your mother!dmfdmfnoreply@blogger.comtag:blogger.com,1999:blog-3722233.post-65315755695373664502011-06-04T05:15:12.399-05:002011-06-04T05:15:12.399-05:00Just as a simple illustration: Assume student A w...Just as a simple illustration: Assume student A would like to work with students B, C, or D. A then must be paired with at least one of B, C, or D. Let’s assume A and B are put into the same group, and that B would like to work with E, F, or G. Now at least one of E, F, or G must have named A or B -- or else A and B are not a valid pairing. Very quickly you can list out all of the valid groups of which A could be a member. In this particular problem there are at most 45 such groups (if everyone wanted to work with A), but for a random dataset it’s usually a pretty small number.<br /><br />The easiest approach would be to find a student that’s only a member of one valid group, remove those three students from the set, and repeat the process for the remaining fifteen, then twelve, etc., until you’ve either found a solution or, much more typically for random datasets, shown that no solution exists.<br /><br />In random datasets there’ll usually be a student with only one valid group, but in real datasets with more reciprocal preferences (A wants to work with B, and B wants to work with A) it may well be that all students are members of two or more valid groups. In that case just start with the student with the smallest number of valid groups. <br /><br />I tried several randomly generated datasets and could show in each case that no solution existed in about ten minutes using pencil and paper. When I rigged one preference for each student to ensure a solution existed, I easily found the intended solution and two others, and could show they were the only possible solutions.<br /><br />I then tried to generate a realistic dataset that might have a lot of solutions. I made some of the students more popular and some less popular and, more importantly, introduced more reciprocal preferences than were typically present in the random datasets. I was able to find the 120 possible solutions in less than an hour with pencil and paper.<br /><br />I then tried to come up with the worst case for this algorithm. Carefully choosing all the preferences (and here ignoring the one student each excludes from their lab group) I came up with a dataset where each student was a member of ten valid groups. Even here, though, when each remaining set of fifteen, twelve, nine, and six students are evaluated the number of valid groups decreases and the total number of partitions that needs to be analyzed seems to be on the order of thousands, not hundreds of millions.<br /><br />This general approach seems to work quickly even for larger class sizes. (So far I’ve only tried a 36-member class, which would have over 3E+23 possible partitions.)Erik Henrynoreply@blogger.comtag:blogger.com,1999:blog-3722233.post-82034404462620050052011-06-03T09:23:58.681-05:002011-06-03T09:23:58.681-05:00I am a PhD student in computer science and operati...I am a PhD student in computer science and operation research and my day-to-day tasks generally consist of looking for practical solutions to NP-Hard problems. The discussion here is very good and I think a glimpse into my working process may continue to shed light on how these problems may be solved in practice and connect several points already mentioned.<br /><br />The first major issue is what problem instances to test on. Ideally you have some real-world data which can be used for testing. Without real-world data randomly generated instances can be reasonable but the design of the instance generator must be taken with care to minimize bias. Once the testing data has been selected, the next step is to start with a greedy or approximation algorithm and a lower bound (if one is easy to find). In the event that the greedy or approximation algorithm is "close" to the lower bound we may stop here. This is very context dependent. For some problems being within 10% of optimum is reasonable while in other problems every 0.1% closer to optimum is worth considering.<br /><br />In the event that there is a "large" gap between the greedy solution and the lower bound then the next step is to try complete search methods to find the true optimal solution. The most popular approaches are, enumeration, constraint programming (AI tree search), and integer programing. Each one of these can be very effective in practice for particular types of problems up to some fixed instance size.<br /><br />However, the unfortunate reality is that all complete methods cannot escape exponential growth. No matter how effective a specialized complete search is, there is always some input size which it too large to solve completely in practice. In the event you need to solve a problem of that size, local search or heuristic approaches, such as, simulated annealing, tabu search, genetic algorithms, and MCMC, become a necessity.<br /><br />To get back to the problem mentioned here. I would anticipate it can be solved using a complete search technique (as others have suggested enumeration seems feasible). However, consider solving the same problem for the entire school instead of just one class, with this change of context the solution approach maybe significantly different.Carletonhttps://www.blogger.com/profile/15810966486229396497noreply@blogger.comtag:blogger.com,1999:blog-3722233.post-11899598714672958902011-06-03T07:40:42.129-05:002011-06-03T07:40:42.129-05:00Is it clear that a solution always exists?
Actual...<i>Is it clear that a solution always exists?</i><br /><br />Actually, it is clear that there are scenarios where there is no solution. One simple example is where person A lists persons B,C,D as ones they want to work with and all three of those listed person A as the person they did not want to work with.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-3722233.post-44486326145486529272011-06-03T04:46:35.031-05:002011-06-03T04:46:35.031-05:00this looks like the stable allocation problem whic...this looks like the stable allocation problem which is somehow a generalisation of the stable marriage one.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-3722233.post-31943617420023414002011-06-02T23:29:31.099-05:002011-06-02T23:29:31.099-05:00Is it clear that a solution always exists?Is it clear that a solution always exists?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-3722233.post-59877467060965772382011-06-02T22:39:28.888-05:002011-06-02T22:39:28.888-05:00Does this count as a further argument for small cl...Does this count as a further argument for small class sizes?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-3722233.post-88946737566413882382011-06-02T14:35:54.824-05:002011-06-02T14:35:54.824-05:00Each person list 3 people they want to work with a...Each person list 3 people they want to work with and 3 they don't. As their group must contain one of each, there are only 9 possible groups this person could be in. So if you build a solution iteratively by trying all 9 groups for an ungrouped person, you should only have to try at most 9^6, or about half a million partitions. With pruning, this should be pretty fast.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-3722233.post-78656658313446713482011-06-02T13:51:30.648-05:002011-06-02T13:51:30.648-05:00It's interesting to think about the thresholds...It's interesting to think about the thresholds at which this becomes feasible. Obviously, the class is going to have some sort of social structure...but let's ignore that and assume all likes and dislikes are chosen u.a.r. In that case, the chance that two randomly chosen partners are OK with me are ((16 choose 2) - (13 choose 2))/(17 choose 2) ~ 0.31. Making lots of (false) approximations about uniformity, the probability a group of 3 is OK with all members is about 0.31^3 ~ 0.03, and the expected number of valid groups of 3 is about 24. I'd happily search for a size-six cover out of 24 subsets. (and I somewhat doubt one exists (in expectation.))Andrew Hunterhttps://www.blogger.com/profile/05886020093729586584noreply@blogger.comtag:blogger.com,1999:blog-3722233.post-63096244887554879202011-06-02T13:40:04.379-05:002011-06-02T13:40:04.379-05:00five posts and nobody pointing out the typo in the...five posts and nobody pointing out the typo in the title? for shame!Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-3722233.post-35679057246888787202011-06-02T11:42:08.976-05:002011-06-02T11:42:08.976-05:00This sort of problem, with working sub-solutions, ...This sort of problem, with working sub-solutions, might lend itself well to genetic algorithms. If there is no solution, it won't be able to tell you, but on the chance there is it'd be worth running a simulation for 40 minutes to see what it finds.Macneil Shonlehttps://www.blogger.com/profile/16382866616548432101noreply@blogger.comtag:blogger.com,1999:blog-3722233.post-85282989292919127062011-06-02T11:19:27.647-05:002011-06-02T11:19:27.647-05:00Yeah, this seems fairly tractable with the size gi...Yeah, this seems fairly tractable with the size given (and somewhat interesting.)<br /><br />I don't suppose you could ask your daughter ('s teacher) for (anonymized) data here so people can play with algorithms?Andrew Hunterhttps://www.blogger.com/profile/05886020093729586584noreply@blogger.comtag:blogger.com,1999:blog-3722233.post-55890406144783161022011-06-02T10:07:29.968-05:002011-06-02T10:07:29.968-05:00To complement Michael's and Scott's answer...To complement Michael's and Scott's answers (and to take the opportunity to advertise my own work) I just want to point out that there are much faster exact algorithms than "trying all partitions" for problems like exact cover by 3-sets. See <br /><br />http://arxiv.org/abs/0910.0460Andreas Bjorklundnoreply@blogger.comtag:blogger.com,1999:blog-3722233.post-32860158917318287272011-06-02T09:42:36.729-05:002011-06-02T09:42:36.729-05:00ok, but 190 million combinations is nothing for a ...ok, but 190 million combinations is nothing for a PC and should have been doable.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-3722233.post-81609801332035708052011-06-02T09:40:24.016-05:002011-06-02T09:40:24.016-05:00Lance --
Admittedly without thinking much about t...Lance --<br /><br />Admittedly without thinking much about the specific problem, I'll complain about your response.<br /><br />Sure, let's assume the problem is NP-complete. That doesn't mean that the particular instance is hard to solve. One might suspect, if there are an abundance of available solutions for this problem instance, that a good heuristic would find one very quickly.<br /><br />I say this because I teach an algorithms class, and in that class I specifically try to teach that "It's not do-able" when you get an NP-complete problem is not a suitable answer. (In the real world, I'd like to think that's the sort of attitude that would lead to a stagnant career.) Indeed, this is why I spend some time in the class on heuristic methods (even though that's somewhat unusual, I understand, for algorithms classes).<br /><br />A better answer would be that the problem seems NP-complete, so what can we do about that? (Use a heuristic, settle for an approximation, change the underlying problem somehow, see if it's small enough for brute force to work,...)Michael Mitzenmacherhttps://www.blogger.com/profile/02161161032642563814noreply@blogger.com