Simulation of Continuous and Discrete System
Simulation of Continuous and Discrete System
• It can involve the derivatives of the same dependent variable with respect to
each of the independent variable.
• The simple differential equation can model the simplest continuous system and
they can have one or more linear differential equation with constant coefficients.
Differential Equation
• The quantity F(t) is an input to the system, depending upon the
independent variable t.
• A linear equation with constant coefficients is always of this form.
• A equation may be linear or non linear and of any order or may be
ordinary or partial.
Differential Equation
• The above equation describes the automobile wheel suspension
system is derived from mechanical principles.
• If we pick a point of the wheel as a reference point from which to
measure the vertical displacement of the wheel, the variable x can
represent the displacement of the point, taking x to be positive for
the upward movement.
• The velocity of the wheel, in the vertical direction, is the rate of
change of positions, which is the first differential .
• The acceleration of the wheel, in the vertical direction, is the rate of
change of the velocity, which is the second differential
Differential Equation
• The mechanical law that determines the relationship between applied force and
movement of a body states that the acceleration of the body is proportional to the force.
• The coefficient of proportionality between the force and acceleration is the mass of the
body; so in case of the automobile wheel, where the mass is M and the applied force is
KF(t), the equation of the motion in the absence of other force would be as follows:
• M = KF(t)
The shock observer exerts a resisting force that depends on the velocity of the wheel; the
force is zero when the wheel is at rest and it increases as the velocity rises.
• Different scale factors can be used on the circuits to represent coefficients of the model
equation.
• All voltages can be positive of negative to correspond to the sign of the variable
represented.
• To satisfy the equations of the model, it is sometimes necessary to use a sign inverter,
which is amplifier designed to cause the output to reverse the sign of the input
Analog Computers
• Accuracy of these computers is low as fluctuations in the voltage
level cannot be controlled beyond a limit.
• Secondly, a number of assumptions are made in deriving the
relationships for operational amplifiers, none of which is strictly true,
so, amplifiers do not solve the mathematical model with complete
accuracy.
• Methods have been developed which can maintain a very high degree of
accuracy.
Analog Computers
• A digital computer has the advantages of being easily used for many
different problems.
Scalar
Analog Methods
• The general method by which analog computers are applied and can
be demonstrated using the second order differential equation
• M +D+Kx = KF(t)
• More recently, few purely analog computers are built. Instead, computers with large numbers
of standard, non-linear elements are readily available
• Hybrid computers may be used to simulate systems that are mainly continuous, but do, in fact,
have some digital elements-for example, an artificial satellite for which both the continuous
equations of motion, and the digital control signals must be simulated.
• Hybrid computers are also useful when a system that can be adequately represented by an
analog computer model is the subject of a repetitive study.
Digital Analog Simulator
• To avoid the disadvantages of analog computers, many digital
computer programming language have been written to produce
digital-analog simulators.
• They allow or facilitate a continuous model to be programmed on a
digital computer in essentially the same way as it is solved on a analog
computer.
• The language contains micro instructions that carry the action of
addition, integration and sign changer.
Digital Analog Simulator
• A program is written to link together these micro-instructions, in
essentially the same manner as operational amplifiers are connected
in analog computers.
• More powerful techniques of applying digital computers to the
simulation of continuous system have been developed.
• As a result, digital-analog simulators are not now in extensive use.
Hybrid Simulation
• For most of studies the model is clearly either of a continuous or
discrete nature, and that is the determining factor in deciding whether
to use an analog or digital computer for system simulation.
• However, there are times when an analog and digital computers are
combined to provide a hybrid simulation.
• The form taken by hybrid simulation depends upon the application.
• One computer may simulating the system being studied, while the other
is providing a simulation of the environment in which the system is to
operate.
• It is also possible that the system being simulated is an interconnection
of continuous and discrete subsystem, which can best be modeled by an
analog and digital computer being linked together.
Hybrid Simulation
• The introduction of hybrid simulation required certain technological
developments for its exploitation.
• High speed converters are needed to transform signals from one form
of representation to the other.
• As a practical, the availability of mini-computers has made hybrid
simulation easier, by lowering costs and allowing computers to be
dedicated to an application.
Hybrid Simulation
• The term “hybrid simulation” is generally reserved for the use in
which functionality distinct analog and digital computers are linked
together for the purpose of simulation.
Feedback System
• A significant factor in the performance of many systems is that a
coupling occurs between the input and output of the system.
• The term feedback is used to describe the phenomenon.
• A home heating system controlled by a thermostat is a simple
example of a feedback system.
• The system has a furnace whose purpose is to heat a room and the
output of the system can be measured as root temperature.
• Depending upon whether the temperature is below or above the
thermostat setting, the furnace will be turned on or off, so that
information is being fed back from the output to the input.
• In this case, there are only two states, either the furnace is on or off
Feedback System
• An example of a feedback system in which there is a continuous
control is the aircraft system.
• Here the input is a desired heading and output is the actual heading.
• The gyroscope of the autopilot is able to detect the difference
between the two headings.
• A feedback is established by using the difference to operate the
control surface, since changes of heading will then affect the signal
being used to control the heading.
Discrete System Simulation
• In discrete system the changes in the system state are discontinuous.
• Each change in the state of the system is called an event.
• For example, the arrival or departure of a customer in a queue is an
event.
• That contrasts to continuous systems in which the state changes
smoothly with time.
• Simulation is the representation or imitation of a system by a
computer for the purpose of predicting the behavior of that system
under certain conditions.
Discrete System Simulation
• The model used in discrete system simulation has a set of numbers to
represent the state of the system.
• A number used to represent some aspect of the system state is called
a state descriptor.
• As the simulation proceeds , the state descriptors change value.
• We define a discrete event as a set of circumferences, that causes an
instantaneous change in one or more system state descriptors.
Discrete System Simulation
• Implicit in the definition is the assumption that the system change is
one that has been considered of sufficient importance to be
represented in the model.
• It addition, it is possible that two different events occur
simultaneously, or are modeled as being simultaneous , so that not all
changes of state descriptors occurring simultaneously necessarily
belong to a single event.
• The term simultaneously, of course, refers to the occurrence of the
changes in the system, and not to when the changes are made in the
model-in which, of necessity, the changes must be made sequentially.
Discrete System Simulation
• Discrete-event simulation is commonly used in research to study
large, complex systems which are not suitable for conventional
analytic approach.
• Some examples are the study of sea and network and telephone
exchange.
• Another use simulation is for tuning a design, an example is network
design.
Representation of time in Discrete Event
Simulation
• A system simulation must contain a number representing a time.
• The simulation proceeds by executing all the changes to the system
descriptors associated with each event, as the events occur, in
chronological order.
• The way in which events are selected for execution, particularly when
there are simultaneously events, is an important aspect of
programming simulations.
• The passage of time is recorded by a number referred to as clock time.
• It is usually set to zero at the beginning of a simulation and
subsequently indicates how many units of simulated time have passed
since the beginning of the simulation.
Representation of time in Discrete Event
Simulation
• Unless specifically stated otherwise, the term simulation time means the indicated
clock time and not the time that a computer has taken to carry out the simulation.
• As a rule, there is no direct connection between simulated time and time taken to
carry out the computations.
• The controlling factor in determining the computation time is the number of events
that occur.
• Depending upon the nature of the system being simulated and detail to which it is
modeled, the ratio of the simulated time to the real time taken can vary enormously.
Representation of time in Discrete Event Simulation
• One method is to advance the clock to the time at which the next event is due to
occur.
• The other method is to advance the clock by small intervals of time and determine at
each interval whether an event is due to occur at that time
Representation of time in Discrete Event
Simulation
• The first method is referred to as event-oriented, and the second
method is said to be interval-oriented.
• Discrete system simulation is usually carried out by using the event-
oriented method, while continuous system simulation normally uses
the interval-oriented method.
• It should be pointed out, however, that no firm rule can be made
about the way time is represented in simulations for discrete and
continuous systems.
• It is not the case that, the event-oriented method is not necessarily
faster than the interval oriented method for discrete systems.
Representation of time in Discrete Event
Simulation
• Fixed time step Model: In a fixed time step (interval oriented) model,
a time is simulated by the computer.
• All events that take place during that interval are treated as if they
occurred simultaneously at the end of this interval
Representation of time in Discrete Event
Simulation
• Next Event Model: In a next event model(event-to-event) the
computer advances time to the occurrence of the next event, thus it
shifts from one event to the next; the system state does not changes
in between.
• When something of interest happens to the system, the current time
kept track of.
• The following flowchart shows both models
Arrival Process Or Pattern
• Any queuing system must work on something –customer, parts,
patients, orders etc.
• We generally called them as entities or customers.
• Before entities can be processed or subjected to waiting , they must
first enter the system.
• Depending on the environment, entities can arrive smoothly or in an
unpredictable fashion.
• They can arrive one at a time of in clumps (eg bus loads).
• They can arrive independently or according to some kind of correlation.
Arrival Process Or Pattern
• They can arrive independently or according to some kind of
correlation.
• A special arrival process, which is highly useful for modeling purposes,
is the Markov arrival process which refers to the situation where
entities arrive one at a time and the times between arrivals are
exponential random variables.
• This type of arrival process is memory-less, which means that the
likelihood of an arrival within the next t minutes is the same no
matter how long it has been since the last arrival.
• Examples are phone calls arriving at an exchange, customers arriving
at a fast food restaurant, hits on a web site and many others.
Arrival Process Or Pattern
• The usual way of describing an arrival pattern is in terms of the inter-
arrival time, defined as the interval between successive arrivals.
• For an arrival pattern that has no variability, the inter-arrival time is,
of course, a constant.
• Where the arrivals vary stochastically, it is necessary to define the
probability function of the inter-arrival time.
• Two or more arrivals may be simultaneous.
• If n arrivals are simultaneous, then n-1 of them have zero inter-arrival
times.
Poisson Process (stationary)
• Consider random events such as the arrival of jobs at a shop, the
arrival of e-mail server, the arrival of boats to a dock, the arrivals of
calls to the call center, the breakdown of machines in a large factory,
and so on.
• These events can described by a counting function N(t) defined for all
t ≥ 0.
• This counting function will represent the number of events that
occurred in [0,t].
• Time zero is the point at which the observation began, regardless of
whether an arrival occurred at that instant.
Poison Process (stationary)
• For each interval [0,t], the value N(t) is an observation of a random
variable where the only possible values that can be assumed by N(t)
are the integers 0,1,2,..
• The counting process, {N(t), t ≥ 0) is said to be a Poisson process with
mean rate λ if the following assumptions are fulfilled.
a. Arrivals occur one at a time.
b. {N(t), t≥0} has stationary increments: The distribution of the
numbers of arrivals between t and t + s depends only on the length
of the interval ‘s’, not on the starting point t. The arrivals are
completely random
Poison Process (stationary)
• C. {N(t), t>0} has independent increments: The number of arrivals
during nonoverlapping time intervals are independent random
variables. Thus, a large or small number of arrivals in one time
interval has not effect on the number of arrivals in subsequent time
intervals. Further arrivals occur completely at random, independent
of the number of arrivals in past time intervals.
• This is equivalent to saying that the number of arrivals per unit time is
a random variable with a Poisson’s distribution.
• This distribution is used when chances of occurrences of an event out
of a large sample is small
Poison Process (stationary)
• The Poisson distribution is the discrete probability distribution of the
number of events occurring in a given time period, given the average
number of times the event occurs over that time period.
• Let X be the discrete random variable that represents the number of
events observed over a given time period. Ley λ be the expected value
(average) of X.
• If follows a Poisson’s distribution, then the probability of observing k
events over time period is
• P(X=k) =
Example 1
• A computer repair person is “beeped” each time there is a call for service. The
number of beeps per hour is known to occur in accordance with Poisson’s
distribution with a mean of λ= 2 per hour.
• a. Find the probability of three beeps in the next hour.
• b. Find the probability of two or more beeps in a hour-period
• Solution:
• Here k = 3.
• The probability of three beeps in the next hour is calculated as
• P(X=k) = = = 0.18
• P(X=2)+P(X=3)+…… 1- (P(X=0)+P(X=1)
• P(2 or more) = 1-(P(0)+P(1)} = 0.592
Example 2
• In a single pump service station, vehicles arrive for fueling with an
average of 5 minutes between arrivals. If an hour is taken as unit of
time, cars arrive accordance to Poison’s process with an average of λ
=12 cars/hr.
•
Example 3:
• A major league Baseball park, five customers arrive at a concession
stand on average in a ten-minute period.
A. What is the probability that in a ten minute period exactly three
people will arrive at the concession stand
B. Find the probability of exactly 3 customers arriving in 20 minutes?
C. Find the probability of 3 or fewer customer’s arriving in 20 minutes?
D. Find the probability of more than 3 customers arriving in 20
minutes
• A: λ =5, t=1 , x= 3
• P(X=k) = = = 0.18
Example 4
• Suppose that a computer will make an average of 3 errors per 40
words of translation. Suppose we randomly selects a 1200 word
passage translated by this program. Assume that the Poisson
distribution applies
A. Determine the probability that no errors will be found
B. Calculate the probability that more than 14 errors will be found
C. Find the probability that fewer than 9 errors will be found.
Non Stationary Poisson Process
• Non-stationary Poisson Process (NSPP) is characteristics by λ(t), the
arrival rate at time t.
• The NSPP is useful for situations in which the arrival rates varies
during the period of interest such as meal time in a restaurants,
phone calls during the business hours etc.
•
Non Stationary Poisson Process
• When the Poisson’s process is with a rate function λ = λ(t), which
varies with time. Such a process is called non-stationary or no-
homogeneous Poison process.
• If {N(t):t≥0) is a Poisson’s process with a rate function λ(t), then an
increment, N(t)- N(s), giving the number of events in the time interval
(s,t) , has a Poisson’s distribution with parameter μ= dt and
increments over disjoint intervals are independent random variables.
Example
• Demand on a first aid facility in a certain location occur accordance to
a non-stationary Poisson’s process with the following rate function:
• λ(t) =
• where t is measured in hours from the opening time of facility. Find
the probability
• (a) two demands occur in the first hour of operation
• (b) two demands occurs in the second hour of operation
• (c ) one demand occur in the last three hours of operation
• (d) two demands occur in the first two hours of operation
Solution
• (a) The mean for the first hour of operation is μ =
• Hence P(N(1)-N(0) =2} = = 0.251
• (b) The mean for the second hour of operation is 3. It follows that the
number of events in the time interval (1,2) has the Poisson’s
distribution with mean 3.
• Therefore
• P{N(2)-N(1) = 2} = = 0.609
• (c ) The mean for the last three hours of operation is
• u = = 4.5
• (d) The mean for the first two hours of operation is:
• u = + = 4.5
• Therefore , N(2)- N(1’) has the Poisson’s distribution with mean 4.5.
• Thus, P{N(2)-N(0) = 2} = = 0.1125
Gathering Statistics
• Most simulation programming systems include a report generator to print out
statistics gathered during the run.
• The exact statistics required from a model depend upon the study being
performed, but there are certain commonly required statistics which are usually
included in the output.
• Among the commonly needed statistics are:
• Counts giving the number of entities of a particular type or the number of times
some event occurs.
• Summary Measures such as extreme values, mean values and standard
deviations
• Utilization defined as the fraction (or percentage) of time some entity is engaged.
Gathering Statistics
• Occupancy defined as the fraction (or percentage) of a group of
entities in use on average
• Distributions of important variables such as queue length or waiting
times.
• Transit Times, defined as the time taken for an entity to move from
one part of the system to some other part.
Gathering Statistics
• When there are stochastic effects operating in the system ,all these
system measures will fluctuate as simulation proceeds, and the
particular values reached at the end of the simulation are taken as
estimates of the true values they are designed to measure.
•
Monte Carlo Method/ Simulation
• Monte Carlo methods, or Monte Carlo experiments, are a broad class
of computational algorithms that rely on repeated random sampling to
obtain numerical results.
• It is a numerical computation method that consists of extensive
experimental sampling with random numbers.
• For example, the integral of a single variable over a given range
corresponds to finding the area under the graph representing the function.
• Suppose the function f(x) is positive and has lower and upper bounds a and
b, respectively.
• Suppose, also, the function is bounded above by the value c.
Monte Carlo Method/ Simulation
• The graph of the function is then contained within a rectangle with sides
of length c and b-a.
• If we pick points at random within the rectangle, and determine whether
they lie beneath the curve or not, it is apparent that, providing the
distribution of selected points is uniformly spread over the rectangle.
• The fraction of the points falling on or below the curve should be
approximately the ratio of the area under the curve to the area of the
rectangle.
• If N points are used and n of them fall under the curve, then
approximately,
Monte Carlo Method/ Simulation
• =
• When it is decided that the sufficient points has taken, the value of
integral is estimated by multiplying n/N with the area of rectangle,
c(b-a)
Estimating the value of PI using Monte
Carlo Simulation
• The idea is to simulate random (x,y) points in a 2-D plane with domain
as a square of side 1 unit.
• We then calculate the ratio of number of points that lied inside the
circle and total number of generated points.
Estimating the value of PI using Monte
Carlo Simulation
Estimating the value of PI using Monte
Carlo Simulation
• We know that area of the square is 1 unit sq while that of circle is
• π *(1/2)2 = π/4
• Now for a very large number of generated points,
•
•=
Algorithm
1. Start
2. Initialize circle_point, square_points and interval to 0
3. Generate random point x
4. Generate random point y
5. Compute d = x*x + y*y
6. If d<=1 then increment circle_points
7. Increment square_points
8. Increment interval
9. If increment< NO_OF_ITERATIONS, then goto step 2
10. Calculate PI = 4*circle_points/square_points)
11. Stop