Blog Fiasco

January 28, 2011

How I scheduled a meeting

Filed under: Linux — Tags: , , , , — bcotton @ 8:09 am

Part of my responsibilities at work include wrangling our platoon of students. With most of them graduating at the end of this semester, I’ve preemptively hired many more to begin absorbing the knowledge necessary to keep a high performance computing shop running. The problem with students, though, is that they have classes to attend, which can make scheduling a bit of a bear. It gets worse as the number of students go up. Right now, I’ve got 14 separate schedules to balance .

I initially had them all register their availability using the free site whenisgood.net, but there were no times that worked for the whole group. Trying to figure out manually a pair of times that would get everyone to at least one meeting was challenging, but then I realized I could script it pretty easily. The hard part was turning each block on the calendar into either a 1 (available) or 0 (not available). Then it was simply a matter of trying every combination and rejecting the ones that don’t get everyone to at least one meeting.

The code below was saved as student_meeting.pl and invoked with a set of nested for loops like so:

for x in `seq 0 79`; do for y in `seq 0 79`; do perl student_meeting.pl $x $y 2>/dev/null; done; done

You may notice that each pair of available meetings would be printed twice. For example, 27 and 71 work, so 71 and 27 work as well and both get printed. The 0-79 represent the 80 half-hour time blocks from 9 AM to 5 PM Monday through Friday. The availability should be encoded similarly for each person inside the script. I include just mine in the example code so that you can see what it looks like. As it currently stands, the code is horrendous and not very robust. If there’s interest, I can clean it up some and put it on github. I’m not really sure if anyone else would care about it, but it might be a useful little project to someone else.

#!/usr/bin/perl

%availabilities = (
 'bcotton' => [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
 1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,0,
 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
 1,1,1,1,1,1,0,0,0,1,0,0,0,0,1,0,
 1,1,1,1,1,1,1,1,1,0,0,1,1,1,1,1],
 # More people would also be here
);

@accounts = keys(%availabilities);

$meeting1 = $ARGV[0];
$meeting2 = $ARGV[1];
$meeting1attendees = '';
$meeting2attendees = '';

foreach $person ( @accounts) {
 $goodtimes = 0;
 if ( $availabilities{$person}[$meeting1] == 1 ) {
 $goodtimes++;
 $meeting1attendees .= " $person";
 }
 if ( $availabilities{$person}[$meeting2] == 1 ) {
 $goodtimes++;
 $meeting2attendees .= " $person";
 }
 unless ( $goodtimes > 0 ) { die; }
 $goodmeetings{$person} = $goodtimes;
}

print "###\nMeeting times $meeting1 $meeting2\n";
print "Meeting 1 $meeting1attendees\nMeeting 2 $meeting2attendees\n";

3 Comments »

  1. There was a time I would have been quite excited by something like this. But, luckily for me, I no longer have to schedule Student Assistants to cover a desk. Oh, and don’t forget the fun of the add/drop period, when all your lovely schedules, have to be completely redone because almost every student changed their class schedule.

    Comment by Susan — January 28, 2011 @ 1:40 pm

  2. @Susan: students are lucky they’re cheap, because they’re a hassle.

    Comment by bcotton — January 28, 2011 @ 1:42 pm

  3. What, no use warnings or use strict? Not a lexical scoping to found. ;-)

    gizmo

    Comment by gizmomathboy — January 28, 2011 @ 9:58 pm

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress