# How to use mathematica to create school time-table?

I wonder if it is possible to use Mathematica for helping myself to create school timetable. I have a feeling that it requires quite simple optimization algorithm, but I have never been into optimization, so I don't really know where to start.

The task looks like that:

1. I have a given free class rooms at certain time points.
2. I have an information about how much time and places require certain lessons
3. Also I do have some teacher preferences - some would prefer mornings, some evenings etc.

Is there any function that would help solve that matter?

-
Related question: mathematica.stackexchange.com/q/5181/5 – R. M. Sep 30 '12 at 16:40
It is not related to the mentioned question. I have here some kind of optimization question, not visualizing the tabular data. – Misery Sep 30 '12 at 16:42
More importantly, have you tried formulating this as an optimization problem? Have you written down what the objective function should be and what the constraints are? If not, then Mathematica won't automatically divine that for you. I suggest you formulate the question mathematically first and then show us where you're getting stuck in Mathematica – R. M. Sep 30 '12 at 16:42
Yes, I understand your question... my followup question was: Have you thought about where to begin and how to formulate it mathematically? If you have, share it with us and then it is easier to help you with the Mathematica aspect of it. – R. M. Sep 30 '12 at 16:45
This sounds like a painful Integer Programming question. NP-Hard. en.wikipedia.org/wiki/Integer_programming – Amatya Sep 30 '12 at 19:37

I'd try this with some sort of genetic algorithm. Motivation: It suffices to find a reasonably good schedule, not THE best schedule, since the function you're maximizing is not canonical, (optimize to use the least number of rooms, best room preference or something in between?). Also, the search space is huge, and finding an exact solution is most likely NP-hard (time slots in rooms -> knapsack problem).

Thus, randomly generate a schedule, then make a bunch of random modifications, select a few that are "better" according to your fitness function, and repeat until you have a decent schedule.

-
thanks :) now I'll manage to at least properly formulate my problem. Does Mathematica have any genetic algorithms built in? – Misery Oct 1 '12 at 5:37
Look up "DifferentialEvolution". – J. M. Oct 1 '12 at 8:45
@J.M. This seemed interesting, I didn't find any details on the algorithm being implemented for DifferentialEvolution, is there a more detailed reference I've missed ? – image_doctor Oct 1 '12 at 12:08
@image_doctor: OP was asking about genetic algorithms, and that's why I brought up the particular example that is built into Mathematica. In any event, see this paper, among many other papers on the use of differential evolution in task scheduling. – J. M. Oct 1 '12 at 12:16
@J.M. Thanks very much for the link, but sadly I don't have access to IEEE papers. My query was more motivated out of an interest of the particulars of the algorithm in Mathematica, rather than GAs for Scheduling problems in general. – image_doctor Oct 1 '12 at 12:48