You are on page 1of 55

1

TIMETABLE GENERATION USING AI ALGORITHMS


-Sudip Gupta 10304291 -S Senthilkumar 10304255

ABSTRACT
This project deals with the stages of building a substantial, carefully specified, fully tested and fully operational university and school timetabling system. The emphasis is on the software engineering aspects of the problem. That is, Constraint Satisfaction problems are expressed in a language more familiar to the formal software engineering community. Moreover, this project is used to formulate domain constraints and heuristic information. In addition to that, the user's needs are looked at more closely. For instance, the system supplies indications useful for relaxing or reformulating the constraints of the problem when a solution satisfying these constraints is impossible to produce. This has a value in bringing Constraint Satisfaction one-step closer to formal

specification, program verification and transformation.

The project is developed using Java and Windows file system for a standalone application. The basic inputs are obtained from user and the inputs are processed and the time table is generated accordingly. As time tables are must in educational institutions this project would be highly helpful

TABLE OF CONTENTS
CHAPTER 1. INTRODUCTION 1

CHAPTER 2. 2.1. 2.2.

WORKING ENVIRONMENT HARDWARE SPECIFICATION SOFTWARE SPECIFICATION

2 2 2

CHAPTER 3. 3.1. 3.2. 3.3. 3.4

SYSTEM STUDY EXISTING SYSTEM LIMITATIONS OF EXISTING SYSTEM PROPOSED SYSTEM ADVANTAGES OF PROPOSED SYSTEM

3 3 4 4 5

CHAPTER 4. 4.1. 4.2. 4.3.

SYSTEM ANALYSIS FEASIBILITY STUDY DATAFLOW DIAGRAM / BLOCK DIAGRAM MODULE DESCRIPTION

6 6 7 9

CHAPTER 5. 5.1. 5.2.

SYSTEM DESIGN MODULE DESIGN CODING

14 14 17

CHAPTER 6. 6.1. 6.2.

SYSTEM TESTING UNIT AND INTEGRATION TESTING OUTPUT SCREENSHOTS

40 40 41

CHAPTER 7.

FUTURE ENHANCEMENTS

48

CHAPTER 8.

CONCLUSION

49

CHAPTER 9.

REFERENCES

50

INTRODUCTION
Time table of a university is the backbone for organizing classes. Universities like SRM University boast a huge student crowd and hence, lots of classes are there in each department. Creating a timetable with no clash of subjects and teachers is really a tough job while doing manually. Here, a time table has 5 working days with 7 periods each. 4 periods in first half and 3 in second. Each section has two lab subjects. When number of teachers is more than the required, the generation becomes an easy job. Here, we are focusing on creating a time table with optimal number of teachers so that we can have reserve teachers when needed. The time table generated by the system is applicable only for UG courses as PG courses have different constraints hence creating time table for both UG and PG is a tough job to do. Information schema here can be further extended when designing a system for Pg courses.

TimeTable Problem Timetable generation is a NP-hard problem .i.e. there is no specific algorithm which can be used for creating timetables. As constraints for timetable vary from institute to institute, separate algorithm has to be defined for each institute. The method of backtracking has been used earlier. The get the best performance out of our algorithms, we allot slots to subjects in such a way that either they get their final positions or remain unalloted which is allotted later after other subjects are allotted. Also arrangement of teachers plays a major role in our methodology as most of the subject constraint as well as teachers are validated while assigning teachers. Teacher assignment problem With minimal number of teachers in the repository, this project advances towards its generations of various tables. There are various constraints for teachers which have been listed out in the literature review. Stress on teacher has to be minimal as there is a limit of efficiency for human working. These constraints, rather than using as hurdles, have been used in our project

As they guide us on how subjects can be for teachers, those guidelines have been used at the time of creating subject timetable itself so that teacher assignment becomes an easy job. The system designed here has been designed in such a way that it can be used as a standalone application so that any system with java in it can run the application.

