[MUSIC] In history, discrete event simulations have been used a lot to solve some complicated optimization problems. They have a real interest here. And because they are low to simulate systems that are not directly accessible through mathematics, like I don't know. And to show you how we could use descriptive [INAUDIBLE] system to optimize some problem, I will introduce virtual post office, and we will see first how we can describe how this post office works, using the descriptive and simulation framework. And then, how could we solve some simple optimization question about it. So imagine that we have a post office with n windows. And each window, indexed by i, wi, has a state which can be closed, open, or busy. And each window has a daily schedule that is established in advance for example, by the post office manager. And the schedule tells when which window is open and when. For instance, the post office is not open at 8:30, so before this time all the windows are closed, of course. And when it opens, it opens the window W1 and W2. One hour later, it close the window W2. One hour later it close the first window, open the second. And at 11:30, it opens all three window at the same time and so on. And instead, daily schedule is repeated every day and the manager has to establish it, to minimize the number of waiting customers and to be sure that the number of every employee does exactly the number of hours is paid for. No more, no less. On the other end we have customer coming in the post office. And let's say that every customer, here indexed by j, has arrived with a different request. I don't know, sending the boxes names and so on. And every request takes an amount of time to be processed by the window teller. So for example, this time will be noted by pj. So for a given simulation we can know in advance the arrival time and the processing duration of each customer. For example, that can be a table to say okay, so there's the first guy coming in the post office at 8:30, and what he will ask will take five minutes. Another one will arrive ten seconds later and its request will take two minutes, and so on. And we can continue like that to have a list for all the day. This list can be established in advance. For example, before the simulation starts. By, I don't know, for example, having people inside apostrophes for one week and counting every customer, at what time he goes in, how much time you will stay at the window, and so on. And so we can have a pretty good idea of the flux of customer, and the load that they will exert on the post office system. The customer in this post office, when they come they may wait in line, in queue. So when a customer j arrives, the first thing that he does is to look for an open window. If there is an open window, you will go there. The window will be as busy for Pj second. For an amount of time Pj. If there's no window which is open, either because they are closed or they are busy, the customer will wait in the first in, first out queue. And as soon as a window become open either because the customer they're finished and it is goes from busy to open or because the window opens in the schedule so it goes from closed to open. The first customer in the queue of course will go there. So that's a really simple post office, almost everybody is familiar with that but if you try to find an equation that can describe the function of this post office is really, really, really difficult. On the other hand, it's easy to describe it with discrete events framework. That's what we'll be doing soon. But before, some optimization questions. So first, question that we could ask about the system, for example, is how to organize the schedule to minimize the waiting line length. For example, usually there are most customers around the lunch time than in the middle of the morning. So it's more interesting to have all the windows open at that time. But to have the more interesting schedule, we can try too much to produce record of customer arriving, and try to find the best schedule that can minimize the wait time. We could also define a waiting threshold, which is acceptable, for example, waiting ten minutes is acceptable, and so then we can try to close windows as much as possible to be sure that the waiting time cannot be over this threshold. So for example in that case, in the phrasing of a transition problem, the maximum time that the customer will wait is a constraint, and the objective function is to reduce the amount of open time of the windows. And then we can also ask other question about organization for example some questionnaire that are just have really simple request we will like for example they want to buy a I don't know to buy some packages or to just send one. And in that case we could have a queue for late requests. So we could compare several ways of organizing the post office. And then we can have, for example, as a optimization objective function the amount of time waiting, or a mutual objective function and so on. So we could ask a lot of questions, if we could simulate such system, and as I said before it's really difficult to do it with an inequality equation with OD, but it's quite simple in that case do it with discrete events. How? We need to first to define the what elements of the state, what company of the state we are interested in tracking. And in that case we can really simply define the system, for example by tracking the state of the windows with our vector W which has as many elements as the number of windows, and every element will point to the states open, closed, or busy. And then a FIFO queue of waiting customers. And each customer can be represented simply by his processing duration time. The amount of time that would be needed to process his request at the post office. So simply by having a FIFO queue which contains numbers, the amount of time that will be needed. And then we can really easily define events. So we have three events related to windows like the opening of the window, processing some client, and closing. And we can also have event using arrival of new customer in the post office. And of course all this event will have actions, like said before. For example the open event will make a state transition for our window from close to open. And process, we make a transition from open to busy and so on. The arrival action of an arriving customer is a bit more complicated because we are first to check if some of the windows are open or not, and then eventually go into the queue. But it's really interesting to simulate, there are lots of variation, I will not fully specify the model because I have more interesting example to show you. But what is interesting here is to understand that the exogenous events usually we'll fully determine the how the system will behave in regard to what you are really measuring about. Usually, we'll needed to measure some quantity, some objective functions that went to minimize and not only the variable that you want to optimize will have a role but also the exogenous event. So it's really important that they really reflect in that case the load of the post office, and if we can obtain them empirically, that's great, but most of the time we just have statistics, with average, and mean, some distribution function. We have some ins that behave like a person process for example. We have to generate them at the beginning. And since to optimize our problem, we may use exogenous events generated empirically, generated at random. We will need to make several runs to approximate the objective function that we really want to simulate. That is really close to Monte Carlo method that you have seen in preceding lecture. Finally it's really interesting to say that's the discrete event simulation framework that to when we are interested in optimizing a system. Just a way of computing an objective function which satisfies some constraint. Which usually is coupled with another system. Optimization can be a greedy system, simulated animating genetic algorithms. Since the generic, the system are really fast to compute. We could have several runs in just a few seconds and allowed to explore a large space of parameters. In the next module I will show you, shortly present you some really basic concept about implementation and show you how you can easily define a variety on discrete event system code. [MUSIC]