# [Help]Algorithm form room allocation..??

Hi, i'm going to make program for examination timetabling. I am confused, how to choose most suitable room for some exam. These are the rules for placing an exam to a room:
1. If total of students is bigger than the biggest room capability, then the class will be split. (ex. if the total of students is 120, but the biggest capacity of room is 40, then the exam will be split into three rooms)
2. One room can handle two (maximum, cant more than 2 exams) exams at the same time and day.

I am going to minimize the use of room and day. So the exam will be held densely (lets say, if the timetable made by human will product a timetable for 12 days, i want to minimize it to 10 days.. or 9 days...)

Anyone can help me?

Thank you very much

• : Hi, i'm going to make program for examination timetabling. I am
: confused, how to choose most suitable room for some exam. These are
: the rules for placing an exam to a room:
: 1. If total of students is bigger than the biggest room capability,
: then the class will be split. (ex. if the total of students is 120,
: but the biggest capacity of room is 40, then the exam will be split
: into three rooms)
: 2. One room can handle two (maximum, cant more than 2 exams) exams
: at the same time and day.
:
: I am going to minimize the use of room and day. So the exam will be
: held densely (lets say, if the timetable made by human will product
: a timetable for 12 days, i want to minimize it to 10 days.. or 9
: days...)
:
:
: Anyone can help me?
:
: Thank you very much
:

I actually not sure whether i should have answered this cause it was a while back, but just incase you still need answer, I can actually give you the code in Delphi if you need an example, but here it is explained what you need to do.

[u]Step 1[/u]
Lets say that for example sake you use structured variables {like in Delphi records} that look like this

Roomtype
RoomNR //primary key for record
Roomsize // size of the room, how many seats

Rostertype
Date // Date for exam
RoomNR // Which room for this date
ExamNR // Which exam for this room and date

Examtype
ExamNR // Primary key for the exams
StudentsAmount // Amount of students in this exam
Allocated // Boolean type, to chech later if the exam was allocated to
date and room or not...

For example sake lets say you have code to enter the information needed for the different rooms, exams into array's of the above structured variables created...

[u]Step 2[/u]
Now you must initialise the examType.Allocated to false to ensure no exam is allocated, as well as that the Rostertype is completely empty.

[u]Step 3[/u]
Now begins the fun part the big coding. You must now use While statements to get the job done infact there are going to be a few.
First you want to do the easy part allocate the first exam in the correct room, i'd say use the ExamType as the first while statements directive, then search each room for the best size , test whether the room is occupied with the by test the space left. AFter this allocate the size to the date to show it has been allocated, then after this use a while statement to test the dates to see if on the same date the same room has more than 2 exams if so then minus the current exams students from the date room allocation.

In a nutshell that is what you need to do, if you need more detail if be happy to forward you some code unfortunately i only know Delphi fluently to ensure the code will work i know C++ but not that good, contact me for further information.

simon@ld.co.za