1. LITERATURE REVIEW The following application is an intense application of algorithmic codes. There are various constraints which makes this process a manually impossible process to do. Constraints are applicable on period allotment, teacher assignment and various other fields. The application time table must have 5 working days with 7 slots of working hours each i.e. 7 periods for 5 days from Monday to Friday. Each day slot is divided into 4 periods in first slot and three in second. Labs are of 3 periods each. Preference should be given for 2 n d , 3 r d and 4 t h or in the 2 n d half. If one lab falls on 1 s t half in a week, the next lab subject must fall on the 2 n d half. No two classes of same year are allowed to have same lab on same day and slot. Theory subject have credit based marking. They are divided into 4credit subjects and then in the decreasing order. The credits are pre-decided. Mathematics subjects are usually 4 credit subjects. Followed by lab specific theory subjects also as 4 credit subjects. Other theory subjects are 3 credit papers whereas language is 2 credit Other non-engineering specific subjects are in 1 credit subjects. 4 credit subjects must have more than 7 hrs a week where as 3 credits must have 5-6 subjects per week. 4 credits are preferred in the beginning of daily slots i.e. 1 s t , 2 n d , 5 t h or 6th. Theory may follow 4 credits after that. For ease of further period and slot allotment, lab period is avoided for the day having the corresponding lab. 4 credit subjects must have slots daily.

For faculty

Faculties must have one subject of their own preference and other of not, if any subjects does not have itself as preference of any teacher. Class in-charge must get subject and class of his preference but it must be a 4 credit one with a lab. Faculties must not have more than 3 theory papers on a day. Faculties must not have more than 1 theory on a day if he/she has a lab on that day They should not have consecutive periods in two different classes. Non-departmental subjects should be given least priority while assigning faculty 3 credit elective subjects must be given 1 s t priority while assigning staffs for 3 credit subjects. Some free periods must be there for library, counseling and sports purpose.

3. WORKING ENVIRONMENT

HARDWARE SPECIFICATION

Processor RAM Hard Disk CDROM Monitor Key Board Mouse

: :

Intel Pentium III, 866 MHz 256 MB : 40 GB

: : : :

52X 15 110 keys keyboard 3 button Mouse

SOFTWARE SPECIFICATION

Operating System : Front End Back End : :

Windows XP Java Windows File System

4. SYSTEM STUDY

4.1EXISTING SYSTEM

Time Table creation is tedious and time consuming process for the faculty in charge. At present this is done manually as there are no efficient time table generators. While framing time table the basic problems are slot clashes. Allotting periods itself is so tedious that allotting the whole time table is not at all efficient when done manually. So, even the software which have already been created do not comply with the constraints of our university.

4.2 LIMITATIONS OF EXISTING SYSTEM Time Consuming Tedious Process Manual Labor Less flexibility

4.3 PROPOSED SYSTEM

This algorithm based application allots periods (theory as well as labs) in such a way that no period clashing or faculty period clash is met. We pair subjects in such a way that teachers remain associated and no period clash appears. Subjects are allotted as per credit and their lab classes. 4 credit papers are given preference for number of periods per week and is allotted as per the corresponding lab day. This avoids the constraint of number of subjects per day both theory and lab for a faculty.

10

Then we assign subjects to teacher as per their seniority and as per their preference. This is done starting from the 4 credit subject first and then the 3 credits and then the unassigned subjects. This keeps utmost care of the designation of faculties and their preferences. This procedure creates not only a feasible TimeTable for our department but also an optimal one. Output of the application is not only the class time table but also faculty timetable ,both the optimum ones.

4.4ADVANTAGES OF PROPOSED SYSTEM Effective Easy re-arranging of periods Not time Consuming No mental stress Generate various sets of time tables

11

SYSTEM ANALYSIS 5.1 FEASIBILITY STUDY

