MKS_sjacques Posted September 8, 2006 Report Share Posted September 8, 2006 I'm trying to write a flexible round robin program for randomly scheduling teams to play one another. There is one variable, the # of teams, which has to be an even number. The fixed constants are that every team has to play all of the other teams, but they only play all of the teams once, and all teams play on the same day every week... seems fairly straightforward to do... So what I have so far seems to work initially, but it then bogs down as the # of possible pairings dwindles... I basically initialize a 2D array (#teams x #teams-1) so for example if there's 10 teams, there would only be 9 sets of matches (9 weeks), as the teams don't play themselves. I have a couple of for loops to strip out the row and column indexes, a random # generator to generate random opponents, and some logic to sort out if the randomly selected team has played the matched team before (across the row) and if they were matched to play any other team that week (down the column). So in an 8 team environment, you could imagine the first weeks games as team 1 vs team 4, team 2 vs team 3, team 5 vs team 7, and team 6 vs team 8. The rub is that I have seen the algorithm pick the next weeks matchups as team 1 vs team 7, team 2 vs team 5, team 3 vs team 4, and it hangs because now it's trapped itself into team 6 vs team 8 again... Anyone ever do something like this? I was thinking I'll just keep scrapping the row until the program is able to randomly come up with a matching that works for that week, but I was hoping for a more scientific way to "randomly" generate a schedule... Any thoughts? Quote Link to comment
Bob Y. Posted September 8, 2006 Report Share Posted September 8, 2006 I haven't done this in LabVIEW, but a quick google search turned up http://en.wikipedia.org/wiki/Round-robin_tournament and http://www.devenezia.com/javascript/articl...oundRobin3.html This seems to be a fairly good explanation and sould be easy to implement in LabVIEW (or with even less translation, a math script node). I might play with implementing it this weekend, but don't wait on me! :beer: Hope that this helps, Bob Young Quote Link to comment
MKS_sjacques Posted September 11, 2006 Author Report Share Posted September 11, 2006 Bob, Thanks for the info, I also came across the javascript RR generator link, trouble with those is that they are "patterned", i.e. they follow the round robin algorithm and you can clearly see a pattern... what I wanted to do was to randomize the results such that there's no discernable pattern to the viewer... so it would be some form of the RR algorithm... I've even generated code that randomizes the columns after the RR schedule is created, but there's still a visible pattern by column... Thanks again for your inputs! Steve I haven't done this in LabVIEW, but a quick google search turned up http://en.wikipedia.org/wiki/Round-robin_tournament and http://www.devenezia.com/javascript/articl...oundRobin3.html This seems to be a fairly good explanation and sould be easy to implement in LabVIEW (or with even less translation, a math script node). I might play with implementing it this weekend, but don't wait on me! :beer: Hope that this helps, Bob Young Quote Link to comment
Darren Posted September 13, 2008 Report Share Posted September 13, 2008 This problem always intrigued me, but I was never able to come up with a solution. In case anybody is interested, I posted the Round Robin problem on the LabVIEW Puzzles thread on the NI Forums, and one of the NI Forums members named ShotSimon was able to come up with a solution. See here. -D Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.