 Hi, I'm Jeffrey de Smit and I'm going to show you how to optimize a school timetable to create a better schedule for teachers and students alike. I'm going to use our open-source software for this called OptaPlanar and let's take a look what it does. So here we have a number of lessons, math, chemistry, French and history and we do assign those to a time slot, A30 or 930 and to a room, room A or room B. Now there's a number of constraints. For example math and chemistry are actually attended by the same students and chemistry and French are taught by the same teacher. So we give all of these data to OptaPlanar and it's going to find a solution for us where it makes sure that all of these constraints are fulfilled. So as you can see in the solution, for example, Marie Curie is first teaching French in room B and then chemistry in room A but not at the same time. On top of this we will also add soft constraints. So for example to give the teachers a compact schedule. So they don't get two lessons that are with a big gap between them. This is the OptaPlanar Quick Start application for school time tabling. So what you can see here is we have a number of rooms, A, B and C here, number of time slots from Monday morning till Monday evening and Tuesday morning till Tuesday evening. And then we have a number of lessons here at the bottom that we need to assign such as biology, chemistry, geography and so forth. Now you can see we already have Matt assigned to 9 o'clock, 8.30 and to room A here. So let's see what happens if we solve this. We can still move this one. So let's see if we start solving this. So here's OptaPlanar comes with a solution and as we give it a bit more time, it actually comes with multiple schedules and the schedules actually improve the quality of the schedules. You can see that here on the score on the top. Now we actually have a score of 0 hard and 10 soft. So what does that mean? Well, 0 hard means there's no hard constraints broken. So for example, if you look over here, there's only one lesson per room at a certain time slot. It's never putting two lessons in the same room at the same time. If you look at the student group, what you see is every student group, the ninth grade here for example, only has one lesson at the same time. No student group ever has two lessons at the same time. And of course, for the teachers, we do see the same thing, right? Every teacher can teach all of its lessons and they don't have to be at two places at the same time. And when that is the case, then we have zero hard constraints broken, right? Now there's also 10 soft constraints. That's actually a positive number. And that tells us that 10 times it was able to compact the schedule for the teachers. And we can see the effects of this right here. So for example, Darren has two lessons, but those lessons are actually back to back, which is ideal for him, because he only has to come to the school once and actually just, and he doesn't have any gap hours in between. Same we see for Marie Curie, five lessons in a row. That's just ideal for her. And we see for the other teachers, mostly a compact schedule, but we have one exception here. Indiana Jones does have two lessons with a gap between them. And of course, the same goes for Penelope Cruz over here. Now that's because of all of the other constraints, of the hard constraints, which I explained earlier, but also may potentially some of the soft constraints, right? So how is this implemented behind the scenes? Well, behind the scenes, this uses a Java class model, right? And so we have a time slot where we have a day of week, like Monday, Tuesday, Wednesday, a start time in an end time. Then we have a room, right? And then of course, we have a lesson. A lesson has a subject, a teacher and a student group. A subject could be Matt, a teacher could be Marie Curie. And of course, a student group would be ninth or tenth grade or something like that. And then of course, these are assigned to a slime slot and a room. So Java-wise, these are pretty simple Java beans, you know, get or set as potentially if you want those and that's about it. And then of course, there's the constraints. So let's take a look at the constraints, right? So constraint-wise, there's a timetable constraint provider. And what this thing does is it actually enumerates the constraints I've shown you earlier. So one of them is for example, the room conflict. That's a hard constraint that says when you have a pair of two different lessons that are in the same time slot in the same room, then we want to penalize that with a hard weight where we basically say this should never, ever, ever happen. Otherwise, the scheduling is not feasible. And in a similar way, we have the teacher conflict and the student group conflict to make sure that none of these have to be in two places at the same time. So let's see what happens if we disable some of these constraints. So let's disable the teacher conflict constraint and the student group conflict constraint. And of course, the soft constraints here too. I'll explain in a minute what they do. And then let's go back to the implementation and let's reload that. And this is using Quarkus so I can just refresh and actually and restart the application in just a half of a second or so. So I'll click solve again. And now it's going to solve with those new constraints. So on the first side, everything looks fine because all of the, there's no two lessons in the same room at the same time. But actually look at per teacher, you'll see that in some cases, well, this turns out fine. That's by accident. If you look at my student group, you can clearly see there's some issues here, right? So Monday, 8.30 time slot, we have two lessons for the ninth grade at the same time. We're asking these students to be in two places at the same time. So that's not good. So we can go back here. We can actually enable that constraint again for the student groups. And when we then go back to the application, we refresh it again. Here we go. We solve it again. And what actually happens now is it's good for the rooms. It's good for the student groups, as you can see. But let's see how it turns out for the teachers. We didn't have that constraint this time. It actually violated that because it didn't know it existed. So we actually have the case where we are asking the teacher to be at two places at the same time. Similarly, we can fix it again, too, right? So we can enable this one again. So what are these other soft constraints here? Well, the first, the one I talked about earlier, was the teacher time efficiency constraint. That's to compact the schedule to make sure that teachers can teach back to back, basically, and they don't have to come in in the morning for an hour, and then in the afternoon and lose a lot of time traveling back and forth to the school. There's another one. There's a teacher room stability constraint, which makes sure that the teacher is always teaching in the same room. So he can actually decorate that room specifically for his class. For example, you can imagine if you're a math teacher, you would like to hang up maybe some posters to teach you about math, right? And then there's a student group, the subject variety constraint, which just makes sure that students don't get two lessons of maths in a row, or two lessons of French in a row, or two lessons of anything in a row, right? Why? So they can really, students typically prefer to have some variety in their subjects on a particular morning or afternoon, right? Let's enable that one too, okay? And then, of course, if we go back, we go back, we get back the original schedule. Now you can see by some coding, you can actually add your own constraints. For example, you have certain teachers who don't like to teach in the morning. You can easily add a constraint for that, don't give them morning lessons. Others like to prefer to teach in the afternoon, or in the beginning of the week, it's all possible. And the sky is the limit with these constraints, right? Now, you can see here, it's again solved. And just to show you about the teacher, the students groups, their variety, you can see, well, there's one violation here. They have two times English in a row, but most of the time, you'll see that now here, two maths in a row. But most of the time, you'll see that they do have a good variety. They're not doing two lessons of the same thing in a row, right? So, and of course, if you think this shouldn't really shouldn't be happening, you can just increase the weight on that constraint, make it more important than the other ones. For example, in a teacher compactness constraint, and then you'll get less of those incidents happening, but potentially more teachers having a non-compact schedule, of course, there's trade-offs. You can't have it all, but you can do a much better schedule than what you do right now in a manual way, or with less sophisticated algorithms, right? And so you can create a win-win situation for both the students and the teachers. So, if you want more, if you want to try out, if you want to run this code yourself, go to optoplanner.org. And what you can do is you can, there's a link here to the clone to the Quick Starts code, right? And you can actually just grab the Quick Starts code for there, or you can actually download the Quick Starts directly with the green button. Thanks for watching.