The methodology that is used in this project is described as follows. The number of theory papers including their credits and the practical courses are obtained initially. The teachers give their area of interests. We first allot the lab sessions for all the classes. Then the time table is ensured to have four credit papers daily either at the forenoon or at the afternoon sessions. We then fill up the time table with three credits followed by two credits. Classes are filled leaving one period in the forenoon or in the afternoon. This period is at last considered for one credit subjects or library or seminar hours. Subjects are allotted to staffs as per their preference given by them prior to the generation of the time table. At certain cases the second choice is also considered. The time table is framed following all the constraints and providing the utmost flexibility to the institution.

12

5.2 DATA FLOW DIAGRAM

5.3 MODULE DESCRIPTION

13

Module 1: Input of Required Data In this module, information is taken from the authority as per the following sequence to ensure ease of input as well as proper information schema filling: 1. Number of sections for each year 2. Subjects for that corresponding year 3. Teacher information 4. Corresponding subject preference The information is then stored in separate and organized serializable files and is linked to its corresponding class so that the following modules can use data easily

Module 2: Lab Allotment In this module, lab slots are decided as per the number of sections.Lab periods should be allotted in such a way that all constraints are satisfied and optimal lab slots are allotted. In case the slots clash with each other, allotment is started again from the beginning.

14

Module 3: Theory period allotment In this module, we allot the 4 credit subjects first and then 3 credits subjects. While allotting, the theory paper corresponding to the lab period on that day is not allotted for optimized subject generation. Also 4 credit papers are allotted either in the 1 s t or 2 n d period or in the second half. If any free slot is available, non-departmental subjects are allotted.

15

Module 4: Faculty assignment Subject is allotted to the respective class teachers as per their preference. Then, the 4credit subjects are assigned to the faculty as per seniority and as per their preference. Once the subjects are assigned, each teachers subject count is raised by 1. In the similar way, 3 credit subjects are allotted their respective faculties. This information later helps us to assign when the preferences are allotted and the subjects still remain unassigned.

16

Then, the unassigned subjects are assigned to the faculties whose subjects are still left and the periods do not clash with the unassigned once. This is done by the paring which was used in lab allotment. This way, no teacher will have the periods consecutively or at the same period in two different subjects.

17

6. System Design Module Design:

18

6.2 Coding PERIOD ALLOTMENT:

package teacher; import teacher.classinfo; import teacher.JxFrame; import java.awt.*; import java.awt.event.*; import java.util.*;

//swing classes import javax.swing.text.*; import javax.swing.*; import javax.swing.event.*; import javax.swing.border.*; import java.util.*; import java.io.*;

