 Hi, welcome to another OPTA planner example. This time we're going to look at exam time tabling and we're also going to look at how the user can change the scoring parameters to focus on the things in the plan he finds or she finds most important. So let's take a look at the example first. In the exam time tabling problem we are going to schedule exams into periods and into rooms. So the exams in this in this application are the colored buttons. So for example over here we have one exam the exam with ID 254 and here we have another exam the other exam and then the Brown exam and so forth. And we are going to schedule these in two periods. So for example we're going to schedule them on the 15th of April at 9 30 or and or maybe in the afternoon and 15 of April on 14 o'clock or maybe another day and so forth. And as you can see we have a number of periods which we can select from. And then also we're going to schedule them in rooms which are on the top here. So we have seven rooms room zero to room six and of course each room has a capacity which you can see here. So for example this room is the largest room room zero which has a capacity of 260 students and other rooms for example this one only has a capacity of 100 and so forth. And the rectangle here shows the capacity so the more wide space in the rectangle the higher the capacity of this room. Similarly each of the periods has a certain duration in this case they're all the same they all have a duration of 210. But each of the exams also have a duration as you can see. So for example and this in the purple exam it has a duration of 120 so you can see that the oval is the circle is filled up to over half. And of course we need to make sure that each exam if an exam takes 120 minutes that the period has at least 120 minutes. Now because of it and because in this data set they all have 210 minutes all the periods we won't have any problems with that. Now the second thing we need to worry about is of course that the student size doesn't is not bigger than the number of seats in that room. So for example this exam requires let's take a look 49 students so 49 seats and the room has 260 which is fine but there's another exam in the same room at the same time which also which requires 211 seats so we have to take the sum of those two which is 260 if I'm not mistaken and which just fits into that room perfectly so that's fine and we're not going over capacity. As you can see in all the other examples we make sure that the sum of the exams the students or the number of students of the exams is less than the capacity of that room right. So yeah and we can schedule multiple exams in the same room so sometimes you schedule only one exam like here in the room at that time sometimes you schedule two like in this case but sometimes you can actually schedule far more so like in this case we're scheduling a lot of exams about six at the same time in the same room. You can also see that most of them are actually small sometimes even just a few students a handful of students sometimes even just five students that's fine as long as there's not seats in the room that's okay. Okay now what do we want to optimize we want to optimize the number of things so of course like I've just told you we had a number of heart constraints where the capacity and so forth there are a couple more some exams need to be scheduled at the same time as another exam sometimes an exam should not be scheduled at the same time as another exam and sometimes one exam needs to scheduled before another exam happens so for example if you have a math exam in theory and one in practice the theory math exam should be scheduled before the practice math exam for example that could happen so we can configure all those heart constraints and of course opto planner takes those into account right and actually the example of the planner example here take those into account right. Okay now there's also a number of soft constraints and one of the soft constraints is that we should not have mixed duration so what's a mixed duration well here for example in this case we have a mixed duration the purple exam takes 120 minutes but the brown exam takes 180 minutes so that means that after about two hours into the exam almost a lot of students in the room will basically stand up and leave the room this is very disruptive for the other students which are taking the orange the brown exam and because everybody's leaving the room at some point right and to avoid this we don't want to have this situation we really want to have a situation where if multiple exams are in the same room at the same time that they at least take the the same amount of time so for example in this case we already have this the yellow and the purple exam they take the same amount of time so there's no problem there but this is actually a problem and if you actually go looking we look at the constraints matches so an explanation is why we have a certain score and currently you have to score of minus 6500 this will explain us how good or bad this this this plan is right so if we look into this one of the constraints is about mixed durations there are a few others which I haven't explained yet and we see that it's there are actually 65 occurrences of those and for a total of we lose about 650 points on that and one of them is this first one so I believe probably this one will be the first one I know it's not there no not ordered by period but anyway it's definitely in here okay now there are a number of other constraints right let's take a look what the other constraints are a room penalty certain room should not be used at a certain time if you do use them we're going to lose points on them apparently we use quite a lot of points on a few of those up to 1450 points another one is period spread where we really want to spread the exams as much as possible so that the student which is doing multiple exams so some exam share students right so for example the purple exam might share students with the with with this brown exam and so forth if they share students then these exams should be as far as part as possible of course but of course one student will have up to 20 30 exams and in one exam period so there's there's a limit and then we mean we want to spread them as evenly as possible but we don't want to have a case where a student has two exams really short up to each other and when they're really short after each other then two exams are actually in a row and that's even a lot worse because if we have that we lose a lot of points just for having one instance of this so two exams on the same day in a row that's just a killer for some of the students and we don't want to have that and there's number of other constraints yeah like I said room penalty and of course front load so what's front load well the teachers they have to have the time to grade the exams and that's why they want to have most the exams with the most students in the front of the schedule so that a lot of the exams are already done by half of the schedule so they have time to correct those exams and to grade those exams that's why we want to have the ones and we actually see those in here the ones with with a lot of students or those with a lot of gray in the rectangle we want to have them at the beginning so this is good this is one is in the beginning which will actually in this case you'll find some and the end here as you can see right okay now let's see what happens if we optimize this with planner because this is an initial solution you'll see that if you give it some time the score will improve and you will see that some of the exams are are being moved as a result of that so this gives us a better schedule where students are happier because the exams are more spread more evenly and also the teachers are happier because they the exams which take a lot of grade where a lot of students are participating in are earlier in the schedule now as a user you might say okay but I still have a lot of soft constraints broken here and that will never get to zero so there might be point when you say I have to make choices I have to make a choice between the welfare of the students and the welfare of the teacher and depending on the institution you might and of course the realistic constraints of the teachers and the students there you might want to plan this differently than the default settings right because by default all of these constraints have some weight against each other and you might say this constraint or that constraint is more important to me than the others let's take a look at what happens if we do that so I'm going to stop this for a minute right and notice that we still have this mixed duration over here right let's suppose I really really want to get rid of those mixed duration let's suppose I'm happy to lose to have some exams which are big at the end for that or to have some students have some more exams in the same period as long as we don't have these mixed duration because that's just really really disruptive for the students so let's take a look at the scoring parameters these are the scoring parameters this means that every time we have two exams in a row we will lose seven points per student even if I recall correctly and then two exams in the end of the day so every time a student has two exams on the same day we lose five points per student and then the number of other things like the period spread penalty so the period spread length means that we want to have five days of between two exams and this period penalty is very low as you can see just one if that happens we're going to lose that one point so we're really really going to avoid two exams in the same day but two exams for example in three or four days will only just cost us one point so that's that's relatively okay now here you can see the exams of mixed duration penalty right so if you have direct mixed duration on 10 then then we lose quite a few points 10 but it's apparently not that much because we still have instances of that right so let's let's be unreasonable and let's hide that a little bit to 1000 let's take a look at the score also here at the bottom what will happen there you will see that the score immediately blows up because to 64000 the reason for that is of course these mixed durations we have 59 of them and they are costing us a lot of points right now because it costs a thousand points and not ten points per instance now if we optimize now you will see that as it starts optimizing that's opto planner will take a look at those mixed durations and will definitely break those so here we have one you can see that the score is going down he's he's definitely fixing mixed durations he should be fixing this one soon too you can see here a couple no those are not mixed durations and let's give it some time but you can see he's basically throwing out all the mixed durations now okay now so this one is gone too and he's of course by moving those mixed durations he's probably violating a few of the other soft constraints but as we said we find it as a use of far more important to have no mixed durations right so this is night this is one nice thing you can do if you're implementing a project with opto planner is that you can allow your users to change the scoring parameters so you might have a multi-tenancy setup where you say okay we have one for this school set up and we use the same application for another and same application for another school for multiple schools now each school can is basically a tenant in your system but you can say that per school they can decide what they find more important so you can basically save per tenant what are the scoring parameters which of the rules should apply and how much they they should wait so you can actually use the scoring parameters to disable rules so for example let's say I don't care about uh mixed durations I can do that too so I can do for example you can set the mixed durations to zero all right and then when you solve this you will see that it will likely introduce uh mixed durations because in trying to solve the other soft constraints it's as you can see here introducing lots and lots of mixed durations okay so I hope you find found this interesting and if you want to know more about opto planner just go to opto planner dot org website so opto planner is a lightweight embeddable planning engine for java and you can use it in in in swing application like this but of course you can use it in web application too or any other plain old java application really this is just one of the examples which uses java swing to show the example so thanks for watching bye