3

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?

Ajasja
  • 13,634
  • 2
  • 46
  • 104
Misery
  • 2,640
  • 1
  • 30
  • 39
  • Related question: http://mathematica.stackexchange.com/q/5181/5 – rm -rf 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
  • 7
    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 – rm -rf Sep 30 '12 at 16:42
  • Well, i know that it won't divine it for me. I am looking for an answer to: "where and how to begin that in mathematica?" – Misery Sep 30 '12 at 16:44
  • 2
    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. – rm -rf Sep 30 '12 at 16:45
  • related: http://stackoverflow.com/questions/2177836/algorithm-for-creating-a-school-timetable – cormullion Sep 30 '12 at 17:57
  • 3
    This sounds like a painful Integer Programming question. NP-Hard. http://en.wikipedia.org/wiki/Integer_programming – Amatya Sep 30 '12 at 19:37
  • also http://stackoverflow.com/questions/2304868/which-algorithm-to-use-for-generating-time-table-for-schools – Dr. belisarius Sep 30 '12 at 21:21

1 Answers1

2

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.

Per Alexandersson
  • 2,469
  • 15
  • 19
  • thanks :) now I'll manage to at least properly formulate my problem. Does Mathematica have any genetic algorithms built in? – Misery Oct 01 '12 at 05:37
  • 1
    Look up "DifferentialEvolution". – J. M.'s missing motivation Oct 01 '12 at 08: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 01 '12 at 12:08
  • 1
    @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.'s missing motivation Oct 01 '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 01 '12 at 12:48
  • @image_doctor: I see. I did sidestep the problem of how to formulate a scheduling problem into a form that can be processed by NMinimize[]... unfortunately, I have not done this in a while, so the particulars are hazy. – J. M.'s missing motivation Oct 01 '12 at 13:06
  • @J.M. Sorry, we may be talking at cross purposes, I'm not so concerned with scheduling, but with Mathematica's implementation of Genetic Algorithms. – image_doctor Oct 01 '12 at 23:48
  • Mathematica does not come with genetic algorithms as built-in functions. However, it is rather easy to implement yourself; You need a fitness function (that assigns a number that represents how good a schedule is), and a function for randomly mutate a schedule a bit (switching classes, rooms, etc). Then, start with 100 randomly generated schedules, select the top 10 based on their fitness, and create mutated copies of these until you have 100 again. Repeat until the best schedule is good enough. – Per Alexandersson Oct 02 '12 at 09:21