public class SimpleTable2 extends JxFrame { public SimpleTable2() { super("Simple table"); try{

19

JPanel jp = new JPanel(); getContentPane().add(jp); ObjectInputStream is=new ObjectInputStream(new FileInputStream("yrinfo.ser")); Cl plobj=(Cl)is.readObject(); is.close(); pds p1=new pds(); pds p2=new pds(); pds p3=new pds(); pds p4=new pds(); pds p5=new pds(); pds p6=new pds(); int[] code = new int[9];

code[0]=plobj.th1; code[1]=plobj.th2; code[2]=plobj.th3; code[3]=plobj.th4; code[4]=plobj.th5; code[5]=plobj.th6; code[6]=plobj.th1; code[7]=plobj.th2;

20

int lab1=0; int lab2=0; int no=plobj.numsec; int i; int[] a = new int[36]; int[] b = new int[36]; int[] c = new int[36]; int[] d = new int[36]; int[] e = new int[36]; int[] f = new int[36];

int max = 8; for (i = 1; i <= 35; i++) { a[i] = 1; b[i] = 1; c[i] = 1; d[i] = 1; e[i] = 1; f[i] = 1; } int sec = no;

int n;

21

n = sec; int x, y; x = 2; y = 26; a[x] = lab1; a[x + 1] = lab1; a[x + 2] = lab1; a[y] = lab2; a[y + 1] = lab2; a[y + 2] = lab2; //a[21]=a[35]=30; n--; x = x + 7; if (x > 31) x = 2; y = y + 7; if (y > 34) y = 5; if (n > 0) { b[x] = lab1; b[x + 1] = lab1; b[x + 2] = lab1; b[y] = lab2;

22

b[y + 1] = lab2; b[y + 2] = lab2; //b[28]=b[7]=30; n--; } x = x + 7; if (x > 31) x = 2; y = y + 7; if (y > 34) y = 5; if (n > 0) { c[x] = lab1; c[x + 1] =lab1; c[x + 2] = lab1; c[y] = lab2; c[y + 1] = lab2; c[y + 2] = lab2; //c[14]=c[35]=30; n--; } x = x + 7; if (x > 31)

23

x = 2; y = y + 7; if (y > 34) y = 5; if (n > 0) { d[x] = lab1; d[x + 1] = lab1; d[x + 2] = lab1; d[y] = lab2; d[y + 1] = lab2; d[y + 2] = lab2; n--; } x = x + 7; if (x > 31) x = 2; y = y + 7; if (y > 34) y = 5; if (n > 0) { e[x] = lab1; e[x + 1] = lab1; e[x + 2] = lab1;

24

e[y] = lab2; e[y + 1] = lab2; e[y + 2] = lab2; n--; } x = x + 7; if (x > 31) x = 2; y = y + 7; if (y > 34) y = 5; if (n > 0) { f[x] = lab1; f[x + 1] = lab1; f[x + 2] = lab1; f[y] = lab2; f[y + 1] = lab2; f[y + 2] = lab2; n--; } x = x + 7; if (x > 31) x = 2;

25

y = y + 7; if (y > 34) y = 5; int q = 0; for (i = 0; i <35; i++) { if (a[i] == 1) { a[i] = code[q]; q++; } if (q > max - 1) q = 0; } n = sec; n--; if (n > 0) { for (i = 1; i <= 35; i++) { if (b[i] == 1) b[i] = code[q]; q++; if (q > max - 1) q = 0; } }

26

n--; if (n > 0) { for (i = 1; i <= 35; i++) { if (c[i] == 1) c[i] = code[q]; q++; if (q > max - 1) q = 0; } } n--; if (n > 0) { for (i = 1; i <= 35; i++) { if (d[i] == 1) d[i] = code[q]; q++; if (q > max - 1) q = 0; } } n--; if (n > 0) { for (i = 1; i <= 35; i++) {

27

if (e[i] == 1) e[i] = code[q]; q++; if (q > max - 1) q = 0; } } n--; if (n > 0) { for (i = 1; i <= 35; i++) { if (f[i] == 1) f[i] = code[q]; q++; if (q > max - 1) q = 0; } }

/* * * * *

28

* * * * * * */

Object[] [] musicData1= { { "cs"+ a[1], "cs"+ a[2], "cs"+a[3], "cs"+a[4], "cs"+ a[5], "cs"+ a[6], "cs"+ a[7] }, { "cs"+ a[8], "cs"+ a[9], "cs"+ a[10], "cs"+ a[11], "cs"+ a[12],

29

"cs"+ a[13], "cs"+ a[14] },{ "cs"+ a[15], "cs"+ a[16], "cs"+ a[17], "cs"+a[18], "cs"+a[19], "cs"+ a[20], "cs"+ a[21] },{ "cs"+ a[22], "cs"+ a[23], "cs"+ a[24], "cs"+ a[25], "cs"+ a[26], "cs"+ a[27], "cs"+ a[28] },{ "cs"+ a[29], "cs"+ a[30], "cs"+ a[31], "cs"+ a[32],

30

"cs"+ a[33], "cs"+ a[34], "cs"+ a[35] } };

Object[] [] musicData6= { { f[1], f[2], f[3], f[4], f[5], f[6], f[7] }, { f[8], f[9], f[10], f[11], f[12],

31

f[13], f[14] },{ f[15], f[16], f[17], f[18], f[19], f[20], f[21] },{ f[22], f[23], f[24], f[25], f[26], f[27], f[28] },{ f[29], f[30], f[31], f[32],

32

f[33], f[34], f[35] } };

Object[] [] musicData2= { { b[1], b[2], b[3], b[4], b[5], b[6], b[7] }, { b[8], b[9], b[10], b[11], b[12],

33

b[13], b[14] },{ b[15], b[16], b[17], b[18], b[19], b[20], b[21] },{ b[22], b[23], b[24], b[25], b[26], b[27], b[28] },{ b[29], b[30], b[31], b[32],

34

b[33], b[34], b[35] }

};

Object[] [] musicData3= { { c[1], c[2], c[3], c[4], c[5], c[6], c[7] }, { c[8], c[9], c[10], c[11],

35

c[12], c[13], c[14] },{ c[15], c[16], c[17], c[18], c[19], c[20], c[21] },{ c[22], c[23], c[24], c[25], c[26], c[27], c[28] },{ c[29], c[30], c[31],

36

c[32], c[33], c[34], c[35] } };

Object[] [] musicData4= { { d[1], d[2], d[3], d[4], d[5], d[6], d[7] }, { d[8], d[9], d[10], d[11],

37

d[12], d[13], d[14] },{ d[15], d[16], d[17], d[18], d[19], d[20], d[21] },{ d[22], d[23], d[24], d[25], d[26], d[27], d[28] },{ d[29], d[30], d[31],

38

d[32], d[33], d[34], d[35] } };

Object[] [] musicData5= { { e[1], e[2], e[3], e[4], e[5], e[6], e[7] }, { e[8], e[9], e[10], e[11],

39

e[12], e[13], e[14] },{ e[15], e[16], e[17], e[18], e[19], e[20], e[21] },{ e[22], e[23], e[24], e[25], e[26], e[27], e[28] },{ e[29], e[30], e[31],

40

e[32], e[33], e[34], e[35] } }; for(i=1;i<=35;i++) { p1.p[i]=a[i]; } for(i=1;i<=35;i++) { p2.p[i]=b[i]; } for(i=1;i<=35;i++) { p3.p[i]=c[i]; } for(i=1;i<=35;i++) { p4.p[i]=d[i]; } for(i=1;i<=35;i++)

41

{ p5.p[i]=e[i]; } for(i=1;i<=35;i++) { p6.p[i]=f[i]; }

ObjectOutputStream os6=new ObjectOutputStream(new FileOutputStream("sec1.ser")); os6.writeObject(p1); os6.close(); ObjectOutputStream os5=new ObjectOutputStream(new FileOutputStream("sec2.ser")); os5.writeObject(p2); os5.close(); ObjectOutputStream os4=new ObjectOutputStream(new FileOutputStream("sec3.ser")); os4.writeObject(p3); os4.close(); ObjectOutputStream os3=new ObjectOutputStream(new FileOutputStream("sec4.ser")); os3.writeObject(p4); os3.close();

42

ObjectOutputStream os2=new ObjectOutputStream(new FileOutputStream("sec5.ser")); os2.writeObject(p5); os2.close(); ObjectOutputStream os1=new ObjectOutputStream(new FileOutputStream("sec6.ser")); os1.writeObject(p6); os1.close();

String[] columnNames = {"1st", "2nd", "3rd","4th","5th","6th","7th"};

JTable table1 = new JTable(musicData1, columnNames); JScrollPane sp1 = new JScrollPane(table1); table1.setPreferredScrollableViewportSize(new Dimension(800,100));

jp.add(sp1); JTable table2 = new JTable(musicData2, columnNames); JScrollPane sp2 = new JScrollPane(table2); table2.setPreferredScrollableViewportSize(new Dimension(800,100));

jp.add(sp2);

43

JTable table3 = new JTable(musicData3, columnNames); JScrollPane sp3 = new JScrollPane(table3); table3.setPreferredScrollableViewportSize(new Dimension(800,100));

jp.add(sp3); JTable table4 = new JTable(musicData4, columnNames); JScrollPane sp4 = new JScrollPane(table4); table4.setPreferredScrollableViewportSize(new Dimension(800,100));

jp.add(sp4); JTable table5 = new JTable(musicData5, columnNames); JScrollPane sp5 = new JScrollPane(table5); table5.setPreferredScrollableViewportSize(new Dimension(800,100));

jp.add(sp5); JTable table6 = new JTable(musicData6, columnNames); JScrollPane sp6 = new JScrollPane(table6); table6.setPreferredScrollableViewportSize(new Dimension(800,100));

jp.add(sp6); setSize(1300,1800); setVisible(true); }catch(Exception ex)

44

{ System.out.println(ex.toString()); } } static public void main(String argv[]) { new SimpleTable2(); } } class pds implements Serializable { int[] p=new int[36]; }

