Lecture 03-How to Build Simulation Models?

IIT Kanpur July 201
20 followers
1 Video View·Dec 3, 2023
types of system, study of system, classification of simulation models, discrete event simulation, time keeping mechanisms, next event time advance.
Today, we are in the new topic, actually the continuation of what we were having yesterday's
lecture about the simulation of business system and how can we use simulation to study business
system.
You might have already seen that we have worked on multiple topics about the simulation and
introducing to you the language of simulation, various concepts of it and today we will further
go deeper into the topic and so that you can understand the individual modules of simulation
systems and how can you use such modules to build a simulation model of a business system.
So, if you look at the learning agenda, you have already seen that we have studied the
nature of simulation in the previous lecture in the brief history.
These things were covered in the first lecture, then systems models and simulation, the applications
of it, real world applications and why simulation is needed, the advantages, disadvantages,
this all we covered in the second lecture.
Now, today we will focus more towards how to build simulation models, that kind of a
question we will try to identify and the examples we will work on the next class to actually
demonstrate how an actual simulation works by hand and why it is intractable to do large
simulations using hand, you require a computer to do that.
So, first we will get into the concept of type of system or types of system and there
is in for the people classify again, this is different, please remember this, this is
different from the systems engineering approach, systems engineering approach.
So, we are talking about business systems here and business systems generally we are
trying to create into what we call as a using simulation to study the system.
So, for us there are mainly two types of systems.
The first one is the discrete system and the second one is the continuous system, okay.
So, what is a discrete system?
Discrete system is a system where system state variables, system state variables change
instantaneously, please check my spelling, I am not very sure about my spelling, instantaneously
at separated points in time, so the, remember we studied what is a system state variables
remember, these variables what are they, they describe the state of the system, state of
the system at any given time, given time, that is a system state variable.
So, these state variables, they change instantaneously at an instant, they change like this quickly
at separated points in time, okay.
We will give an example is a bank teller operation, okay.
So, remember we looked into some of the system state variables and if we use one of the system
state variables is number of people in the system, in the system, okay, this is equal
to number of people waiting in queue plus number being served by the teller.
So, you imagine a bank teller, here is a bank teller and people are waiting in a queue in
front of the bank teller, these are all individuals, okay, waiting in a queue and there is one
person being served, okay, or maybe two people being served, it does not matter.
So, then the total number of people in the system is the people who are waiting in the
queue, this one and the people who are being served, some of them.
So, if you plot that in a graph on a time scale t, at initially when the time t equal
to 0 and if you say here as the number of people as the y-axis, initially the value
will continue to 0 for some time and at a particular point, when one person arrives,
this number will go to 1, area 1, 2, 3, 4, 5, 6 like this and then it will continue and
then one person more arrives, it goes to 2, continues and at some point of time, this
first person service gets done, so it goes down to 1 and then it continues like this
for some time and then maybe another arrival happens, then it goes to 2, then it goes to
2 and then remains for some time, then another arrival happens, goes to 3, then it comes
down to 2, then it comes down to 1, then it continues like this, okay.
Now, this depends upon, this changes when a person arrives or leaves the system, so
these are all, all these things that you see, they are instantaneous changes, only at a
particular instant, the system changes and then it continues in the state for some time,
then it changes again, so such type of systems are called as discrete systems for the purpose
of simulation. So, then and what would be a continuous system? Continuous system will
be something where system state variables, variables change continuously, are a function
of time. One of the examples of this would be flight of an aircraft, flight of an aircraft,
so if you think about it, if you think this is being the runway, okay and then it is an
aircraft standing here, this is wing, it is ready to fly and this is the runway and then
it flies, then from here it takes off and it flies to some level, then it again flies
to some level and continues and then it descends to some level, continues and then descends
and then here is another airport, where it finally comes and lands, okay.
So, if you think about it in, ask that and here is time, okay, continues, so at every
instance of time, the aircraft is doing something, things are changing, it is not instantaneous,
even if it is gaining altitude, once it takes off, let us say this is the takeoff point,
okay, from here, let us say this is, let us say, first ceiling or something like that,
okay, let us say 20,000 feet or something, the aircraft does not go from 0 feet to 20,000 feet
in like instantaneously, it takes time to climb, okay, so this is the continuous variation.
Similarly, then it might continue in 20,000 feet for some time, then it will go to maybe
32,000 feet, okay, so this will be the second set of climb, then this would be probably,
it will stay in its cruise altitude, okay and then from here, it may come down to the
one altitude, let us say, 10,000 feet, okay and then stays in this, then maybe come down
to the 5,000 feet, okay and then it comes and lands, something like this, so all these
changes, okay, you can see that these are not instantaneous, but a function of time,
all these changes, okay, these changes, these changes, they are all functions of time.
So, such kind of a system where the system state variables change continuously as a function of
time and this is important because this kind of systems are also simulated, for example,
autopilot simulations, okay, they include studying such kind of continuous systems,
the only difference is that mostly in this course, we will be focusing more towards
discrete like systems, because we are more interested in discrete systems rather than
continuous systems, we will only look at few examples of continuous systems in the class
and in realistically, many systems are partially discrete and partially continuous.
So, for example, is time continuous or discrete, okay, so this is an interesting question because
time by rule is continuous, okay, you can say theoretically, time is continuous,
but the watch that you wear, you can only measure the time in seconds, so most watches allow
time measurements in hour, minute and seconds, not the other values, why? Because for easy usage,
time has been discretized, so discretization allows us to study the system quickly, okay,
so that is why we actually discretize time, so if you look at your watch, you will see that the
seconds clock tick, tick, tick and that tick is by the seconds, okay, that is what happens.
So, I hope you will now understand the concept of what is called as a discrete system
and what is a continuous system and as I said earlier, we are going to focus more towards the
discrete system, okay, so now, the second question is, the next biggest question is,
how do we study a system? What are the ways in front of us to study a system?
Again, as I want to remind you guys, here we are focused on system simulation,
not systems engineering, okay, so we are going to study, how are we are trying to find out how
we are going to study a system, so let us assume that this is a system that we want to study,
a system, so we want to study this system, let us assume that we want to study this particular
system denoted by, there are 2 ways we can do it ideally, okay, so there are 2 ways.
The first option is to, we make a big rectangle, experiment with the actual system,
second option is experiment with a model of the system, so assume that you have a
car manufacturing facility, let us say, for example, automotive manufacturing, let us say,
we are interested in manufacturing of cars, 4 wheelers, so one way to do it is, actually do
the experiment with actual factory, this means, do experiment with actual factory, okay, this
sounds good and this is probably the best way to do the experiment, but this is on inherent
disadvantages, what are those inherent disadvantages? Number 1, too expensive,
nobody will give you a factory to play around with, okay, second one is, anything goes wrong,
too risky and the third one is, adversely impact productivity, impact production, the job of a
factory is to produce cars, this car manufacturing factory, the aim is to produce cars, not to allow
you to conduct experiments with the system, so because of this expense and the riskiness
and the adverse impact on the production, this approach, okay, is not preferred in industry,
well, if you want to try a weapon, then as you do how to make a weapon and then drop the weapon
and find out how the weapon is, but if you want to study about a factory, it is almost impossible
for you to expect that the factory will come to you, somebody will give you the factory to do
the experiment, so the second option is experiment with a model of the system,
so here also we have 2 options, ideally speaking, the way to do this is, first is to build a
physical model, physical model is like a model of the system which has, how do you put it,
the like for example, if you are building a car, okay, so some people will say, okay,
take clay, like if I draw something like this, it does not look like a car much,
but if you see something like this and then put 4 wheels on it, then you will say, oh,
this looks like a car, so I can actually make a physical system of this also, I can make it
in using the actual materials and build a physical model of it, other option is,
I can build a mathematical model of it, build a mathematical model, so I want to,
I can say that the mass of the car is equal to 1000 kilograms and I want to accelerate it at
2 meter per second or something like this, then I can find out the how much of force is required
using the mass into acceleration and something like that, so then this mathematical model will
be applicable to car, jeep, motorcycle, bus, whatever it is, so these kind of systems is
called as a mathematical model, so you mathematically represent the system, okay.
Then in the mathematical model again, you have 2 options, okay, so I am kind of drawing it little
far away, the first option is to build an analytical solution, okay and other option is
using the simulation, okay, so using an analytical solution is by you know,
non-methods of mathematics, okay, so an example of this would be, one way to think about it is,
what would be the best example to do, okay, here, so let me give you a simple example,
you want to that is a, here is a gun with a howitzer and here is a target, okay and you
want to find the angle theta at which you need to fire, so that it will come and hit the target,
okay, so if you know the force which the projectile comes out, then you need to find out
is known, if you know that, then you know what is this distance, okay and then using this,
you can find out at what angle you need to fire, so that the projectile will reach this
particular distance, so that you can hit the target, so you can solve for the theta, you know
and then you are able to identify, okay, it is you fire at 38 degrees, then you will be able
to hit this target or something like this, okay, this is the analytical approach.
In a simulation, it would be a numerical approach, so what you could do, think about it is,
you can say that, okay, here is the gun and here is the barrel, okay, then you can say,
here is a theta and then you will say, I will start with theta equal to 10 degrees,
okay and then find what is the distance, so let us say, let us assume that this distance equal to
20 kilometers, okay and then you find out that it reaches 17 kilometers, okay,
then theta equal to 20 degrees, you find out that it reached
18 kilometers and there is a theta equal to, I am just giving you an example,
30 degrees, it reached 19.2 kilometers and theta equal to 40 degrees, then it reached
20.4 kilometers, so now you know that the desired angle is somewhere between 30 and 40,
okay and then now you can basically figure out, okay, it is 40, 20 is close to this,
so I might start reducing from 40, so I might do now 39, then I do 38 like this, okay,
so this is one way of numerically studying the system, you are trying to simulate the
behavior of the system for different range, different thetas and then find out which one
would actually work for it. It is kind of same way, what you actually do is,
simulation is you provide scenario and measure the output and then once you have many such outputs,
then you find the average of output, okay and then you use these averages, I am just giving
you a broad example, but what you are looking at is, you are looking at the, you know,
what is something called as the expected value of the parameter, is what you are looking at,
at some point of time, you will see what is an expected value and all those aspects
little later down the road, but for the time being, let us, I hope this will give you a
rough idea of how the simulation and analytical model actually works, okay.
Now, from here, let us look into what we call as the classifications of the simulation model,
okay. Most of the simulation models that are built for the, for studies are classified into
multiple options. The first classification is static versus dynamic. So, static model means,
model implies the state of the system does not change as time progresses. So,
for all practical purposes, the system remains constant, there is no change in it.
So, an example of this will be a clay model of the car, okay, you built it and then once you
frozen the design, it just stays there, nothing is going to change. Dynamic model,
on the other hand, what happens is, the state of the system, the system changes over time or
as time progresses, system state changes. This change can be either instantaneous
or it can be continuous, okay, it does not matter. The important thing is, as time progresses,
the state of the system changes, that is the most important.
Second type of a classification is what we call as deterministic versus stochastic, okay. So,
a deterministic model means, deterministic model implies there are no uncertainties
associated with any state of the model, okay. How do I put it is that there are no probabilities.
You know that is what is going to happen and that is what it is. There is absolutely no probabilities
that are associated with it. So, the system is deterministic, okay. On the other hand,
stochastic model implies the state of the model, state of the system is not known with,
this is the most important thing, not known with certainty or it implies that every system state
has a probability. So, there is a probabilistic occurrence associated with every system state,
okay. Such kind of a system, such kind of a system that a model that makes such a system
is called stochastic model. So, there is one option is deterministic and stochastic.
Then the third one is continuous versus discrete. We have already discussed this. So, discrete
model implies state changes, state change of the system. If the system changes are,
which also means that is also applicable to the model, the state change of the system or the model
happens only at discrete time instances or in a way that or you can think about as the happenings
in the system, in the system are countable. Since it happens in discrete instances,
you can start counting it now, okay. Whereas continuous is the opposite of the same,
okay. State change happens continuously over time, which implies not countable,
okay. You are not able to count what is happening over time in the system.
So, hence for our course mostly, most of the operational models, most of the models that we
are going to study, this operational models in this case we are talking about is the business
systems, okay. Most of the business systems for which we build operational models are dynamic.
Dynamic means the state of the system changes over time. So, the system will change the,
we will say it as state of the system changes over time, right. Then this is also stochastic,
which means probabilistic. There is a probability component, probabilistic
behavior. So, the system occurrences, different aspects of the system or different states of the
system are not known for certainty, but the occurrences is associated with a particular
probability. Discrete means the system is countable, okay. Countable or countably finite
or infinite. So, it happens at the specific instances of time and those instances or
occurrences are countable as far as we are concerned, okay. So what? So, now in our case,
hence we actually study more on discrete event simulation model. The right phrase for this is
actually, what we are going to study is what we call as, I was just going to write it here,
a discrete event stochastic simulation model. That is what we will be focusing
more in the class, okay. Discrete event stochastic simulation model.
So, as we said earlier, the discrete event simulation. So, in our case, we are modeling
a system, okay. The system is studied as it evolves over time. So, the system evolves over
time. So, how do we do that? This is done by a representation, this is done by a representation
where the state variables, state variables change instantaneously, instantaneously
at separate, separate or separated points in time. So, what we are talking here is that
we are modeling the system, okay. We are modeling the system as it evolves over time.
And how do we are doing is, we are doing this by representing the state variables or the state
variable changes are represented instantaneously at separate points of time, okay. So, the things
happen as I drew the graph earlier, okay. As time progresses, the system state is drawn something
like this, okay. As time progresses, it will come down, then it goes up again, then it comes down,
stuff like this, okay. So, such kind of instantaneous changes at separate time interval.
So, if you say this is t equal to 0, this is t 1, t 2, t 3, t 4, t 5, etc. These are individual
separate time instances, okay. Or in a better way, simply put, we can say that simply and
specifically, okay, we can always say that state change, state change can occur only at a
countable number of points in time. So, we are modeling the system where
the state change can occur only at a countable number of points in time.
So, you can say how many events happened, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10. You can actually count,
you can say that here t 10. So, 10 events has happened. So, because of this countable
number of points in time, you can do this. And these time points, these time points are
when a particular event, it is a new word for you, event occurs, okay. So, what is an event?
An event is something like, if you talk about it, it is a particular happening that. So,
what is an event? We are going to talk about it. But remember, if we talked about the bank teller
example, people are waiting in a queue here, okay. Three people are waiting and here is the
bank teller, okay, sitting in a chair. And there is a computer right next to it.
And here is one person getting served. So, as of now, the number of people in the system is at a
value of 4. And let us say one more person came and joined the queue. Then at that instance,
that particular time instance, the system state changes. Because now the number of people in the
system becomes 1, 2, 3, 4 plus 1, 5. And from that time period onwards, until the next person
comes or the person leaves, the state of the system continues to be in the same place.
So, this kind of when the person joined the queue or when a person leaves this,
this is what we call as a particular event. So, let us define what is an event, okay.
An event is instantaneous occurrence, instantaneous occurrence that may change,
that may change the state of the system. So, what we are talking about here is an event is
an instantaneous occurrence that changes the state of the system. So, when I said a person arriving,
okay, a person joining the queue, okay, which in another way we can think about it as arriving
at bank, okay. This is one particular instance, that is an event, okay. This translates to an
event, okay, event 1. Another example of this is a person leaving the bank. This is another event,
okay, event 2, and the person can leave. Then another person leaving from the queue,
okay, a person leaving the queue, okay. This is E3, event 3 like this. So, there are multiple
events can happen and any of those events happening will change the state of the system,
okay. So, that is exactly what is called as a event. So, in another words, sometimes in simulation,
okay, specific events are created, created to make or to facilitate,
to make a decision or facilitate a decision about the system's operation, the system's
operation. So, sometimes other than the natural events that are happening, you might have to
create specific events, very specialized events. So, what are that kind of a specialized events?
An example of this will be start the simulation, okay, end of simulation, etc. So, these kinds of
specialized events that are created for you to run or facilitate the simulation model or
operation of the system is what, they are also events. They are not really, these are,
can also be not natural events related to the system, okay. So, hence some people also call
this as pseudo entities, okay. When somebody says pseudo entities, that means we are referring to
these kind of entities which are not really natural events related to the system, but is
created to facilitate a decision about the system's operation, whether the simulation need to be
started or simulation need to be ended, that kind of a thing. Also, the discrete event simulations
can be done by hand. There is no rule that you have to use a computer to do it,
but it is usually done by a computer. Why? Why do we usually do it with a computer?
The simple problem of a single server system, okay, becomes very complex to simulate by hand.
If you are going to do the simulation by hand, be prepared to be there for a long,
long time period, because these are not very easy to do, okay. So, hence we usually use a
computer to do it, but we will do a very small simulation in the class for you to make you
understand the various aspects of simulation. Now, with that, we will move into what we call as a,
the example of a discrete event simulation, which is important for us. Let us see what are the major
examples that we are going to take. So, as I mentioned earlier that a single server queue
or a single server system is a very simplistic system, but it is quite hard to simulate it with
hand. So, a single server system is something that you can imagine this way. Here is a server,
okay, S1, single server, only one person is there as a service, and the single server can,
you can think about it as, can serve one entity, okay. Now, the question is, what is an entity?
We already studied what is an entity. They are the items, things that flow through the
system. We already studied that. And there is a queue, okay, and the entities wait in the queue,
okay. These are entities. So, what happens in a single server system is that, you know,
an entity arrives, it is an entity arrival. When it arrives, if it sees that the server is free,
okay, the two questions is, is server free or is server busy? If the server is free,
then immediately go get served, okay. If the server is not free, then join the queue
and wait in the queue. And when your turn comes in, you will be pulled from the queue.
So, this is the call for service. So, this is one of the most, excuse me, simple systems that you
can see. So, what is one of the most important aspects of this? Why people study such systems?
The main thing is to estimate or you want to find out, you want to estimate or find out
expected average delay in queue or you want to find out how long one waits before getting served.
This is the big question that is to be answered as part of this. How long you should wait before
getting served? That is why you study a system like this. And what are some of the state variables
of this? The major state variables include, okay, one is the status of the server,
okay. There are two options in front of this. One is idle or what you call as free.
The other one is busy, servicing someone, okay. So, you need to know this during arrival,
because if free, then go and if busy, wait in queue to get called for. So, the server is free,
then you go and get served. If the server is busy, then wait in the queue to get.
So, this is important for you to know when an entity arrives into the system. So, this is one
of the state variables. Then other aspect is current length of the queue. You need to know
this because decides whether to wait in the queue or leave without being served.
Sometimes when you actually go to a place and see a very long queue there, then what people do is
that people sometimes say, oh, I am not going to be here, I will leave and I will come back later,
okay. So, such kind of a decision happens for that you need to know what is the length of the
queue. Then another state variable, these are not all the state variables. These are few examples
what we are talking about. Now, the third one is the time of arrival of each customer
into the queue, okay. This is required to decide when to start the service.
Also, it helps you to decide, identify how long the person was in the system.
If you want to find out how long the person or how long the entity, you need to think about person
as a entity, okay. How long the person or the entity was in the system is another aspect that
is related. So, these are few examples of the state variables of the system that tells you
how the state of the system or how the system state behaves, okay.
Similarly, about events. Events, some of the major events are arrival of a new customer.
So, when an event happens, event happens implies system state changes, okay. So, when a new customer
arrives, then the number of the people, number of the queue, everything goes up by one, okay.
Then, service completion or departure of a customer. So, when the service is completed
and a customer departures from the system, then that is also, it will reduce the number in the
system. So, here it will increase the number in the system. In this case, it will decrease
the number in the system, okay. Then, you can also have end of simulation events
or you can think about it as pseudo events. This is a, helps to make modeling decision.
So, if you say that I want the bank to simulate for 8 hours, if you say a study for 8 hours,
which is equal to 8 into 60, 480 minutes. So, you say that, okay, the clock keep on ticking.
And as soon as you click, reach the 480 minutes, stop the study, okay. Stop study. When this
happens, then you see the reports and other things. So, this is not a actual event, it is a
pseudo event, which allows you to do the, what we call as the modeling decision of the system.
Now, the other major thing that we also need to do is, how is this time being kept in the system,
okay. This is a important aspect of the system, because the time keeping mechanism is quite
significant for our work, okay. So, the first thing is what we call as a simulation clock,
okay. So, what is a simulation clock? It is simply a variable. It is a variable that keeps
keeps the current value, value of the simulated time of the model.
It is not the real time that we talk about. We are talking about the simulated time.
The time is a simulated time. You are not going, if you are going to study the system for 8 hours,
that means, that does not mean that you stand in front of the computer for 8 hours and
observe it. The simulated time is way, way, way faster than the actual 8 hours. That is the
reason why you use simulation, okay. So, this actually variable that keeps the current value
of the simulated time of the model. It, what it does is, the modeler must decide on and be
consistent, decide on and be consistent about the time unit. If you say that I am going to study
the system in minutes, then stick with minutes. Do not keep on changing things here and there,
okay. Ideally, there is no relationship between simulated time and actual time.
So, that means, this is necessary, necessary to run or simulate. When you use the word run,
it is also equivalent to simulate the model on a computer, okay. So, you are having what we call as
the, you know, simulation clock, a variable that keeps the current value of the time.
And the modeler must decide on initially and be consistent about the time unit.
And there is no relationship between the simulated time and the actual time. And you require this
because you want to literally run the model on a computer. And there are 2 approaches,
2 typical approaches are used for the advancing the time or to do the time advance of the simulated
time, okay. You are talking about the simulated time. How are we doing this? Okay, the first one
is the next event time advance, okay. You identify what is the next event that is going to happen
and then do the time advance. This is the most commonly used approach. This is one example.
Next one is the fixed increment, fixed increment time advance, okay. That means the clock will
advance by every 5 minutes and then the system states are measured at every 5th minute, okay.
This is seldom used, not very common, but this is typically used in sometimes in studying traffic
systems like traffic flows, etc., but not very commonly used, okay. The most commonly used one
is the next event time advance approach. So, with this what we will do today is that
we will stop today's, actually we will continue with one more slide and then we will stop after
this. This is the, we will talk about how the next event time advance work and then we will stop
today and then we will come back in the next class. So, what happens is how does the next
event time advance work? So, first what you do is you initialize a simulation clock.
You initialize it, initialize it to 0, okay. That is the first thing you need to do. Then,
so you start with the time t equal to 0. Then determine times of occurrence of future events,
okay. This is called building the event list, okay. So, you are here to build the event list.
So, you build the event list and from there you determine the times of occurrence of the future
events. Then what happens is clock advances. Where does a clock advances? To the next or the most
imminent event, okay, that is to be executed. So, you advance the time to the next or the most
imminent event to be executed and this involves updating the event list. So, what happens is
you remove it from the event list and then once it is executed, you remove from the event list and
then next one comes up in the higher in the order and then continue until, when how long will you
continue? Continue until stopping role is satisfied, role is satisfied and stopping role
should be explicitly stated, should be explicitly stated, okay. So, that is the continue until.
Then clock jumps from one time, one event time to another next event that which means the times
between the event, between the events do not exist, which means we are only in the period of
inactivity is ignored. So, implies if no event happens or no state change, time is skipped.
So, this is how the time gets managed in the simulation. So, hopefully this has now make
you understand that how the and when you do an example, a complete example, then you will
get a clean idea of how to do it and go from there. So, hopefully you guys understood the
more advanced or internal modules of the simulation and how the inner workings of it.
And in the next class, we will do an example so that the concepts becomes crystal clear to you.
Thank you for your patient listening and please read the textbook so that you can
be updated on to the concept. Thank you very much.
