IDs are generated internally and automatically. If the classroom has computers, it is expected that there is a computer for each seat. The Room class has an ID and the name of the classroom, as well as the number of seats and information about equipment (computers). It also contains a list of classes that the group attends. The StudentsGroup class has an ID and the name of the student group, as well as the number of students (size of group). It also contains a list of classes that a professor teaches. The Professor class has an ID and the name of the professor. Let's start by explaining the objects which makes a class schedule. In this example, only hard requirements are implemented. Hard and soft requirements, of course, depend on the situation. Distribution (in time or space) of classes for student groups or professors.Some soft requirements (can be broken, but the schedule is still feasible): To place a class in a classroom, the classroom must have laboratory equipment (computers, in our case) if the class requires it.A classroom must have enough seats to accommodate all students.No professor or student group can have more then one class at a time.A class can be placed only in a spare classroom.Hard requirements (if you break one of these, then the schedule is infeasible): These requirements can be divided into several groups by their importance. When you make a class schedule, you must take into consideration many requirements (number of professors, students, classes and classrooms, size of classroom, laboratory equipment in classroom, and many others). In this article, I assume that you are familiar with the basic concepts of genetic algorithms, and I won't describe them in detail because it has been done so many times before.
![league schedule generator algorithm league schedule generator algorithm](https://scx1.b-cdn.net/csz/news/800a/2021/a-q-learning-algorithm.jpg)
This is where genetic algorithms come in to the game. For more complex inputs and requirements, finding a considerably good solution can take a while, or it may be impossible. The problem can be solved using a heuristic search algorithm to find the optimal solution, but it only works for simple cases. We take the last two elements of this list (5 and 3) and we put them after 6 and 4.Making a class schedule is one of those NP hard problems. We remove 6 and 4 from the list of the first round (1, 6, 2, 5, 3 and 4 ) and we sep the resulting order, which results in 1, 2, 5 and 3. We take the last team of the previous round (team 4) and the last team (team 6), since the round is par we must put first 6 and then 4, the result is 6 vs 4. We have 6 teams, so we will generate 5 rounds with 3 matches each. We keep the process until every round is generated. We do this with every pair until we go through the entire list. Once we have this list, we put the eliminated teams at the beginning of it.īeginning from the end, we take two teams from this list and we put them at the front. Then we must remove the teams that were first in the previous round, keeping the same order. Last team of previous round = 3 if the round was 6 vs 5, 1 vs 4 and 2 vs 3 Note: last team = 6 if there are 6 teams.
![league schedule generator algorithm league schedule generator algorithm](https://d3i71xaburhd42.cloudfront.net/982ee1b8a92511b49821da36a60721d9d481cf2e/5-Table1-1.png)
On the contrary, if it’s even, the last team goes first and then we put the last team of the previous round. If the round we are generating is even (First one is 1, so it is always odd) we must take the first team of the previous round and then the last team.
![league schedule generator algorithm league schedule generator algorithm](https://i.ytimg.com/vi/ZZDf2JKvtOw/maxresdefault.jpg)
![league schedule generator algorithm league schedule generator algorithm](http://golfsoftware.com/images/golf-pairings-generator.jpg)
To generate the following rounds, we must take the last element of the previous one (the last team of the first round order) and the last team (team number 6 if there are 6 teams) and we arrange them in the following way: Once we have all the teams we must arrange them in the following way: In case it is odd, an additional team needs to be created which will be used as a “free day”, the team that has a match against it will not play in that round. The first thing we must do is to see if the amount of teams is odd or even. It’s a classic tournament or league scenario. It is also required that each team will only play one single match in each of the defined rounds. We wish to create a fixture in which every team will face every other team one single time.