45

7. SYSTEM TESTING

7.1 Unit Testing

Each module in the project is tested unit wise. The project on completion of testing is verified with all the constraints The initial unit is the input of all the data. The data is inputted as per the required class allotments. Insufficient of staffs would lead to generating incorrect timetable as many periods would be unallocated. The class teachers enter their input first followed by the professors, assistant professors and the lecturers. They enter their designation and their preference of three subjects. All the inputs are stored in corresponding databases so that it could be retrieved for later use. The next phase deals with the initial period allotment. The initial period allotment is done in the preference of the staffs. The class in-charges take their subject of preference followed by the professors then the assistant professors and then the lecturers. There might be worse situations where we might force someone to take a subject if their preference does not match with the given list.

Unit testing for Lab Allotment

The next unit to be tested is allotment of lab slots. For lab allotment, the designed system is programmed in such a way that no two classes have same lab slot for same lab subject. Also lab is preferred either in 2 n d , 3 r d , 4 t h or in the second half of a day. Our inputs for testing are the lab subjects. A few constraints that effect the time table because of lab are choices made by class-in-charges, as well the subject which have lab subject for that specific year. The output we got was a time table with labs allotted in such a way that no two sections had same lab day and classes.

46

Time table generated had same time table for two sections only if number of sections exceeded 6 sections which is obvious.

