in reply to Re: [OT] simple algorithm for assigning students to class sections
in thread [OT] simple algorithm for assigning students to class sections
- Can it be assumed that they have eual distaste for all unrated sections?
Correct. They are supposed to rank all of the sections they are capable of attending. If they can't attend it, they don't rank it ... and anything they can't attend is equally worthless - Can a student be in more than one section?
no. (sorry, i should have considered that varient) - Do all sections have to have students? ... Do the numbers of places per section, total to the number of students?
Excellent question: No, and "not neccessarily"
I initially tried to simplify the description of the problem a little bit. A previous placement process has already partially filled these sections, the data I'll be starting with is the maximum number of additional students each section can accomidate and the list of students not yet placed in a section with their prefrences for a section.
It's completely possible that a section might allready be full (ie: have 0 room) and I believe it's possible that there may be more total students then their are spaces left.
- What are the orders of magnitude you are dealing with?
I believe I need to deal with roughly 750 students, 10-15 sections, and anywhere from 0 to 20 spots in each section.
I'm not adverse to using a brute force approach and letting it churn for a few hours. I'm just not sure what the best brute force approach is, or how to decide when one solution is "better" then another.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: [OT] simple algorithm for assigning students to class sections
by BrowserUk (Patriarch) on Dec 01, 2004 at 09:27 UTC | |
Have a play with this and see how you get on. Update: Corrected error in output code to display [EMPTY] if a course ends up with no students. Uncommented and improved format of output.
Output:
Examine what is said, not who speaks.
"But you should never overestimate the ingenuity of the sceptics to come up with a counter-argument." -Myles Allen"Think for yourself!" - Abigail "Time is a poor substitute for thought"--theorbtwo "Efficiency is intelligent laziness." -David Dunham "Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon | [reply] [d/l] [select] |
by hossman (Prior) on Dec 05, 2004 at 02:10 UTC | |
Thanks for the post, Sorry for my late reply -- works been busy, and my "client" (aka: my girlfriend) has been too busy grading finals to discuss how she really wants it to work, and what kind of "scoring" she wants to apply to permutations. Your approach is really cool (that reduce call is psycho by the way) but it doesn't seem to do very well in some simple cases. By iterating over "0 .. $maxChoices" at the core, and assigning people to sections as early as it can, it produces a lot of solutions in which people are left out of sections, even if another solution exists in which they do get into a section at the expense of someone else getting their second choice instead of their first. (It's definitely important to pay attention to people's prefrences, but a solution in which everyone gets their last choice is definitely better then a solution in which 90% of people get their first choice, and the other 10% don't get anything)... Read more... (2 kB)
Unfortunately, I don't see an easy way to fix this. A "try it several times and pick the best run" won't do much good, since randomness isn't even a factor in these problem cases (the "Alloc1" and "Alloc2" allocations are deterministic) Thoughts? | [reply] |
by BrowserUk (Patriarch) on Dec 05, 2004 at 07:53 UTC | |
Thoughts? Yes. You need a Jiggle® :) Of course, that doesn't guarentee a solution, but it seems to do remarkably well if a solution is possible. I couldn't reproduce your exact example (without hard coding it) but I found a couple of similar one that the above Jiggle solves:
And one which it didn't, but I don't thinkhas a solution with a one-level Jiggle?:
It also seems to work pretty well on much larger tasks (Output substantially trimmed to show just those affected by the jiggle: Read more... (6 kB)
Of course, you could code a 2-level Jiggle fairly easily, and you could go on to try for a recursive Jiggle. Though I think that it might be better to simply rotate the displaced students through the @students array until a solution is found (if possible). Regardless, the Jiggle seems to solve most solvable runs I've tried almost immediately, so it would need a solvable example, that it didn't find a solution for, before the extra effort would be worthwhile. The main body of the code is unchanged except I made the generator a little less prone to producing insoluble datasets. The Jiggle code is the at the end. It's fairly well commented. It uses a couple of discuised gotos (next/last on the outer loop) and a crude sentinel to break the infinite loop possibility with insoluable datasets. It could be better structured, but try it and see what you think? Read more... (9 kB)
PS. Sorry for leaving PM to do the wrapping -- it's been a long night :) Examine what is said, not who speaks.
"But you should never overestimate the ingenuity of the sceptics to come up with a counter-argument." -Myles Allen"Think for yourself!" - Abigail "Time is a poor substitute for thought"--theorbtwo "Efficiency is intelligent laziness." -David Dunham "Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon | [reply] [d/l] [select] |
by hossman (Prior) on Dec 07, 2004 at 07:39 UTC | |
Re^3: [OT] simple algorithm for assigning students to class sections
by Zero_Flop (Pilgrim) on Dec 01, 2004 at 05:24 UTC | |
| [reply] |