Introduction to TOGA

Title:Introduction to TOGA
Author: Dave Haynes
Organization: Thuswise Ltd, UK
Contact: toga@thuswise.co.uk
Version: 0.01.002
Date: 8th August 2003

Contents

What is TOGA?

TOGA stands for "Timetables Optimised with Genetic Algorithms". It is an application to help with the development of school, college and university timetables.

TOGA is intended for the use of teachers and administrators. It requires them to supply information such as staff commitments, room sizes, and course enrolment data. Once these are defined, the timetable will be generated automatically.

Licence

I am releasing the code under the GNU Public License. I believe this is the best way to maximise the user base, and encourage involvement from other developers. Also, I'd like to support the use of Free and Open Source Software in public institutions. The program is written in Python, whose community has a reputation for openness and altruism.

Before you read this guide...

This is a very early version of TOGA, and there is a lot to do before it becomes a complete solution to the task of automated timetabling. It has been released in this state for the following reasons:

TOGA is currently run from the command line, and only available as source code. This may present a difficulty to you if you are not used to using software this way. If this is the case, please send me an email, and I'll try to help. I'm happy to do this because TOGA's future user base will mostly be a non-technical bunch, and I need to understand the issues that are likely to arise.

For those who are able to work from the command line, I have implemented a help system which should be adequate to get you started. A key thing to realise is that TOGA's data model is structured like a Relational Database. This means tables of records, in third normal form. These tables are saved to file as comma separated values.

This guide explains some of the key concepts. However...

Describing the Problem

To use TOGA you are going to have to describe the circumstances under which your school operates. TOGA uses a Data Model of a typical school or institution. It organises this data in memory as twelve tables.

You input the data to TOGA as twelve files, one for each of TOGA's tables. These files may be created in a standard spreadsheet application, such as OpenOffice.org Calc or Microsoft Excel. Together, they describe all the relationships which TOGA needs to build the timetable.

I'll explain more about the tables below. Some of the tables contain references to data in other tables. This means that the tables have to be defined in a certain order. In fact, the tables fall into five groups, and all of the tables in the first group have to be complete before defining those in the second group, and so on. I call these groups tiers, and I label them 0 to 4.

Tier 0 tables

Resource Table
This table contains all the different kinds of resources available, from Squash Courts to Language Labs. Identified by a unique resource code.
Location Table
This table describes all the places in which teaching may take place, and the number of people they can hold. Indexed by a unique location number.
Department Table
All departments which run courses are given here, indexed by a unique department number
Staff Table
Members of staff, indexed by a unique staff number.
Pupil Table
Pupils at the school or institution, all of whom have a unique pupil number
Slot Table
A slot is a space in the timetable where a lesson can occur. Each slot has a unique number.

Tier 1 tables

Tier 1 tables may only be created after all the Tier 0 tables have been defined.

Facility Table
This table specifies where resources may be found in the school or institution.
Course Table
This table contains all the courses offered by departments.
Commitment Table
This table shows which of the staff are able to work for each department, and their proportionate commitment.

Tier 2 tables

Tier 2 tables may only be created after all the Tier 1 tables have been defined.

Lesson Table
This table contains all the lessons which deliver each course.
Enrolment Table
This table shows which pupils have enrolled for which courses.

Tier 3 tables

Tier 3 tables may only be created after all the Tier 2 tables have been defined.

Requirement Table
This table records which lessons require which facilities
Candidate Table
The user does not need to supply this table. It is an internal representation of proposed solutions which is created during optimisation, and then destroyed. One Candidate is finally chosen to produce the Prototype Table.

Tier 4 tables

Tier 4 tables may only be created after all the tier 3 tables have been defined.

Prototype Table
This table provides a complete record of a timetable. It records each instance of a pupil attending a lesson; the location, slot, and the member of staff who takes that lesson.

Producing the Timetable

Obtaining an optimised timetable is an iterative process. First you create your .csv files. At this point, you should not try to include too much information in your model. In particular, restrict staff commitments to their core competencies only. If you forget the syntax of the tables, use the TOGA Help Pages as a guide to creating your twelve files.

Once this is done, you use other command line options to read the files into TOGA's in-memory database. There is a command to check the data for integrity, and another to begin creating an optimised timetable.

TOGA saves session information as it goes. This means that if you are unhappy with the results after an optimisation run, you may run it again from where it left off. You may also make changes to your table files, say, to add a staff commitment, and use the previous solutions as a basis for the new timetable. Alternatively, you can instruct TOGA to delete its session, and start again from scratch.

TOGA can output its timetable as a set of simple web pages. These are generated for every member of staff. The Booking Table may be saved to file as a permanent record of the TOGA database.

TOGA also has a batch mode, so that you can repeat the whole process with one command only. This is a great help when the initial timetable is infeasible, and changes must be made to the data files.

How TOGA works

TOGA uses a Genetic Algorithm to optimise a population of potential solutions. At first, these solutions are generated at random. However, individual solutions may be mated to produce offspring in a manner which imitates nature. By using the processes of Crossover and Mutation, the offspring of two solutions may inherit features of their parents, but may also develop new ones.

Solutions are evaluated for their fitness by an Objective Function. We use this function to pick the best mating pairs, so that offspring solutions have the best chance of being more favourable than their parents.

TOGA's objective function actually checks the fitness of a solution against many criteria. This is called Multi- Objective Evolutionary Optimisation.

Generation after generation, the solution population will get better. Eventually it will reach a state of Pareto-Optimality where no solution is measurably better than another, although all are different. From then on, the algorithm ensures that the solutions are as diverse as possible, and a final choice is made according to soft constraints which may make some solutions more preferable than others.

TOGA's genetic optimiser uses an algorithm called NSGA II 3. The NSGA2 module is still under development, but currently enables solutions to be coded as Haploid individuals, of which simple animals like amoeba are an example, or as Diploid individuals, which mimic the mechanisms of more complex life.

The Objective Function

TOGA's Objective function measures a number of properties of each Candidate timetable. This function maintains separation amongst the criteria, rather than trying to create a single metric from a weighted sum. This means that in principle any number of parameters may be minimised.

The parameters currently minimised by TOGA are:

clash
A measure of the number of times a candidate timetable commits a pupil to two lessons in the same slot.
squeeze
The number of times a lesson is scheduled for a room which is too small for the class.
unfit
The number of times a lesson is scheduled for a room which does not have the resources the lesson requires.

References

[1]Thomas Connolly and Carolyn Begg (2000) "Database Solutions, a step -by-step guide to building databases". Addison-Wesley.
[2]Goldberg, D. E (1989) "Genetic Algorithms for Search, Optimization, and Machine Learning". Addison-Wesley.
[3]Deb, K. (2001) "Multi-Objective Optimization using Evolutionary Algorithms". Wiley.