Also the theory arrangement of the subjects corresponding to lab is determined based on lab allotment.

47

7.2 SNAPSHOTS Fig 7.2.1 Main form

48

Teacher form

49

Class teacher form

Class Time Table

50

51

Faculty Time Table:

52

CONCLUSION
Thus, the project to generate a timetable is completed successfully in four modules using Java2SE6 as front end, and windows Serializable file system as backend, with the functional components of the project and the minimum requirements satisfied. Separate timetable for subjects and teachers are generated for a class. automatically by this system. An optimal timetable is generated by this timetable so that later when change is done, timetables work with optimal efficiency. The project reduces the time consumption and the stress of framing it manually. The project is developed in such a way that, no slot clashes occur providing features to tailor the timetable as of wish. Additional feature in this timetable is that when a teacher leaves the institution or goes on a leave, substitution staff can be assigned without effecting others timetable.

53

FUTURE ENHANCEMENTS

The future enhancements that can be developed from this project is to generate a timetable for PG courses and then combining it to the present timetable generator. The techniques used here can also be implemented for PG courses with change in their constraints. Information schema is also the best suited one for this project. Full code and the project can be obtained by requesting the department or the student programmers of this project.

54

REFERENCE

Web Sites: Algorithms - Optimized Time table generator algorithm http://forum.java.sun.com/thread.jspa?threadID=636835 Algorithms - Optimized Time table generator http://72.5.124.111/thread.jspa?threadID=492946&start=15 Time Table Generation Scheme http://www.calorisplanitia.com/time-table-generation-scheme.aspx About the Computer-Aided Time-Table Generation (ResearchIndex) http://citeseer.ist.psu.edu/534837.html Specializing Narrowing for Timetable Generation: A Case Study www.springerlink.com/index/B5NGC0VQ6L4QW3Q8.pdf LET US WRITE IT OUT:HEAD FIRST JAVA www.ebookers.com/headfirsts/javaed3/chapter 7

Text Books: Java2: The Complete Reference

55

-Herb Schildt Java 2 platform Unleashed -Jamie Javorsky(SAMS Publications)