Scheduling courses in MATLAB.

Screen Shot 2013-09-08 at 2.53.57 PM

First up, a little background about me: I studied computer science at NYU for three years, then I transferred to Stevens to pursue mechanical engineering for another two. It’s all part of a dual-degree program between both schools that essentially allowed NYU to appeal to engineers while having no engineering department or school whatsoever (at least back when I entered). Suffice it to say Stevens filled the gear-shaped hole in NYU’s heart, until NYU went and bought a little place in Brooklyn *cough*NYUPoly*. Either way, I enjoyed the benefits of both schools, both the breadth of a city university and the closeness of a college campus in Hoboken. If for nothing else, it was often an interesting contrast.

Scheduling is hard.

At NYU, class sections tended to follow patterns in their scheduling. They would meet either Monday/Wednesday or Tuesday/Thursday, for the same 75 minute time period each day. Recitations and labs could meet later in the day, or on Friday, and there were plenty of choices for all. My transfer to Stevens was what taught me that I had been taking this sanity for granted; schedule chaos reigned supreme across the Hudson river in Hoboken, and for reasons still unclear…

I suppose that it’s difficult, as a college, to plan sections that every student can fit in their unique academic blueprint. But whatever sympathy I had for administration had long since evaporated by the third time I had to redo my schedule thanks to a rogue required section. It’s a battle I fight only twice a year on average, so maybe it’s a bit petty to complain. It actually only came to my serious attention again when a project sent me looking for an interesting and simple problem that had no right still existing.

Fast forward to my fourth year.  Sitting in a non-CS STEM class with CS experience under your belt is just about cheating. In this case, it was a Modeling and Simulation assignment that sought to get us better acquainted with programming in MATLAB. I’d already done these ‘Hello World’-ish exercises numerous times, so I got the green light to wander off on my own. Oh, the danger of freedom. How I got from ‘disp(2+2)’ to parsing XML in matrices and enjoyed doing so is still a mystery.

Meet Schedumator.

What I submitted in place of the original assignment was an abomination I dubbed The Schedumator. It retrieved an XML-based list of courses I stumbled upon on a Stevens server, and organized all the entries into a neat list of lecture, recitation, and lab sections. It asked the victim to enter the course numbers they needed next semester, ran a rather simple brute-force checking of all the various section permutations, then gurgled out all the schedules that would work sans-conflict. As a nice final touch, it gave you all the necessary registration call numbers.

ITS HIDEOUS.

function [sects,mtngs] = findMeet(r, q)
sects = {};
mtngs = {};
for i = 1:2:r.getLength-1 %skip by two to avoid #text nodes, bug in xml parse?
    %get the section number, title, and call number from the Course node
    s = char(r.item(i).getAttributes.getNamedItem('Section').getValue); 
    c_n = char(r.item(i).getAttributes.getNamedItem('Title').getValue);
    call = char(r.item(i).getAttributes.getNamedItem('CallNumber').getValue);
    s(s==' ') = ''; %removes all whitespace from section name
    if( length(s)-length(q)>1 ) % corrects the lab/recitation section problem, kind of a bandaid
       continue; 
    end
    if( length(strfind(s, q))==1  && length(strfind(s(2:end),q))==0 ) % make sure search starts at beginning
        for j = 1:2:r.item(i).getChildNodes.getLength-1 % once again skip by two to avoid #text
            if strcmp(r.item(i).getChildNodes.item(j).getNodeName,'Meeting') % if it is a meeting (ignoring requirments for now)
                attrs = r.item(i).getChildNodes.item(j).getAttributes;
                day = char(attrs.getNamedItem('Day').getValue);
                if strcmp(day,'TBA')~=1 %can't process 'TBA' unscheduled meetings
                    sects = [sects; {s}];
                    % gets start time and end time from meeting
                    startStr = char(attrs.getNamedItem('StartTime').getValue);
                    stopStr = char(attrs.getNamedItem('EndTime').getValue);
                    start = telltime(startStr);
                    stop = telltime(stopStr);
                    days = code(day);
                    for k = 1:length(days)
                        mtngs = [mtngs; {{s,days(k),start,stop,c_n,call}}];
                    end
                end
            end
        end
    end
end
sects = unique(sects); 

BUT IT WORKS.

input:
classes = {'ME342','ME335','ME358','ME358L','PE200F1','ME345','ME322'};
output:
SCHEDULE 1 ---------------
Mon 09:00am to 09:50am :: [ME342A Fluid Mechanics] (10889)
Mon 10:00am to 10:50am :: [ME335A Thermal Engineering] (10885)
Mon 12:00pm to 12:50pm :: [ME358A Machine Dynamics & Mechanisms] (10896)
Tue 12:00pm to 12:50pm :: [ME335A Thermal Engineering] (10885)
Tue 01:30pm to 03:00pm :: [PE200F1 Olympic Weight Lifting] (11224)
Tue 03:00pm to 04:40pm :: [ME345E Modeling and Simulation] (11917)
Wed 10:00am to 10:50am :: [ME335A Thermal Engineering] (10885)
Wed 12:00pm to 12:50pm :: [ME358A Machine Dynamics & Mechanisms] (10896)
Thu 09:00am to 10:40am :: [ME342A Fluid Mechanics] (10889)
Thu 01:00pm to 02:50pm :: [ME322D Engineering Design VI] (11910)
Thu 03:00pm to 04:50pm :: [ME358LB Machine Dynamics & Mechanisms] (10899)
Fri 09:00am to 10:50am :: [ME322D Engineering Design VI] (11910)
Fri 12:00pm to 12:50pm :: [ME358A Machine Dynamics & Mechanisms] (10896)
Fri 01:00pm to 02:40pm :: [ME345E Modeling and Simulation] (11917)
SCHEDULE 2 ---------------
Mon 09:00am to 09:50am :: [ME342A Fluid Mechanics] (10889)
Mon 10:00am to 10:50am :: [ME335A Thermal Engineering] (10885)
Mon 12:00pm to 12:50pm :: [ME358B Machine Dynamics & Mechanisms] (10897)
Tue 12:00pm to 12:50pm :: [ME335A Thermal Engineering] (10885)
Tue 01:30pm to 03:00pm :: [PE200F1 Olympic Weight Lifting] (11224)
Tue 03:00pm to 04:40pm :: [ME345E Modeling and Simulation] (11917)
Wed 10:00am to 10:50am :: [ME335A Thermal Engineering] (10885)
Wed 12:00pm to 12:50pm :: [ME358B Machine Dynamics & Mechanisms] (10897)
Thu 09:00am to 10:40am :: [ME342A Fluid Mechanics] (10889)
Thu 01:00pm to 02:50pm :: [ME322D Engineering Design VI] (11910)
Thu 03:00pm to 04:50pm :: [ME358LB Machine Dynamics & Mechanisms] (10899)
Fri 09:00am to 10:50am :: [ME322D Engineering Design VI] (11910)
Fri 12:00pm to 12:50pm :: [ME358B Machine Dynamics & Mechanisms] (10897)
Fri 01:00pm to 02:40pm :: [ME345E Modeling and Simulation] (11917)

And then a website.

Now I naturally don’t expect many students to do their scheduling in MATLAB, so what better opportunity to round up a team and get a website built before next semester’s registration? Hey, schedumator.com is still available, what luck!

  • Rob
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s