0% found this document useful (0 votes)
51 views101 pages

Simulation and Modelling Complete Notes

The document provides comprehensive notes on Simulation and Modeling, detailing the definitions, advantages, and disadvantages of modeling and simulation, along with various applications. It explains the concepts of stochastic activities, system environments, and types of systems, while also discussing different models and their classifications. Additionally, it highlights the importance of modeling in understanding complex systems and predicting outcomes in various fields such as manufacturing, healthcare, and logistics.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views101 pages

Simulation and Modelling Complete Notes

The document provides comprehensive notes on Simulation and Modeling, detailing the definitions, advantages, and disadvantages of modeling and simulation, along with various applications. It explains the concepts of stochastic activities, system environments, and types of systems, while also discussing different models and their classifications. Additionally, it highlights the importance of modeling in understanding complex systems and predicting outcomes in various fields such as manufacturing, healthcare, and logistics.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

lOMoARcPSD|50663938

Simulation and modelling complete notes

Simulation and Modelling (Pokhara University)

Scan to open on Studocu

Studocu is not sponsored or endorsed by any college or university


Downloaded by Kanchan Shrestha ([email protected])
lOMoARcPSD|50663938

CHAPTER 1: INTRODUCTION TO MODELING AND


SIMULATION
Modeling and Simulation:
Modeling means creating a physical replica or equations of a situation or activity. Also
Modelling is the process of representing a model which includes its construction and working.
This model is similar to a real system, which helps the analyst to predict the effect of changes
to the system. Example: A simple harmonic motion is represented by a second order equation
y" + ay = 0. The motion depends on the boundary conditions and parameter a.
A simulation is the process of using a model to study the behavior and performance of an
actual or theoretical system. Simulation of a system is the operation of a model in terms of time
or space, which helps analyze the performance of an existing or a proposed system. Simulation
is very important to check what would happen if something goes wrong. This helps to improve
the behavior of the physical situation. Example: A chemical reaction is normally simulated
before it is actually performed to see the effects. A mathematical model of a physical situation
is solved to see the effects of different parameters.
The computer simulation started when D.L. Gerlough published his dissertation: "Simulation
of freeway traffic on a general-purpose discrete variable computer" at the University of
California, Los Angeles, in 1955.
Modeling & Simulation ─ Advantages:
Following are the advantages of using Modelling and Simulation :
• Easy to understand − Allows to understand how the system really operates without
working on real-time systems.
• Easy to test − Allows to make changes into the system and their effect on the output
without working on real-time systems.
• Easy to upgrade − Allows to determine the system requirements by applying different
configurations.
• Easy to identifying constraints − Allows to perform bottleneck analysis that causes
delay in the work process, information, etc.
• Easy to diagnose problems − Certain systems are so complex that it is not easy to
understand their interaction at a time. However, Modelling & Simulation allows to
understand all the interactions and analyze their effect. Additionally, new policies,
operations, and procedures can be explored without affecting the real system.
Modeling & Simulation ─ Disadvantages
Following are the disadvantages of using Modelling and Simulation :
• Designing a model is an art which requires domain knowledge, training and experience.
• Operations are performed on the system using random number, hence difficult to
predict the result.
• Simulation requires manpower and it is a time-consuming process.
• Simulation results are difficult to translate. It requires experts to understand.

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

• Simulation process is expensive.


Modeling & Simulation ─ Application Areas
• Manufacturing applications – Is the computer-based modeling of a real production
system. Simulation analyze and experiment with their processes in a virtual setting,
reducing the time and cost requirements associated with physical testing.
• Construction engineering and project management
• Military application
• Logistic supply chain and distribution application
• Transportation modes and traffic
• Learning environment
• Business process simulation
• Health care
• Network simulation
Stochastic Activities:
The situations or models called stochastic , that have random element , hence unpredictable
and without a stable or certain pattern or order. Examples: All natural events are stochastic
phenomenon. And business and open economies are stochastic systems because their internal
environments are affected by random events in the external environment. Sometime called
synonymous with probabilistic. Where as Stochastic is an idea of(actual or apparent)
randomness but probabilistic is directly related to probabilities and is therefore only indirectly
associated with randomness.
System Environment:
System Environment is a space or world in which the system exists. System is affected by
elements outside of systems called Environmental variables or elements. There is a line
between system and system environment called boundary.

System concept
• System is an assembly of components used within one business unit, working together
for some purpose.
• Also, a system is a group of interrelated components working together to achieve
common goal by accepting inputs and producing outputs in an organized transformation
process.
• A system exists and operates in time and space ; bounded inside system boundary.

System – Terms:
i. State
A variable characterizing an attribute in the system such as no. of jobs waiting
for processing.

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

ii. Activity/event
An occurrence at a point in time which may change the state of the system
- Endogenous – activities occurring within the system
- Exogenous – activities occurring in the environment that affect the system
iii. Entity
An object that passes through the system e.g. cars .Entity is associated with an
event.
iv. Queue
- physical queue of entity/task
- any place where entities are waiting for something to happen for any reason
v. Creating
Causing an arrival of a new entity to the system at some point in time
vi. Scheduling
The act of assigning a new future event to an existing entity.
vii. Random variable
A random variable is a quantity that is uncertain, such as inter-arrival time
between two incoming flights or number of defective parts in a shipment.
viii. Random variate
A random variate is an artificially generated random variable.
ix. Distribution
A distribution is the mathematical law which governs the probabilistic features
of a random variable.
Characteristics of System:
i. Organization
• structure and order
• Example: Hierarchical organization in a company.
• Computer system: organization of various components like input devices,
output devices, CPU and storage devices
ii. Interaction
• Between sub systems or the components
• Example: the main memory holds the data that has to be operated by the
ALU.
iii. Interdependence
• Component linkage
• Component dependence
iv. Integration
•How subsystems are tied together to achieve the system objective
v. Central Objective
• Should be known in early phases of analysis
System – Simple Example:
Building a simulation of a gas station with a single pump served by a single service
man. Assume that arrival of cars as well their service times are random.

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

At first identify:
states: number of cars waiting for service and number of cars served at any moment
events: arrival of cars, start of service, end of service
entities: these are the cars
queue: the queue of cars in front of the pump, waiting for service
random realizations: inter-arrival times, service times
distributions: we shall assume exponential distributions for both the inter-arrival time
and service time

figure: Gas Station


Types of System:
i. Physical or Abstract System
• Physical systems are generally concrete operational systems made up of
people, materials, machines, energy and other physical things;
• static or dynamic in nature.
• Example : system-computer center ,Desks and chairs are the static parts;
Programs, data, and applications can change according to the user's
needs(dynamic parts).
• Abstract systems are conceptual. These are not physical entities. They may
be formulas, representation or model of a real system.
ii. Open or Closed systems
• An open system is one that interacts with its environment and thus exchange
information, material, or energy with the environment, including random and
undefined inputs. e.g: Business, Bank, college, Biological systems, etc.
• A closed system is one, which does not interact with its environment. This
kinds of systems are isolated from environments and occur rarely. e.g: A
computer program without input and output, A chemical reaction inside the
sealed tube.
iii. Deterministic or Probabilistic systems
• A deterministic system is one in which the occurrence of all events is known
with certainty. No doubt on their behavior. e.g: A computer program
• A probabilistic system is one in which the occurrence of events cannot be
perfectly predicted. Thus the behavior of such system always be uncertain and a
certain degree of error is always attached to the prediction. e.g: Weather forecasting,
Inventory control system, Random number generator, etc.
iv. Information System
• Provides information for decision making and/or control of organization
.
• Information removes uncertainty about an event or situation.

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

• Two types:
- Formal Information System: Based on the organization
representation by organization chart. Information is distributed in the
form of memos or reports , instruction from top level to intended user.
-Informal Information System: Employee based system where
problem can be solved with in the circle. e.g: casual conversation,
message on social media or blogs, etc.
v. Continuous and Discrete system
• A continuous system is one in which the state variable(s) change
continuously over time. E.g. the amount of water flow over a dam.
• A discrete system is one in which the state variable(s) change only
at a discrete set of points in time. E.g. customers arrive at 3:15, 3:23,
4:01, etc.

Model and Types of models:


A model of an object is a physical representation that shows what it looks like or how it works.
The model is often smaller than the object it represents. Also we define a model as the body of
information about a system gathered for the purpose of studying the system. Different models
of the same system will be produced by different analysis interested in different aspects of the
system or by the same analyst as his understanding of the system changes.
Types of models:
Models will first be separated into physical models or mathematical models.

MODELS

PHYSICAL MATHEMATICAL

STATIC DYNAMIC STATIC DYNAMIC

NUMERICAL ANALYTIC NUMERICAL


AL

SYSTEM SIMULATION

figure: Types of model


Physical models are based on some analogy between such systems as mechanical and electrical
or electrical and hydraulic . In a physical model of a system , the system attributes are
represented by such measurements as a voltage or the position of a shaft. The system activities
are reflected in the physical laws that drive the model.
The system models that uses symbolic notation and mathematical equations to represent a
system is known as mathematical model .Variables are used to represent the system and the

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

activities are represented by mathematical functions that interrelate the variables. Similarly,
statically and dynamically both physical and mathematical models are further divided.
Static models can only show the values that system attributes take when the system is in
balance. However, dynamic follow the changes over time that result from the system activities.
In mathematical models, a third distinction is the technique by which the model is “solved”
that means analytical and numerical methods. The technique that uses deductive reasoning of
mathematical theory to solve a model is known as analytical method. In practice, only certain
forms of equations can be solved. In some cases, an exact solution can be derived and a result
can be obtained in various conditions. The beauty of the analytical model is that it provides a
generic way to get performance results in various conditions through a mathematical
formulation. For example, linear differential equations can be solved.
The technique that applying computational procedures to solve equations is known as
numerical methods. Numerical methods are used when analytical or symbolic approaches to
solving math problems are computationally difficult. For example, the solution may be derived
in the form of a complicate integral which then needs to be expanded as a power series of
evaluation. Also system simulation is considered to be a numerical computation technique used
𝑏
in conjunction with dynamic mathematical models. Example: A definite integral ∫𝑎 𝑓(𝑥) dx
can be solved either analytically (i.e. symbolically) or numerically.
Static physical models vs Dynamic models
• The best known examples of physical • Dynamic physical models rely upon an analogy between the system
being studied and some other system of a different nature, the
models are scale models. analogy usually depending upon an underlying similarity in the
• In shipbuilding, making a scale model forces governing the behavior of the systems.
• To illustrate this type of physical model, consider the two systems
provides a simple way of determining the shown in following figures i.e. Figure a and Figure b.
exact measurements of the plates covering
the hull, rather than having to produce
drawings of complicated, three-
dimensional shapes.
• Scale models are also used in wind tunnels
and water tanks in the course of designing
aircraft and ships. Figure: (a) Mechanical System (b) Electrical System
• Although air is blown over the model, or • The Figure a. represents a mass that is subject to an applied force
F(t) varying with time, a spring whose force is proportional to its
the model is pulled through the water, extension or contraction, and a shock absorber that exerts a damping
these are static physical models because force proportional to the velocity of the mass.
• The system might for example represent the suspension of an
the measurements that are taken represent automobile wheel when the automobile body is assumed to be
attributes of the system being studied immobile in a vertical direction.
• It can be shown that the motion of the system is described by the
under one set, equilibrium conditions. following differential equation.
• In this case, the measurements do not 𝑀𝑥" + 𝐷𝑥′ + 𝐾𝑥 = 𝐾𝑓(𝑡)
Where, x is the distance moved, M is the mass, K is the stiffness of
translate directly into system attribute the spring, D is the damping factor of the shock absorber
values. • Figure b. represents an electrical circuit with an inductance L, a
resistance R, and a capacitance C, connected in series with a voltage
• Well known laws of similitude are used to source that varies in time according to the function E(t). If q is the
convert measurements on the scale model charge on the capacitance, it can be shown that the behavior of the
circuit is governed by the following differential equation:
to the values that would occur in the real 𝑞 𝐸(𝑡)
system. 𝐿𝑞" + 𝑅𝑞′ + =
𝐶 𝐶
• Sometimes, a static physical model is used • Inspection of these two equations shows that they have exactly the
same form.
as a means of solving equations with • The mechanical system and the electrical system are analogs of each
particular boundary conditions. other, and the performance of either can be studied with the other.

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

• There are many examples in the field of • In practice, it is simpler to modify the electrical system than to
change the mechanical system, so it is more likely that the electrical
mathematical physics where the same system will have been built to study the mechanical system.
equations apply to different physical • If, for example, a car wheel is considered to bounce too much with a
particular suspension system, the electrical model will demonstrate
phenomena. this fact by showing that the charge (and, therefore, the voltage) on
• For example, the flow of heat and the the condenser oscillates excessively.
• To predict what effect a change in the shock absorber or spring will
distribution of electric charge through have on the performance of the car, it is only necessary to change the
space can be related by common values of the resistance or condenser in the electrical circuit and
observe the effect on the way the voltage varies.
equations.
Static Mathematical Model vs Dynamic Mathematical Model
• A static model gives the relationships between the system • A dynamic mathematical model allows the changes of system
the system attributes when the system is in equilibrium. attributes to be derived as a function of time.
• If we alter the attribute values , the point of equilibrium • The derivation may be made with an analytical solution or with a
also changed , the model enables the new values for all the numerical computation, depending upon the complexity of the
attributes to be derived but does not show the way in which model.
they changed to their new values. • The equation that was derived to describe the behavior of a car
• For example, in marketing a commodity there is a balance wheel is an example of a dynamic mathematical model; in this
between the supply and demand for the commodity. case, an equation that can be solved analytically.
• It is customary to write the equation in the form:
𝑥" + 2𝜏𝜔𝑥′ + 𝜔2 𝑥 = 𝜔2 𝐹(𝑡)
𝐷 𝐾
𝑤ℎ𝑒𝑟𝑒 2𝜏 𝜔 = 𝑎𝑛𝑑 𝜔2 =
𝑀 𝑀
• Expressed in this form, solutions can be given in terms of the
variable wt. Figure.6 shows how x varies in response to a steady
force applied at time t = 0 as would occur, for instance, if a load
were suddenly placed on the automobile.
• Solutions are shown for several values of 𝜏 , and it can be seen that
• Both factors depend upon price: a simple market mode! when 𝜏 is less than 1, the motion is oscillatory.
will show what is the price at which the balance occurs.
• Demand for the commodity will be low when the price is
high, and it will increase as the price drops.
• The relationship between demand, denoted by Q, and
price, denoted by P, might be represented by the straight
line marked "Demand“ in Figure c.
• On the other hand, the supply can be expected to increase
as the price increases, because the suppliers see an
opportunity for more revenue.
Figure d: Solutions of second-order equations.
• Suppose supply, denoted by S, is plotted against price, and
• The factor 𝜏 is called the damping ratio and, when the motion is
the relationship is the straight line marked "Supply" in
Figure c. If conditions remain stable, the price will settle oscillatory, the frequency of oscillation is determined from the
to the point at which the two lines cross, because that is formula.
where the supply equals the demand. 𝜔 = 2𝜋𝑓 Where f is the number of cycles per second.
• Since the relationships have been assumed linear, the • Suppose a case is selected is representing a satisfactory frequency
complete market model can be written mathematically as and damping. The relationship given above between 𝜏, ω ,M, k and
follows: D show how to select the spring and shock absorber to get that type
Q=a-bP of motion. For example the condition for the motion to occur
S=c+dP without oscillation requires that 𝜏 ≥1. It can be deduced from the
S=Q definition of that the condition requires that D2≥4MK.
• The last equation states the condition for the market to be
cleared; it says supply equals demand and, so, determines
the price to which the market will settle.
• For the model to correspond to normal market conditions
in which demand goes down and supply increases as price
goes up the coefficients b and d need to be positive
numbers.
• For realistic, positive results, the coefficient a must also be
positive. Figure 4 has been plotted for the following values
of the coefficients:
a=600
b=3000
c=-100
d=2000
• The fact that linear relationships have been assumed
allows the model to be solved analytically. The
equilibrium market price, in fact, is given by the following
expression:
𝑎−𝑐
𝑃=
𝑏+𝑑
• With the chosen values, the equilibrium price is 0.14,
which corresponds to a supply of 180.

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

Principles Used in Modeling:


It is not possible to govern rule by which mathematical models are built, but a number of
guiding principles can be stated. Also they do not describe distinct steps carried out in building
a model. They just describe different viewpoints:
i. Block-building: The description of the system should be organized in a series of
blocks. Those constructed blocks aim is to simplify the specification of the interactions
within the system. The system as a whole can then be described in terms of the
interconnections between the blocks. Example as shown below:
Customer orders Production control dept

Finished Products
Raw Materials
Purchasing dept Fabrication dept Assembly dept Shipping dept

figure: A factory system

ii. Relevance : The model should only include those aspects of the system that are
relevant to the study objectives. As an example, if the factory system study aims to
compare the effects of different operating rules on efficiency, it is not relevant to
consider the hiring of employees as an activity.
iii. Accuracy: The accuracy of the information gathered for the model should be
considered. In the aircraft system , for example , the accuracy with which the
movement of the aircraft is described depends upon the representation of the airframe.
iv. Aggregation: A further factor to be considered is the extent to which the number of
individual entities can be grouped together into larger entities. The production control
manager, however, will want to consider the shops of the departments as individual
entities.
Similar considerations of aggregation should be given to the representation of the
activities. For example, in studying a missile defense system , it may not be necessary
to include the details of computing a missile trajectory for each firing.
Assignment:
1. Explain about calibration, verification and validation of model.
2. Steps of Simulation Study

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

CHAPTER 2: System Simulation


System Simulation:
System Simulation is a technique of solving problems that uses computer to imitate operations
of real-world task or processes through simulation by observation of the performance, over
time.
At the most general level , simulation should be considered as a form of cognition(cognition =
action or knowledge). There are three basic methods how to get an information of objective
reality: Experiment, Analysis and Simulation. Example: The system being investigated is a
gas station with one attendant. The question is " What is the average time spent by a car in the
gas station ". To get the answer we have three possibilities.
1. Experiment: Take stop watches and measure the time every car spends in the station.
Count the cars, at the end sum all times and divide them by the number of cars.
2. Analysis: Use a formula of the Queuing Theory to compute the average time spent in
the system directly . To use a formula you will have to assume certain queuing model
which means a considerable simplification of the real system and you will need some
quantitative parameters (Here arrival intensity-number of cars arriving per time unit
and service intensity-number of cars served per time unit).
3. Simulation: Write a simulation model that generates randomly arrivals of cars an
duration of services. This is also an experimental method . Instead of experimenting
with the real system the experiments are performed with the simulation model.

The Techniques of Simulation-Monte Carlo Method


• Is a numerical computation method which consists of experimental sampling with random
numbers.
• The basic concept is to use randomness to solve problems that might be in deterministic
principle.
• Most useful when it is difficult or impossible to use other approaches.
• Mainly used in three problem cases: Optimization , Integration and generating draws from
probability distribution.
Application
• Evaluating integrals of arbitrary function of 6+ dimension
• Predicting future values of stocks
• Solving partial differential equations
• Sharpening satellite images
• Modeling cell populations
• Finding approximate solutions to NP-hard problems
Explanation Of Monte Carlo Method
• The integral of single variable over a given range corresponds to finding the area under
the graph representing the function.
• Suppose :
𝑏
f(x) = ∫𝑎 𝑖𝑛𝑡𝑒𝑔𝑟𝑎𝑙 𝑒𝑥𝑝𝑟𝑒𝑠𝑠𝑖𝑜𝑛
where ,
f(x) is positive function

1|Page

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

a , b = lower and upper bounds respectively


also f(x) is bounded by the value c

• The function f(x) is contained with the rectangle with sides c and (b-a)
• Now , pick some points(N) at random within the rectangle and determine whether they
lie beneath the curve or not.
• The fraction of points falling on or out of the curve should be approximately the ratio
of the area under the curve to the area of rectangle.
𝑛 𝑏 𝑓(𝑥)𝑑𝑥
Then, approximately: = ∫𝑎
𝑁 𝑐(𝑏−𝑎)
where, N is total random points
n is points fall under curve
𝑛 𝑏
Now ,
𝑁
𝑐(𝑏 − 𝑎) = ∫𝑎 𝑓(𝑥)𝑑𝑥
• For each point, value of x is selected at random between a and b say x0 and at random
between 0 and c say f(x0)=y.
• If y≤ f(x0) the point is accepted in the count n , otherwise it is rejected and the next
point is picked.
• Monte Carlo is another name for statistical sampling methods of great importance to
physics and computer science.
Advantages:
• It is used to analyze complex and large practical problems when it is not possible to
solve them through a mathematical method.
• In simulation, the experiments are carried out with the model without disturbing the
system.
• Policy decisions can be made much faster by knowing the options well in advance and
by reducing the risk of experimenting in the real system.
Disadvantages:
• Simulation doesn't generate optional solutions.
• It may take a long time to develop a good simulation model.
• In certain cases simulation models can be very expensive.
• Simulation doesn't give the answers by itself so, decision-maker must provide all
information about the constraints and conditions for examination.

2|Page

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

Examples:

3|Page

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

4|Page

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

Problems Depicting Monte-Carlo Method:


Any problems that are too complex and impossible to solve and create "closed-box(such a
model that take too long to run)" using analytical or other approaches, where certain aspects
can be represented by random events.
Monte Carlo Simulation mainly of two classes:
1. Deterministic problem but its aspects can be simplified with a probabilistic (random)
model.
2. Problem involves randomness, but different elements of the problem/system interact in
a way which makes difficult to create a closed representation of the problem and its
randomness.

Case 1:
When system exhibits chaotic behavior and hard to precisely get accurate answer , then called
problem is deterministic but can't model it deterministically. Example 1: A double pendulum.
We have mathematical model of this but our measurements of the initial state of the pendulum
may have slight errors. We could use Monte Carlo simulation, modelling the measurement
error as a random variable, to predict what state the pendulum is most likely to be in a future
point in time. Example 2: let’s take the example of an aircraft engine. Failures happen for
essentially deterministic reasons (e.g. heat, mechanical strain, leading to degradation, cracking
and then failure), but we generally don’t know enough to create an accurate model of these
deterministic behaviors. We can, however, make a model of likely failure modes, and use
historical data to assign probabilities to these, in order to predict failure using Monte Carlo
simulation.
Case 2:
Example: Aircraft engines can catastrophically fail due to “foreign objects” (often birds!)
entering the intake while it is running - referred to as FOD. Failures due to FOD are essentially
random, but we have pretty good data on the probability of it happening. If we want to
understand how many spare engines to hold in case of breakdown (including these random
FOD) events we might use Monte Carlo simulation where FOD and other breakdown events
happen randomly, at different times, and we observe how many spares are needed in order to
always have a high likelihood of having enough in store in case of breakdown
Comparison Of Simulation and Analytical Method:
Both simulation and analytical methods are modeling approaches which aim is providing an
idea of system performance, in different condition.
Analytic method is a mathematical abstraction method that can be extended to address various
working conditions. An exact solution can be derived and a result can be obtained in various
conditions. Also it provides a generic way to get performance results in various conditions
through a mathematical formulation.

5|Page

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

A simulation method such as a Monte-Carlo also make assumption of a model and some
assumption about the behavior of the process. It is used when an analytical formulation cannot
be derived ( For example when the size of the model is too large or when no exact solution can
be derived). Simulation models provide results for a specific use case and should be run many
times to counter balance the effect of numerical calculations.
Compared with analytical solution of problems, the main drawback of simulation is apparent:
it gives specific solutions rather than general solutions. Example: In the study of automobile
wheel motor, an analytical solutions gives all the conditions that cause oscillation . But each
execution of simulation tells only whether a particular set of conditions did or didn't cause
oscillation . To try to find out all such conditions requires that the simulation be repeated under
many different condition.

Experimental nature of Simulation:


The simulation technique makes no specific attempt to isolate the relationships between any
particular variables; instead it observe in which all variables of model change with time .
Relationships between variables must be derived from these observations. Where the system is
tested against lots of input samples and observed outputs instead of analytical solutions.
Simulation is done in series of experiments on constructed mathematical or physical model that
representing similar object or system under study.
A simulation study of the automobile wheel suspension system that was analyzed as :
Mx" + Dx' + Kx = Kf(t)………..(i)
The relationship between D, K and M to prevent oscillation, which was previously discovered
analytically, would have to be discovered by observing the values that result in the motion
being non-oscillatory. Therefore, simulation is an experimental problem solving technique.

Distributed Lag Model:


Models that have the properties of changing only at fixed intervals of time, and based on current
values of the variables and values that occurred in previous intervals , are called distributed
lag models. They are used extensively in econometric studies where the uniform steps
correspond to a time interval, such as a month or a year , over which some economic data are
collected.
In theory, distributed lags arise when any economic cause, such as a price change or an income
change, produces its effect (for example, on the quantity demanded) only after some lag in time,
so that the effect is not felt all at once at a single point in time but is distributed over a
period of time. Thus, when we say that the quantity of cigarettes demanded is a function of
the price of cigarettes taken with a distributed lag, we mean essentially that the full effects of a
change in the price of cigarettes is not felt immediately, and only after some passage of time
does the quantity of cigarettes demanded show the full effect of the change in the price of
cigarettes.
To consider the matter more concretely, let qt be the quantity of cigarettes, say, demanded
per unit time, and let pt be the price per unit of cigarettes during time period t. Other
things remaining constant, such as income, population, and the price of cough drops, we may
express qt as a function of current and past prices:

6|Page

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

Suppose the price of cigarettes has been constant for a long time at a level p, so that p =
pt =pt-1 = pt-2, = …. Then the quantity of cigarettes demanded per unit time will also be a
constant:
Now let the price of cigarettes change from p to p +Δp in period t + 1 and remain at this new
level indefinitely. The effect of the change in period t + 1 will be to change the quantity
demanded from q to q + b0Δp. But the effects of the price change do not stop here; in the next
period, t + 2, the quantity demanded is further altered to q + b0Δp b1Δp . In general, after θ
periods, the change in q will be Thus, the effect of the change in price on demand is distributed
over time: b0Δp the first period, b0Δp + b1Δp the second, and so on.
Econometric models of this nature have been built for the national economies of most of the
major industrial countries. Many large corporations also use models reflecting the effects of
the national economy on their industry.
Example: Find the growth in national consumption for five years using the model given
.Assume the initial income Y-1 is 80 and take expenditure in the 5 years to be as follows:
Years G(Government Expenditure)
1 20
2 25
3 30
4 35
5 40

7|Page

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

Therefore , consumption (83.588,94.2088,102.97581,111.321909,119.57247) growth is in


distributed fashion not in drastic .

Cobweb Model:
• Cobweb Model or Cobweb Theory was first analyzed by Nicholas Kaldor in 1934
named as "Cobweb Theorem".
• Cobweb Model or Cobweb Theory is an economic model based on the idea that price
fluctuations can lead to fluctuation in supply which cause falling and rising in price .
Also explains why prices might be subject to periodic fluctuations in certain types of
markets
• It describes cyclical supply and demand in a market.

figure: Divergent Cobweb

8|Page

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

• Producers expectations about prices are assumed to be based on observations of


previous prices.
• Agricultural markets are a context where the cobweb model might apply.
Limitations of Cobweb Model:
• Rational expectations
• Price divergence is unrealistic and not empirically seen
• It may not be easy or desirable to switch supply
• Other factors affecting price
• Buffer stock schemes: Governments or producers could band together to limit price
volatility by buying surplus
Example: Draw the cobweb model(in graph) for:
i) Fluctuation of market price.
ii) Cobweb model for market economy graph from given data.
Q = 12.4-1.2P, S = 8.0+0.9P-1, S = D,P0 = 1.0
Solution:
i) Fluctuation of market price:
As you know Cobweb model is based on Supply and Demand chain where
fluctuation on Demand and Supply causes fall and rise in Price . In below figure p0
is the initial price, the value of S at the end of the first interval can be derived and
determines the value of Q.
Fluctuations of market price as shown in figure below:

9|Page

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

ii) Cobweb from given data:

10 | P a g e

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

Time advance mechanism


Time advances mechanism is a science of dynamic system which depicts the time
dependence of a point or state. Models are dynamic and facilitate simulation time for the
values(i.e. One value to another).
Simulation Time:
• Simulation time is the mechanism of passage of time .
• Simulation clock gives the current value of simulated time. The advancement of time
is managed by incrementing the simulation clock.
• The simulation clock is initialized at 0 and the times of occurrence of future events are
determined.

11 | P a g e

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

• The simulation clock is then advanced and statistics of performance measures are
collected.
Two Categories:
1. Discrete Time Simulation(DTS) model (fixed time advances Or time-step)
2. Discrete Event Simulation(DES) model (next event time)
DTS (fixed time advances Or time-step)
• In this model time unit is defined .
• Simulation clock advances a specified unit of time ∆ t for representing exact
increment.
• While upgradation in the further process in simulation clock, it examines the event
list to identify the possible occurrence of any event in past period of time ∆t.
• If one or more events were occurred during the previous interval then those events
are considered to occur at the end of the interval at system state.
• If the system is time driven, DTS is better. Also called synchronous model.
DES (next event time)
• Mapping of system that represents the variation of variables instantaneously in the
dynamic system over a period of time.
• Simulation Clock is varies according to the occurrence of events and facilitates the
initial worth of stimulated time on the basis of current events.
• It is better for event driven system.
• DES estimates the time for futuristic events on the basis of a list of events.
• Clock advances to next (most initialize simulated clock to 0) imminent event ,which
is executed.
• Also update the event list after event execution.
• Continue until stopping rule is satisfied.
• Clock jumps from one period of time to the next and period of inactivity are ignored.
Components of DES
• System state: Collection of state variables to describe the system state.
• Simulation clock: A variable giving the current value of stimulation time.
• Event list: A list containing the next time when each type of event will occur.
• Statistical counter : To accumulate quantities for output
• Initialization routine : Initialize the clock at 0
• Timing routine: Determine next event time, advancing the clock
• Event routine : Carry out logic for each event type.
• Library routines: Utility to generate random variants.
• Report generator and Main Program

12 | P a g e

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

Organization of DES Model

figure: Organization of Components


Arrival routine:

Departure routine:

Example: The Airport System


• Contains a single runway on which arriving aircrafts must land.
• Once an aircraft is cleared to land , it will use the runway .Runway is available only
after the aircraft has landed and the landed aircraft remains on the ground for a
certain period of time before departing.

13 | P a g e

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

Lets simulate "Airport System" having single runway(i.e. Single Server Queue)
Conceptualize Model:
• Customer (aircraft)
Entities utilizing the resource
• Server(runway)
Resource that is serially reused
• Queue
Buffer holding aircraft waiting to land

Objectives: Evaluate the performance of the "Airport System"


Performance Metrics:
• Average waiting time : an aircraft must wait when arriving at an airport before
they are allowed to land .
• Maximum number or aircraft on the ground : Helps to dimension the required
surface for the parking area.
Specification Model Of System:
• Customer:
➢ What is the arrival process?
▪ Schedule of aircraft arrivals
➢ Customer attributes?
▪ E.g. Priorities or other properties
• Servers
➢ How much service time is needed for each customer?
➢ How many servers?
• Queue
➢ Service discipline – Who gets service next?
➢ FIFO, LIFO, random…, depend on a property and Queue capacity

Computational Model Of System:


• The General Algorithm
• Define state variables
• Define the events
• For each Event
➢ Change the corresponding state variables
➢ Create next events, if any
➢ Collect statistics
➢ Progress simulation time
➢ Using and event-based time advance
State Variables:
• InTheAir: number of aircraft either landing or waiting to land

14 | P a g e

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

• OnTheGround: number of landed aircraft


• RunwayFree: Boolean, true id runway available

Events(Types):
• Events: aircraft arrival, landing, departure

• An event must be associated with any change in the state of the system.
Event 1: Aircraft Arrival
(InTheAir, RunwayFree)
Event 2: Aircraft Landing
(InTheAir, OnTheGround, RunwayFree)
Event 3: Aircraft Departure
(OnTheGround)
Output Statistics:
Compute:
• Maximum number of aircraft on the ground
➢ OnTheGround: indicate the number of aircraft currently on ground
➢ Maximum “on the ground” =Max(OnTheGround)
• Average Waiting Time:
➢ Waiting time for each aircraft: wti = ArrivalTime –LandingTime
➢ Total sum of all waiting times: wttotal = sum(wti)
➢ Total number of aircraft: Ntotal
➢ Average time: wtavg = wttotal/Ntotal

Effect of Time-Advance-Mechanism
• Now a days modeling and simulation becomes more complex, modelers are faced with
mounting challenges to design and analyze simulations that effectively address difficult
problems.
• We have to perform series of empirical studies to characterize and compare the influence
of TAM(DES and DTS).
• The effects of changes in time “step” across a number of vital simulation areas.

15 | P a g e

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

Queuing Models and its Characteristics


• Most simulations contain queues as part of the model.
• Queue is a collection of items , linear structure which follows a particular order in which
the operations are performed.
• Queueing theory refers to the mathematical models used to simulate these queues.
Queues or waiting lines arise when the demand for a service facility exceeds the
capacity of that facility.

Application:
• Supermarkets, Banks, Restaurant, Gas station ,ETC ………

Performance Measures
• E[S]: average system (response) time (average time spent in the system)
• E[W]: average waiting time (average time spent waiting in queue(s))
• E[X]: average queue length
• E[U]: average utilization (fraction of time that the resources are being used)
• E[R]: average throughput (rate that customers leave the system)
• E[L]: average customer loss (rate that customers are lost or probability that a customer
is lost)
Characteristics of Queuing Systems

16 | P a g e

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

Customer population:
• Finite customer population
➢ The number of potential new customers (arrival rate) is affected by the number of
customers already in the system (waiting and been served). i.e. finite number of
customers(e.g. 40, 50 , 100,….).
➢ Example: Total students of section A / B. As the number of students waiting to meet
with the Lecture increases for viva, the population of possible new students
decreases.
• Infinite customer population
➢ The number of potential new customers is not affected by the number of customers
already in the system.
➢ Example: supermarkets, banks , grocery store,……
Arrival Process:
• Arrival process is the distribution that determine how costumers arrive in the system.
• Arrival process is a random aspect and generally based on inter-arrival time of
successive customers.
• Also arrival may occurs differentially (Random, Scheduled, fixed ….)
• Random Arrival – arrival can be at any interval of time i.e. inter-arrival usually
characterized by probability distribution. Where Poisson arrival process (with rate λ),
where An represents the interarrival time between customer n-1 and customer n, and is
exponentially distributed (with mean 1/λ).
• Scheduled Arrival – interarrival times can be constant or constant plus or minus a small
random amount to represent early or late arrivals. E.g: patients to a physician or
scheduled airline flight arrivals to an airport.
• At least one customer is assumed to always be present, so the server is never idle, e.g.,
sufficient raw material for a machine.
Note: Service Process – is the distribution that determines customers processing
time(exponential/deterministic/general,…). The service rate describes the number of
customers serviced during a particular time period . The service time indicates the amount of
time needed to service a customer . Service rates and times are reciprocal of each other and
either of them is sufficient to indicate the capacity of the facility.
Waiting (Queue) Behavior:
• Waiting means a line(queue) and the attitude of the customers entering the queuing
system is known as waiting behavior.
• Classified as : (a) Patient Or (b)Impatient
• Patient: Wait for service until been served, no matter how much customer has to wait
once arrived to the system. E.g: Machines arrived at maintenance shop.
• Impatient: Customers that wait for a certain time in the queue and leave the system
without getting service and shows some impatient Behavior.
➢ Balking: leave when they see that the line is too long.
➢ Reneging: leave after being in the line when it is moving too slowly.
➢ Jockeying: move from one line to a shorter line.

17 | P a g e

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

System Capacity:
• A limit on the number of customers that may be in the waiting line and being on service.
• Limited capacity, e.g., an automatic car wash only has room for 10 cars to wait in line
to enter the mechanism.
• Unlimited capacity, e.g., concert ticket sales with no limit on the number of people
allowed to wait to purchase tickets.
Queue Discipline:
• Defined as the logical ordering process of customers in a queue that determines which
customer is chosen for service when a server becomes free.
• Queue Discipline types:
➢ FIFO(First In First Out)
➢ LIFO(Last In First Out)
➢ SIRO(Service In Random Order)
➢ SPF(Shortest Processing First)
➢ PR(Service according to Priority)

Types of Queue:
Two types:
• Single Server Queue
• Multiple Server Queue
Single Server Queue:
• Serve one at a time or can make request one at a time ,depends on queue discipline.
• Simply ,queue is a line of customers, where customer at the head of the line get service
from the server.
• Departure after service and arriving customers join the tail of line.

Example: For the following data find the queue Statistics(Time in minutes) : IAT denotes
the inter-arrival time and ST denotes the Service Time. Assume the first customer arrives at
Time t=0. Inter-Arrival Time(IAT): Time between two successive arrival.

18 | P a g e

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

Solution:

Explanation:
Inter-arrival time(IAT) is time between two successive arrival of customers. Arrival
Time(cumulative sum of IAT) is time of customer arrival. Service Time – time needs to
facilitated, waiting time – time to get service, service time begins – time when customers/jobs
started, Service Time End – time when customer/jobs finished and departure, Time Customer
Spends in System – total time spends in system(Waiting time + Service time) and Time the
system Idle – time that server stay relaxed.
Multiple Server Queue:
• Include more than one server and respond for multiple request at a time. Provide service
to customers/ jobs arriving into queue.
• The model of multiple server system is on parallel fashion , with several similar servers or
with different types of servers.
• In Multiple Server Models include either single queue or multiple queues (i.e. with a
separate queue for every server).

19 | P a g e

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

Example: A Restaurant System with two service Provider. The Time between service ranges
from 1 to 4 minutes, as shown :

Server1: More experience and can provide service faster. Distribution of service time shown.

Server2:

When servers are idle server1takes the service. If both are busy, the customer goes on queue.
Estimate waiting time for server1 and server2 .
Solution:
First, calculate inter-arrival time distribution.

20 | P a g e

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

For server1: Service Time Distribution

For server2: Service Time Distribution

Simulation Table:

Average Waiting Time= 2/10=0.2

Probability of Waiting = 2/10 =0.2

Average service Time = 38/10 =3.8

Probability of server Idle=

Server1=2/24=1/12=0.0833

Server2=14/27 = 0.51

Average Time between arrivals = Sum of all times between arrivals/ number of arrivals -1=24/9=2.66

Average Waiting Time those who waits = Total time customer wait in queue/total number of customer
who waits = 2/2=1

21 | P a g e

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

Average Waiting Time customer spends in the system = Total time customer spends in the system / total
number of customer = 40/10=4

Queues models:
Kendall Notation:
• D.G Kendall introduced in 1953 a three-factor shorthand notation to characterize a
range of queuing models.
• The three-factor notation is A/B/C, where
➢ A: specifies the interarrival time distribution
➢ B: specifies the service time distribution
➢ C: specifies the number of parallel servers
• The notation has since been extended to include up to six different factors. A notation
system for parallel server queues: A/B/c(/N/K/X).
• The First three parameters are typically used, unless specified
➢ A represents the interarrival-time distribution,
➢ B represents the service-time distribution,
➢ c represents the number of parallel servers,
➢ N represents the system capacity,
➢ K represents the size of the calling population,
➢ X specifies the service discipline.
Distribution Notation
• M: stands for “Markovian”, implying exponential distribution.
• D: deterministic (e.g. fixed constant)
• Ek: Erlang distribution with parameter K
• G: General (anything)
Kendall Notation Examples(Queue Models):
M/M/1 Queue:
• Poisson arrivals(exponential inter-arrival), and exponential service, 1 server,
infinite capacity and population , FIFO.
• The simplest 'realistic' queue.
M/M/m Queue:
• Poisson arrivals(exponential inter-arrival), and exponential service, but m server,
infinite capacity and population , FIFO.
M/D/1 Queue:
• Poisson arrivals and constant service times, 1 server, infinite capacity and
population, FIFO.
G/G/3/20/1500/SPF:
• General arrival and service distributions, 3servers, 17 waiting jobs(20-3), 1500 total
jobs, Shortest Packet First.
M/M/1 Queue Model
Assumptions
• The easiest waiting line model
• The following assumptions are made:
1. The customers are patient (no balking, reneging, or jockeying) and come from an
infinite population.

22 | P a g e

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

2. Customer arrivals are described by a Poisson distribution with a mean arrival rate
of (λ). This means that the time between successive customer arrivals follows an
exponential distribution with an average of 1/ λ.
3. The customer service rate is described by a Poisson distribution with a mean service
rate of (µ). This means that the service time for one customer follows an exponential
distribution with an average of 1/ µ.
4. The waiting line priority rule used is first-come, first-served.
5. Note: The service rate must be greater than the arrival rate (µ > λ). If µ ≤ λ the
waiting line would eventually grow infinitely large.
Operating characteristics formulas (Notation):
• λ: mean rate of arrival (number of arrival’s per unit of time)
• µ: mean service rate (average number of customers that can be server per unit of time)
• c: number of servers in parallel
• n: number customers in system
• ρ = λ/(cµ): utilization of the server; also the probability that the server is busy or the
proportion of time the server is busy(number of customers server per unit of time)
• Pn: probability that there are n customers in the system (1- ρ) ρn
• L: mean number of customers in the system (waiting + being served) (ℷ⁄𝜇 − ℷ)
2
• Lq: mean number of customers in the queue ρL=(ℷ ⁄𝜇(𝜇 − ℷ))
• W: mean waiting time or average time spend in the system(waiting + being served)
(1⁄𝜇 − ℷ)
• Wq: mean waiting time in the queue ρW=(ℷ⁄𝜇(𝜇 − ℷ))
𝜇
• Ln : Average length of non-empty queue( ⁄𝜇 − ℷ)
Example 1:
• The computer lab at State University has a help desk to assist students working on
computer spreadsheet assignments.
• The students patiently form a single line in front of the desk to wait for help.
• Students are served based on a first-come, first-served priority rule.
• On average, 15 students per hour arrive at the help desk. Student arrivals are best
described using a Poisson distribution.
• The help desk server can help an average of 20 students per hour, with the service rate
being described by an exponential distribution.
Calculate the following operating characteristics of the service system.
(a) The average utilization of the help desk server
(b) The average number of students in the system
(c) The average number of students waiting in line
(d) The average time a student spends in the system
(e) The average time a student spends waiting in line
(f) The probability of having more than four students in the system

23 | P a g e

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

solution:

Example 2:
A self-service store employs one cashier at its counter. Nine customers arrive on an average
every 5 minutes while the cashier can serve 10 customers in 5 minutes. Assuming Poisson
distribution for arrival rate and exponential distribution for service time , find:
i. Traffic Intensity
ii. Average number of customers in the system.
iii. Average number of customers in the queue or average queue length.
iv. Average time a customer spends in the system.
v. Average time a customer waits before being served.
Solution: (Example 2)
Given,
arrival rate (λ)= 9/5 customers/minutes = 1.8 customers/minutes = 108 customers/hour
service rate (µ)= 10/5 customers/minutes = 2 customers/minutes = 120 customers/hour
Traffic Intensity/utilization server
ρ = λ/ µ
= 1.8/2=0.9 0r 90%
Average number of customers in the system.
L = λ/( µ- λ)
=1.8/(2-1.8)=9
Average number of customers in the queue or average queue length.
Lq =ρL
= λ2 / µ ( µ - λ)
= 0.9*9 =8.1
Average time a customer spends in the system.
Ws = 1/( µ- λ)
=1/(2-1.8)=5min
Average time a customer waits before being served.
Wq = ρWs
= λ/( µ - λ)
=0.9*5=4.5min

24 | P a g e

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

Example 3:
A radio repairing person spent time to repair radio sets has exponential distribution with
mean 20 minutes. Radios are repaired on ordered fashion and their arrival is
approximately poison with an average rate of 15 for 8-hour day , find:
i. Traffic Intensity.
ii. How many jobs are ahead of the average set just brought in?
iii. Average number of jobs in the queue or average queue length.
iv. Average time a jobs spends in the system.
v. Average time a jobs waits before being served.
vi. What is the repairman’s expected idle time each day?
Solution: (Example 3)
Given,
mean(m) =20, mean = 1/ µ or 1/ λ
arrival rate (λ)= 15/8*60 radios/minutes = 0.03125
service rate (µ)= 1/20 radio/minutes = 0.05
Traffic Intensity
ρ = 0.03125/ 0.05
=0.625 0r 62.5%
Average number of radios in the system.
L = λ/( µ- λ)
=0.03125/0.01875=1.6666
Average number of radios in the queue or average queue length.
Lq =ρL
= λ2 / µ ( µ - λ)
= 1.04166
Average time a radio needs to spend in the system.
Ws = 1/( µ- λ) =1/(0.05-0.03125)=1/0.01875
=53.333
Average time a customer waits before being served.
Wq = ρWs
= λ/( µ - λ)
=33.333
What is the repairman’s expected idle time each day?
for 8-hour ρ= 8*0.625=5hours
idle time = 8-5= 3hours
Probability distribution:
Poisson Distribution:
• It is statistical tool that helps to predict the probability of certain events from happening
when you know how often the event has occurred within a specified period of time.
• It gives us the probability of a given number of events happening in a fixed interval of
time.
• Can be used to estimate how likely it is that something will happen “X” number of
times.
• Average arrival rate is known.
• Mean arrival rate is constant for some number of time periods.

25 | P a g e

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

• Number of arrivals in each time period is independent


• As the time interval approaches 0, the average number of arrivals approaches 0.
Example: The average number of minor earthquake shocks in Kathmandu is 150 per year.
What is the probability that exactly 200 shocks will hit in Kathmandu next year?
Solution:
λ = 150 shocks/year
x= 200 shocks
We know that ,
Poisson distribution formula:
P(x; λ)=(e- λ)(λx)/x!
Now, P(x; λ) = (2.71828)-150(150)200/200! =

Assignment:
Types of System Simulation
1. Numerical Computation Technique For Continuous Models:
2. Numerical Computation Technique For Discrete Models:

26 | P a g e

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

CHAPTER 3
Continuous system simulation
Introduction
A continuous system simulation is one, in which predominant activities of the system cause
smooth changes in the attributes of the system entities. When such system is modeled
mathematically , the variable of the model representing the attributes are controlled by
continuous functions. In general, in continuous, the relationship describes the rate at which
attributes changes, so that the model consists of differential equations.
If a system can be represented using simple differential equation model then it is often possible
to solve the model without the use of simulation, otherwise we use simulation to solve those
models which are complex to solve analytically.

System Dynamics
• System Dynamics is a methodology for studying and managing complex feedback
systems, in managerial, organizational and socioeconomic context.
• Dynamic System are imbedded into the development of System Dynamics and the
System Dynamics theory is often used to explain the principles upon which dynamic
systems are being built.
• The developers of system dynamics models are not always highly trained
mathematicians and in certain cases they do not see the need for dynamics applications
within their models.
• Example: Fluctuations in the general level of economic activity, price and supplies
fluctuate , social policies , biological oscillations, or explosions in populations, etc.
• The principal concern of a System Dynamics study is to understand the forces operating
in a system in order to determine their influence on the stability or growth of the system.
• Dynamic System is a system described by differential and /or difference equations. The
present output depends on past input and the output changes with time if it's not in a
state of equilibrium.
• Example( Dynamic System):
➢ A bathtub is a simple example of a dynamic system(material is flowing through this
system).
➢ A pot of water set on a burner.
Differential Equation:
We can use differential equation to represent the behavior of continuous system.
Example: Mx" + Dx' + Kx = Kf(t) (with constant coefficient describes the wheel
suspension of an automobile and is linear differential equation)
Although derivatives of any order may form other form , such as being raised to a power,
or are combined in any form , the differential equation is said to be non-linear differential
equation. Linear equations are simple to be solvable where non-linear equations can
usually not be solved exactly and are the subject of much on-going research.
When more than one independent variable occurs in a differential equation, the equation is
said to be partial differential equation. Differential equation occurs repeatedly in scientific
and engineering studies. It can involve the derivatives of same dependent variable with
respect to each of the dimensional body. An example is an equation describing the flow of

1
Compiled By: Santosh Bist

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

heat in a three dimensional body. There are four independent variable representing the three
dimensions and time , and one dependent variable , representing temperature.
Differential equation occurs repeatedly in scientific and engineering studies. The reason for
this prominence is that most physical and chemical process involves rates of change, which
require differential equations for their mathematical description. Since a differential
coefficient can also represent growth rate, continuous models can also be applied to a
problem of a social or economic nature where there is a need to understand the general
effect of growth trends.
Example: Lets illustrate how differential equation represent problems. Here we will show
how the equation describing the automobile wheel suspension system is derived from
mechanical principles.

Mx" = Kf(t) – Dx' – Kx …………(i)


• The variable x represent the vertical displacement of the point(point of wheel) , taking
x to be positive for an upward movement.
• The rate of change of position in the vertical direction called velocity of the wheel(x').
• Also the rate of change of velocity in the vertical direction called acceleration of the
wheel(x").
• According to "Mechanical Law" the relationship between applied force and movement
of a body states '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, M is mass and Kf(t) is applied force.
Mx" = Kf(t) (is the equation of motion in the absence of other forces)
• However, the shock absorber exerts a resisting force that depends on the velocity of
the wheel(force zero at wheel rest and increases as the velocity rises).
• If we assume the force is directly proportional to the velocity, it can be represented by
Dx'(D is a measure of the viscosity of the shock absorber).
• Similarly, the spring exerts a resisting force which depends on the extent to which it
has been compressed.
• Again, if the force is directly proportional to the compression , it can be represented
by Kx(K is constant defining the stiffness of the spring.
Mx" = Kf(t) – Dx' – Kx(since both these (Dx' and Kx) forces oppose the motion)
• So, it is linear differential equation , with coefficients, and , as mentioned above, it can
be solved analytically.
Analog Computers
• Generally used to solve continuous model but sometimes are also used to solve
static models.

2
Compiled By: Santosh Bist

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

• Before the general availability of digital computers(for the discrete system


simulation), there existed devices whose behavior is equivalent to a mathematical
operation such as addition or integration.
• The combination (of addition and integration devices )is specified by mathematical
model of a system allowed the system simulated.
• The devices gave continuous outputs and so lent themselves readily to the
simulation of continuous system called analog computer or when they are used to
solve differential equation they are referred to as differential analyzer.
• Simulation with an analog computer is more properly described as being based on
a mathematical model than as being a physical model.
• The most widely used form of analog computers is the electronics analog computers
based on the operational amplifiers.
• Voltages(v1,v2,v3,…) in the computers are equated to mathematical variables and
the operational amplifiers can add and integrate the voltage(input variables).
• It is necessary for sometimes to use sign inverter to satisfy the equations of the
model.
Components of Analog Computer
Adder: With an appropriate circuit, an amplifier made to add several input voltage each
representing the variable of the model to produce a voltage each representing a sum of
the input voltage.

Integrator: Integrator is a circuit arrangement , the output is the integral with respect
to time of single input voltage or the sum of several input voltages(can be positive or
negative).

Sign Inverter: It is an amplifier designed to cause the output to reverse the sign of the
input.

Scale Factor: Different scale factors can be used on the input to represent the
coefficient of the model equations.

Advantages of Analog Simulation:


• Analog computers have higher speed of solution than that of digital simulation.
• Analog simulations have direct access to an immediate display of computer
result.
• Analog simulation is more natural in sense so , can reflect system structure and
interpret the results.

3
Compiled By: Santosh Bist

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

Disadvantage of Analog Simulation:


Though analog computers came into existence much before the digital computers, and
have played a major role in the simulation of continuous dynamic system, but they are
giving way to digital computers at the fast pace. Following are some of the important
disadvantages of digital computers:
a) Limited Accuracy: The result obtained by employing digital simulation has high
accuracy than analog simulation. Thus, where high accuracy in results is
required , as in space vehicles, guided missiles and fusion, the analog method
cannot be used.
b) Magnitude scaling: In analog simulation , values of various variables are
represented by voltages and have fixed limit and range. Because of limited range
all program variables have to be scaled, so that none exceeds the voltage range
if exceeds the result become inaccurate. This is very difficult task, especially
when the number of variables is large and the variation is not known. On the
other hand , in digital computers, the problem of magnitude scaling does not
raise.
c) Hardware setup required: In analog simulation , hardware elements have to
combine to simulate the system , they have to be tested and calibrated while no
such set up is required in digital simulation. Switching from one simulation to
other takes time in analog simulation , while it requires no time in digital
simulation. A simulation program on a digital computer can be easily stored for
use.
d) The output of analog simulation is not understood by general people.
e) The analog computer is usually dedicated to one application at a time .
f) It has lack of memory.
Analog Methods
The general method by which analog computers are applied can be demonstrated using the
second-order differential equation given as:
Mx" + Dx' + Kx = KF(t) -----(i)
Solving the equation for the highest order derivate gives:
Mx" = KF(t) – Dx' – Kx ---------(ii)
From equation (ii), F(t) is supplied, and there exist variables representing -x and -x'. These
three variables can be scaled and added with a summer to produce a voltage representing Mx".
Integrating Mx" with scale factor of 1/M produces x'. Changing the sign produces -x', which
supplies one of the variables initially assumed; and a further integration produces -x, which
was the other assumed variable. For convenience, a further sign inverter is included to produce
+x as an output.

4
Compiled By: Santosh Bist

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

Design an analog computer for human liver. The equations for human liver are
dx1/dt = -k12x1 + k21x2
dx2/dt = k12x1 – (k21 + k23)x2
dx3/dt = k23x2
Solution:
Here, above model has more than one independent variable. i.e. when a model has more than
one independent variable, a separate block diagram is drawn for each independent variable and,
where necessary ,interconnections are made between the diagrams. As shown below;

Lets read from left to right there are three integrators and they solve the equations for x1,x2
and x3. Interconnections between the three integrators, with sign changers where necessary,
provide inputs that aware the differential coefficients of the three variables. The first integrator
is solving the equation
x'1 = -k12x1 + k21x2
The second integrator is solving the equation,
x"2 = k12x1 – (k21 + k23)x2
The last integrator solves the equation,
x'"3 = k23x2
Note: Mathematical model of liver

Hybrid Computers
• The scope of analog computers has been considerably extended by developments of solid-
logic electronic device.
• Solid-logic devices, in addition improves the design and performance of operational
amplifiers and make devices cheaper and easier to obtain.

5
Compiled By: Santosh Bist

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

• But , before that analog computer uses few nonlinear elements, such as multipliers or
function generators and were expensive to make.
• Also we know that digital devices can store values, switching , and performing logical
operation.
• So, the term Hybrid computer has come to describe combinations of traditional analog-
computer and digital devices.
• Hybrid computer may be used to simulate system that are mainly continuous and also have
some digital elements i.e. Hybrid computers are used mainly in specialized applications
where both discrete and continuous data need to be processed.
• For example:
➢ An artificial satellite for which both the continuous equation of motion and the digital
controls signal must be simulated.
➢ A petrol pump contains a processor that converts fuel flow measurements into quantity
and price values.
➢ In hospital Intensive Care Unit(ICU) , an analog device is used which measures patient's
blood pressure and temperature etc , which are then converted and displayed in the form
of digits.
• Hybrid computer are useful when a system that can be adequately represented by an analog
computer model is subject of a repetitive study.
Digital-analog Simulators
Analog computers have some disadvantages and to avoid , Digital-Analog simulators are on
effect. Digital-Analog Simulation is a programming technique which makes a digital computer
operate much like an analog computer. They allow a continuous model to be programmed on
a digital computer in essentially the same way as it is solved on an analog computer. These
languages contain macro instructions that carry out the action of address, integrators and sign
changers.
A program uses these macro-instructions to link them together in essentially the same way as
operational amplifiers are connected in analog computers. Later more powerful techniques of
applying digital computers to the simulation of continuous system have been developed. Due
to these digital-analog simulators are not now in common uses.

Continuous System Simulation Languages


A digital computer is limited to a routine that represents a function of analog or hybrid as is
done with digital analog simulator. This restriction in digital computer . To overcome the
restriction, a number of continuous system simulation languages(CSSL) have been developed.
They use the familiar statement type for digital computer , allowing a problem to be
programmed directly from the equation broken into functional elements.
A CSSL can include macros or subroutine which performs function of specific analog element.
It also includes variety of algebraic and logical expression to describe the relationship between
variable. Example: Continuous System Modeling program(CSMP-III).

Continuous System Modeling program(CSMP-III)


This program is constructed from three general type of statement:
1) Structural Statement
This statement defines the model which consists of FORTRAN like statement and
functional block designed for operation that frequently occur in a model definition. This

6
Compiled By: Santosh Bist

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

statement can make the use of operation of addition, subtraction, multiplication,


division and exponent.
Example: X = 6Y/10 + (Z-2)2
Fortran statement: 6.0*Y/10 + (Z-2)**2.0
Real constants have decimal notations. Exponential notations can also be used.
Example: 1.2e3
= 1.2*10-3
= 0.0012
Fixed value need declaration, variable name must be six character or less.
Example: PI = 3.14159
Functions used in CSMP-III:

2) Data Statement
These statement designs the numerical values to parameters , constant and initial
conditions, ICON can be used to set the initial value of the integration block function.
CONST can be used to set values for constant. PARAM is used to set parameters for
individual . It also can be used to set series of numeric values for one parameter.
Example:
CONST A = o.6, XDOT = 1.25, YDOT = 5.55
PARAM D = (0.25,0.50, 0.75, 1.0)
3) Control Statement
This statement specifies the option in the execution of the program and the choice of
the output. TIMER is used to specify the timer interval.
7
Compiled By: Santosh Bist

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

Example:
TIMER DELT = 0.005, FINTIM = 1.5, PRDEL = 0.1, OUTDEL = 0.1
where,
DELT – is Integration interval
FINTIM – is Finish Time
PRDEL – is Interval at which print results
OUTDEL – is Interval at which to print plot
If printed or print-plotted output are required then control statement with the words
PRINT and PRTPLT are used, followed by the name of variables to form the output.
TITLE and LABEL can be used to put headings on the output.
Example:
1) Solve the equation: 3x"' +15x" +50x' +200x = 10
Program:
TITLE DIFFERENTIAL EQUATION SOLUTION
*
X3DOT = (1.0/3.0)*(10.0 – 15.0*X2DOT – 50.0*XDOT – 200.0*X)
X2DOT = INTGRL(0.0,X3DOT)
XDOT = INTGRL(0.0,X2DOT)
X = INTGRL(0.0,XDOT)
*
TIMER DELT = 0.005, FINTIM = 1.5, PRDEL = 0.05, OUTDEL = 0.05
PRINT X, XDOT, X2DOT,X3DOT
PRTPLT X
LABEL DISPLACEMENT VS TIME
END
STOP
2) Explain about the simulation of an automobile wheel with CSMP III program for it.
Program:
TITLE AUTOMOBILE SUSPENSION SYSTEM
*
PARAM D = (5.656, 16.968, 39.592, 56.56, 113.12)
*
X2DOT = (1.0/M)(K*F – K*X – D*XDOT)
XDOT = INTGRL(0.0,X2DOT)
X = INTGRL(0.0,XDOT)
*
CONST M = 2.0, F = 1.0, K = 400.0
TIMER DELT = 0.005, FINTIM = 1.5, PRDEL = 0.05, OUTDEL = 0.05
PRINT X, XDOT, X2DOT
PRTPLT X
LABEL DISPLACEMENT VS TIME
END
STOP
Explanation:
Above program is for the case where Mass(M = 2.0), applied force(F) = 1.0 and
stiffness of the spring(K = 400) ,specified as CONST statement. A PARAM statement
has been used to produce runs with different values of D(5.656, 16.968, 39.592, 56.56,
113.12), to give different values to the damping ratio(0.1,0.3,0.7,1.0, and 2.0). The
program integrates with an interval of 0.0005, and runs for a time of 1.5.

8
Compiled By: Santosh Bist

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

The output is for values of X", X' and X, and print-plot for X. All output is at intervals
of 0.05.
Hybrid Simulation
Sometimes a model of a simulation does not show only continuous behavior completely, but
also has a discrete nature at this time, the system being simulated is an interconnected of
continuous and discrete system which can be best model by an analog and digital computers
being linked together to provide a hybrid simulation. High-speed devices are needed to
transform signal from one form of representation to the other. The term hybrid simulation is
generally reserved for the case in which functionally distinct analog and digital computers are
linked together for the purpose of simulation.

Feedback System:
A significance factor in the performance of many systems is that a coupling occurs between
the input and output of the system. Feedback describes the situation when output from (or
information about the result of) an event or phenomenon in the past will influence an
occurrence or occurrences of the same (i.e. same defined) event/phenomenon in the present or
future. When an event is part of a chain of cause-and-effect that forms a circuit or loop, then
the event is said to "feed back" into itself.

A home heating system controlled by a thermostat is a simple example of feedback system.


The system has a furnace whose purpose is to heat a room , and the output of the system can
be measured as room temperature. Depending upon whether the temperature is below or above
the thermostat (regular ) setting, the furnace (heater) 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 will on or off.
Example: Automatic Aircraft System
Continuous Simulation Example:
1) Predator and Prey:

9
Compiled By: Santosh Bist

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

It is also called parasite-host model. An environment consists of 2 populations, predator


& prey. Predator – Prey model is also a mathematical model. The Prey is passive but
the Predator depends on the Prey for their source of food. Let
x(t) = number of prey population at time t.
y(t) = number of predator population at time t.
Also, let us make the following assumption for Prey & Predator:
i. In the absent of Predator, the rate of growth of Prey = rx(t), where 'r' is natural
birth rate and natural death rate.
The rate of change of Prey Population,
𝑑𝑥
𝑑𝑡
= r.x(t)
ii. In the absent of Prey, the rate of change of predators in the absence of prey is -
sy(t), where 's' is natural birth rate and natural death rate.
The rate of change of Prey Population,
𝑑𝑥
𝑑𝑡
= -s.y(t)
iii. Both Predator and Prey presence which means increase in Predator species and
decrease in Prey species.
For Prey:
The interaction between predator and prey, the death rate of prey is proportional
to the product of two population size x(t).y(t) or death rate of prey is a.x(t).y(t).
Therefore, rate of change of prey population, dx/dt, is given by:
𝑑𝑥
𝑑𝑡
= rx(t) – a.x(t).y(t)

For Predator:
The interaction between predator and prey, the death rate of prey is proportional
to the product of two population size x(t).y(t) or death rate of prey is b.x(t).y(t).
Therefore, rate of growth of Predator population, dy/dt, is given by:
𝑑𝑦
= -s.y(t) + b.x(t).y(t)
𝑑𝑡

where, a and b are measure of effect of the interspecific between two species. As
the predator population increases, the prey population decreases. This causes the
decrease in the rate of increased predator, which eventually results in decrease in a
number of predators. These in turns cause the number of prey to increase.

2) The Pure and Pursuit Model:


In a Pure Pursuit problem, there is a target which moves along a predetermined path
and there is pursuer (follower) who follows the target, re-directing itself towards the
target at fixed interval of time. The target does not make any effort to evade (to escape)
the pursuer. An aircraft following an enemy bomber is an example of pure pursuit
problem .
Problem Statement:
The fighter aircraft flies towards the bomber to catch up with it and to destroy it. The
bomber continues to fly along a pre-determined path and the fighter has to change its

10
Compiled By: Santosh Bist

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

direction to keep pointing towards the bomber. Now a question is whether the fighter
will be able to destroy the bomber or not, if so, in how much time.
If the target flies along a straight line, the problem can be solved directly with analytical
technique: however, if the path is curve, the problem is much more difficult and
normally can't solved analytically. Then we will use simulation to solve these problems
under the following simplifying condition:
i) The target and the pursuer are flying in the same horizontal plane when the
fighter first sights the bomber, and both stay in that plane. This makes the
pursuit model two dimensional.
ii) The fighter's speed VF is constant(20kms/minutes)
iii) The target's path is specified.
iv) After a fixed time span ∆t the fighter changes its direction in order to point itself
toward the bomber.
Let us consider the situation, where the target and pursuit fly in the same
horizontal plane, stay in that plane. During the period of pursuit , the fighter
speed VF is constant at 20 kms/minutes while the target path is specified as a
function of time as follows:
Time(t) 0 1 2 3 4 5 6 7 8 9 10
X(t) 100 100 120 130 122 119 300 240 168 165 219
Y(t) 0 3 6 10 15 20 26 32 37 34 30
The fighter aircraft is at position(XF,YF) , i.e. (0,50) when it first sight the
bomber at time t=0, the time at which pursuit begins. At the time t=0, the
bomber is at (XB,YB) = (100,0). The fighter corrects its direction towards the
bomber and shoots the bomber by firing a missile as soon as it is within a
distance of 10km , and the pursuit ends. In case the bomber is not shoot within
12 minutes of pursuit, the pursuit is abandoned.
The fighter aligns its velocity factor with the point of sight towards the bomber.
It continues to fly in that direction for one minute and at time t+1, it looks the
target again and re-aligns itself. At time t, the distance between the fighter &
the bomber is:

Distance d = √[𝑌𝐵 (𝑡) − 𝑌𝐹 (𝑡)]2 + [𝑋𝐵 (𝑡) − 𝑋𝐹 (𝑡)]2

If 𝜃 is the angle with the line connecting the bomber and fighter mesh with x-
axis then
𝑌𝐵 −𝑌𝐹
sin 𝜃 = 𝑑
𝑋𝐵 −𝑋𝐹
cos 𝜃 = 𝑑

The co-ordinates of the position of the fighter at time t+1 can be determined as:
𝑋𝐹 (𝑡 + 1) = 𝑋𝐹 (𝑡) + 𝑉𝐹 𝑐𝑜𝑠 𝜃
𝑌𝐹 (𝑡 + 1) = 𝑌𝐹 (𝑡) + 𝑉𝐹 𝑠𝑖𝑛 𝜃
with these new co-ordinates of the fighter , its distance from the target is again
computed. If the distance is 10km or less, the pursuit ends. Otherwise the values
of the sin 𝜃,cos 𝜃 and new co-ordinates of the fighter are re-computed. If the

11
Compiled By: Santosh Bist

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

pursuit does not end within specified time, the bomber is considered as escaped
and pursuit is abandoned.

3) A Serial Chase Problem:


A serial chase problem can be defined as multiple pure pursuit problems. In these chase
problem, there are number of moving objects with chase each other in a serial order like
a chases B, B chases C, C chases D and so on. Each object moves towards its target. At
some time, each is being targeted by some other object. Depending upon the original
location and speed of the objects, each object will focus its own time to hit its target.
As soon as it occurs, the chase ends.
Let us consider the objects A, B, C & D located at original position as shown in figure
below:

Here, A is to hit B, B is to hit C & C is to hit D. The velocities of A, B, C and D are Va,
Vb, Vc &Vd respectively. Let 𝜃𝑎 be the angle with the velocity vector A makes with the
direction AB. Similarly, let 𝜃𝑏 be the angle which velocity vector B makes with
direction BC. Though C & D moves in straight line, in present case to generate the
problem, let 𝜃𝑐 & 𝜃𝑑 be the angle with velocity vector of C and D makes with direction
CD.
As A runs towards B , it continuously changes its direction so that its velocity vector is
in direction B. Similarly, B continuously changes its direction so that its velocity vector
is a way in a direction of its target C. Since D is not chasing any object it will move in
a straight line. So as to keep maximum distance from its hitter C. Object C has to run
towards D. These again move in a straight line as its target is running straight
We want to determine which of the object will be hit first?
These can be determining by simulating the chase as:
➢ The location of all 4 objects in determined after every small increment in time.
➢ The direction of motion at new point is determined.
➢ The distance between object are computed.
➢ As soon as the distance between any set of object i.e. distance AB, BC or CD
becomes zero, hit occurs and chase ends.
Assignment:
1) Interactive System
2) Real time System
3) Simulation of autopilot system

12
Compiled By: Santosh Bist

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

Chapter 4
Discrete System Simulation
Discrete System is defined as the changes in state are discontinuous and each change in the
state of the system is called an event. The model used in discrete system simulation has a set
of numbers to represent the state of system. A number used to represent some aspect of the
system state is called a state descriptor. The state descriptors change value and define a
discrete event as a set of circumstances, that causes an instantaneous change in one or more
system state descriptors.
It is possible that two different events occur simultaneously , or are modeled as being
simultaneous and not necessary to change all of state descriptors occurring simultaneously
belong to a single event. But the changes must be made sequentially. Also system simulation
must contain a number representing 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
simultaneous events, is an important aspect of programming simulations.

Representation of Time:
Clock time is the passage of time recorded by a number . It is initialized to zero and
subsequently indicates how many units of simulated time have passed since the beginning of
the simulation. The term simulation time means the indicated clock time and not the time that
a computer has taken to carry out the simulation. Also , there is no direct connection between
simulated time and the time taken to carry out the computations where the computation time is
the number of events that occur. Simulation is carried out on digital computers , where real
events occurs in time intervals measured in fractions of microseconds. We know , for
simulation of an economic system , events occurs once a year and even a hundred years of
operation could easily be performed in a few minutes of calculations.
Two methods exist for updating clock time. One method is to advance clock of time as event
occur also called event-oriented and second one 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 also called
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.
Another approach to representing the passage of time has been called significant event
simulation , is applicable to continuous systems in which there are quiescent(idle) periods. The
interval between events in the event-oriented approach is a quiescent period, but it involves
having the models representation of the system activities create a notice of the event that
terminates the interval. The significant event approach assumes that simple analytic functions,
such as polynomials of low order, can be used to project the span(duration) of a quiescent
period.

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

Generation Of Arrival Patterns:


Discrete system simulation generate exogenous arrivals. It is possible that an exact sequence
of arrivals has been specified for the simulation. For example: Extensively used for testing the
design of logic circuits, such as components of digital computers. A particular sequence of
signals might be designed as the simulation input to see if the design reacts as expected.
The sequence of inputs may have also been generated from observations on a system. The
programming components of system , are often tested with a record , gathered from a running
system. This approach has been called trace driven simulation.
The simulation proceeds by creating new arrivals as they are needed, if there is no interaction
between the exogenous arrival and endogenous events of the system .
The preferred method of generating arrivals for computer simulation programs is
Bootstrapping. Bootstrapping term is often used to describe the process of making one entity
create its successor. Exogenous arrival of an entity is defined as an event and the arrival time
of the next entity is recorded as one of the event times. When the clock time reaches this event
time , the event of entering the entity into the system is executed, and the arrival time of the
following entity is immediately calculated from the inter-arrival time distribution.
The arriving entity usually needs to have some attribute values generated. The attributes for
arriving entity can be assigned at the generation time or later on depending on the requirement.
If the attributes do not affect the event execution, then the attributes can be assigned later on.
But if attributes do affect the event execution, they must be assigned at the arrival time and
retained until the event execution is finished.
Example: Generation of telephone calls . The call length and the origin of the call need to be
generated.

Simulation of a Telephone System:


To illustrate the principle involved in the simulation of a discrete system, consider the example
of a simple Telephone System. The system has a number of telephones(we consider only eight),
connected to a switchboard by lines.

figure(a): Simple telephone system


Switchboard has a number of links which can be used to connect any two lines i.e. only one
connection at a time can be made to each line. Assumed that the system is a lost-call system,
i.e. any call that cannot be connected at the time it arrives is immediately abandoned. A call
may be lost because the called party is engaged, in which case the call is said to be busy call;

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

or it may be lost because no link is available, in which case it is said to be blocked call. We
will simulate , what proportion are successfully completed, blocked, or found to be busy calls.
From above figure (a) line 2 is connected to line 5 and line 4 is connected to 7. Below figure
(b) representing the state of the system.

figure(b): System state-1


Each line is treated as an entity, having its availability as an attribute. A zero means free, while
a one means that it is busy from Lines table. It is not necessary that a detailed history be kept
of each individual link , the fact is that there is fixed number of links(In this case three). The
group of links is represented as a single entity, having as attributes the maximum number of
links and the number currently in use.
Clock time(currently is 1027) is included to keep record of events and the unit of time is taken
1second. When simulation proceeds , clock will be updated to the next most imminent event.
Each call is a separate entity having as attributes its origin , destination, length and the time at
which the call finishes . Bootstrap method is used to generate the arrival of calls. Next call been
generated until clock reaches 1057.
The state of the system recorded at time 1027. There are two activities causing events: new
calls arrive and existing calls can finish. There are three future events: the call between lines 2
and 5 ;finished at 1053, the call between 4 and 7 ; finished at 1075, and a new call is due to
arrive at time 1057, it is due to last 20 seconds.
The simulation proceeds by executing a cycle of steps to simulate each event.
1) Scan the next potential event – In this case , the next potential event is at 1053. Clock
is updated.
2) Select the activity that cause the event – In this case , the activity is to disconnect a call.
3) Test whether the potential event executed.
4) Change the records to reflect the effects of the event – Set disconnected call to zero(line
2 and 5). Reduce the number of links in use by 1 and remove finished call from the
calls-in-progress table.

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

5) Gather some statistics for the simulation output – Counters are set aside to record the
number of calls that have been processed, completed, or lost through being blocked or
busy. Disconnection of a call , the counts of processed call and of completed calls are
increased by one, appears in figure(b) .

figure (b) – System state


In this system , next call arrive at time 1057. The clock is updated to the arrival time and the
attributes of the new arrival are generated. Also , it is necessary to carry out tests: first check if
a link is available or busy . In this call , the called party (line 7) is busy so call is lost. Both
processed calls and busy calls counters are increased by one. A new arrival is generated at time
1063 between line 3 and 6 and will last 98 seconds as shown in figure(c).

figure (c) – System state

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

Again, the next potential event is an arrival , but this time the arriving call can be connected,
so the state of the system moves, figure(d).

figure(d) – System state


Delayed calls:
In telephone system we assumed that the system is a lost-call system . Now , suppose the system
is modified , calls that cannot be connected are not lost , instead wait until they can be
connected. This is not seen in with normal telephone system.
To keep records of the delayed calls , build another list like the calls-in-progress list. To
understand delayed calls let us see following figure:

figure(e)

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

On figure(e) , there are 3 links and only one is in use. Given clock time is 1053, call in progress
4 to 7 at 1075. Also, next call arrive at 1057 from 1 to 7 but line 7 is busy. In this case call lost
and update call counters i.e. number of total proceeds call increased by 1.
For delayed calls , as shown in figure (f) :

figure(f) – State of System


When lines are busy , calls not lost , instead it waits for completion. The counters will still be
kept to show how many calls were delayed by encountering busy or blocked conditions. When
is completed, it is necessary to check the delayed call list to see if a waiting call can be
connected. The next call arrives at 1063 , from line 3 to 6 then system state as:

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

figure(g) – System state


Now , there reflects the changes that occur at time 1075 when the call from line 4 to line 7
ends. The call that was waiting for connection transfer to call-in-progress list where completed
calls disconnected and removed from call-in-progress. The result , when all changes have been
made as:

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

figure(h) – System state


Notice that the call that just arrived finishes before the call between lines 3 and 6 which arrived
earlier but is due to last much longer than the new call. Since the calls-in-progress table is being
in chronological order by completion time, the new call goes ahead of the earlier call in the list.

Simulation Programming Tasks:


Discrete simulation can be proceeds on digital computers . Now generalize the tasks involved
in preparing a computer program for a simulation. There are three main tasks to be performed
as shown in figure below:

figure – Simulation programming tasks


Generate Model –system image is a set of numbers to represent the state of the system as
description of the system. Its purpose is to reflect the state of the system at all times. The

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

activities of the system must be represented as routines that create the discrete events making
the changes to the system image.
Simulation Algorithm – The procedure that executes the cycle of actions involved in carrying
out the simulation, referred to as the simulation algorithm.
Report (Report Generator) – is the generation of an output report. The statistics gathered
during the simulation will usually be organized by a report generator.
The general flow of control during the execution of a simulation program is illustrated in figure
below:

figure: Execution of a simulation algorithm


The create/generate model is the task generating the model, which is executed once. The report
generation task, which is usually executed once at the end of the simulation. Carrying out the
simulation algorithm involves repeated execution of the five steps described previously.
1. Find the next potential event.
2. Select an activity.
3. Test if the event can be executed.
4. Change the system image.
5. Gather statistics.
If the test made at step three finds that the occurred event cannot be executed, the event may
be abandoned, as happened in the lost-call version of the telephone system. Also , when
conditions meets ,the event is to be executed, it is called conditional event. The existence of
the conditional events must be considered when finding the next event.
Gathering Statistics:
Almost all simulation programming systems generate report to print out statistic gathered.
Exact statistics required from a model depend upon the study being performed. But certain
common statistics which are usually included in the output are:

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

1. Counts – no. of entities of particular type or no. of times some event occurred
2. Summary measures – extreme values, mean values, standard deviations
3. Utilization – fraction of time some entity is engaged
4. Occupancy – fraction of a group of entities in use on the average.
5. Distributions – of important variables, such as queue lengths, waiting times .
6. Transit times – time taken for an entity to move from one part of the system to some
other part.
When there are stochastic effects operating in the system, all these system measures will
fluctuate as a simulation proceeds. The particular values reached at the end of the simulation
are taken as estimates of the true values they are designed to measure.

Counters and Summary Statistics:


Counters are the basis for most statistics. Some are used to accumulate totals: others record
current values of some level in the system. The telephone system simulation, for example, used
counters to record the total processed calls number, completed, blocked and busy calls number
as well as to keep track of how many links were in use at any time. Every counter incremented
by 1 if exists. Not only counters , we calculate probability , average , standard deviation etc.
The mean of a set of N observations xr(r = 1,2,3,…..N) is defined as
1
m = ∑𝑁 𝑟=1 𝑥𝑟
𝑁
Standard deviation is defined:
1
s={ ∑𝑁 2 1/2
𝑟=1(𝑚 − 𝑥𝑟 ) }
(𝑁−1)

Measuring Utilization and Occupancy:


Measuring the load on some entity is most common requirement of a simulation. The simplest
measure is to determine what fraction of the time the item was engaged during the simulation
run. The term utilization will be used to describe this statistic. The time history of the equipment
usage might appear as shown :

From above figure, tb time keep record at which the item last became busy , tf time keep record
at which item became free and the interval (tf – tb) is derived and added to counter. At the end
of simulation run, the utilization U is derived by dividing the accumulated total by the total
time T, so that , if the entity is used N times:
1
Utilization(U) = ∑𝑁 𝑟=1(𝑡𝑓 − 𝑡𝑏 )𝑟
𝑁
• A discrete simulation program, update time as events occur, will measure the intervals tf -
tb directly . A continuous simulation program update time in small intervals need to build
up the count by counting the number of intervals in which the item is busy.

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

In dealing with groups of entities , rather than individual items, the calculation is similar,
requiring that information about the number of entities involved also be kept. The figure below
represents function of time, the number of links in a telephone system that are busy. To find
average number of links in use, a record must be kept of the number of links currently in use
and the time at which the last change occurred. If the number changes at time tr , to the value
nr, then, at the time of the next change tr+1, the quantity nr(tr+1-tr) must be calculated and added
to an accumulated total. The average number in use during the simulation run, A, is then
calculated at the end of the run by dividing the total by the total simulation time T, so that:
1
A = ∑𝑁
𝑟=1 𝑛𝑟 (𝑡𝑟+1 − 𝑡𝑟 )
𝑇

Also , the below figure represent the number of entities waiting on a queue, in which case , the
calculation gives the mean number of entities waiting.

If there is an upper limit on the number of entities , as there was a limit on several links in the
telephone system then the occupancy is defined as the ratio of the average number in use to the
maximum number.
Average number in use
occupancy =
𝑀𝑎𝑥𝑖𝑚𝑢𝑚 𝑛𝑢𝑚𝑏𝑒𝑟

If M = links in a telephone
nr = number of busy in the interval ti and ti+1 then the average occupancy , assuming the number
nr changes N times is given by:
1
Occupancy (B) = ∑𝑁
𝑟=1 𝑛𝑟 (𝑡𝑟+1 − 𝑡𝑟 )
𝑁𝑀
An important difference between utilization and occupancy statistics is that for utilization,
timing information must be kept for each individual entity. Occupancy statistics only require
keeping a count of a class of entities , and recording the last time the count changed, just two
numbers.
Assignment:
Recording Distributions and Transit Times
Discrete Simulation Languages

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

Chapter 5: Probability Concepts and Random Number Generation


Probability concepts in simulation – Stochastic variables:
When the outcome of an activity can be described completely in terms of its input, the activity
is said to be deterministic. Stochastic activities output is of random nature. The terms random
and stochastic are used interchangeably. A stochastic process is defined as being an ordered set
of random variables. In particular , stochastic activities used in system simulation give rise to
a stochastic variable, represented by a sequence of random numbers occurring over time.
The activity can be discrete or continuous. The stochastic variable might, for example,
represent the number of days in the month( or a sequence of dates) , that take only the values
28,29,30 or 31: or it might be a variable representing wind velocity, which can vary over a
continuous range. It is necessary to understand stochastic variables and generating random
numbers to conduct system simulation.

Discrete Probability Functions:


A discrete probability function is a function that can take a discrete number of values (not
necessarily finite). If a stochastic variable can take I different values , xi(i = 1,2,… ,I), and the
probability of the value xi is p(xi), p(xi) is non-negative for all real xi and the sum of over all
p(xi) of xi is 1 i.e. ∑𝐼𝑖=1 𝑝(𝑥𝑖 ) = 1.
The set of numbers p(xi) is said to be probability mass function. Example 1: If we toss a coin
6 times we get 2 or 3 heads but not 2 and ½ heads. Example 2: The probability of each of six
faces in die is 1/6, but ,frequently , a probability mass function must be estimated by counting
how many times each possible value occurs in a sample. The probability is then estimated by
computing the fraction of all observations that took each value.
Each of the discrete variables have certain probability between zero and 1. A discrete function
that gives negative values and values greater than one is not probability function.
Let us assume an Examples of discrete variables that can occur in a simulation study are the
number of items a customer buys in a store. Figure below gives data gathered on the number
of items bought in a store for a sample of 250 customers.

figure 1: Number of items Bought by customers


xi is number of items, ni is number of customers, p(xi) is the estimate of the probability of
buying xi items i.e. p(xi) = ni / N(total No. of observations) . A cumulative distribution function

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

is defined as a function that gives the probability of a random variable's being less than of equal
to a given value. In the case of discrete data, the cumulative distribution function is denoted by
P(xi).
Probability functions are often displayed graphically as shown in figure below: figure a, is the
probability mass function and figure b, is the cumulative distribution function.

figure 2: Discrete probability functions

Continuous Probability Functions:


In continuous probability function , variable observed within range or interval. An infinite
number of possible values can be assumed by the variable. The probability of any specific value
occurring is considered to be zero. A probability density function is defined to describe the
variable. The probability that x falls in the range x1 to x2 is given by
𝑥
p[x1 ≤x ≤x2] = ∫𝑥 2 𝑓(𝑥)𝑑𝑥 for all x, f(x) ≥0
1

The integral of the probability density function taken over all possible values is 1. That is,

∫−∞ 𝑓(𝑥)𝑑𝑥 = 1

In practice, most variables in a simulation study have a finite lower limit, generally zero instead
of −∞ . The probability density function at and below this limit is then identically zero, and
the lower limit of the integral can be replaced by the finite value. The same effect may occur
at the upper limit.
The cumulative distribution function, which defines the probability that the random variable is
less than or equal to x, is denoted by F(x), in the case of a continuous variable . It is related to
the probability density function, as follows:

F(x) = ∫−∞ 𝑓(𝑥)𝑑𝑥

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

Measures of Probability Functions:


Some key parameters are used to measure probability functions. The most important of these
is the mean value. In the case of a discrete distribution, if there are N observations, taking the
individual values xr(r=1,2,3,….,N), the mean is estimated from the formula.
1
m = ∑𝑁
𝑟=1 𝑥𝑟
𝑁

If the observations fall into I groups , where the ith group takes the value xi and has ni members,
the formula can be written as
1
m = ∑𝐼𝑖=1 𝑛𝑖 𝑥𝑖
𝑁

For a continuous variable , the mean value is defined by the following integral:

m = ∫−∞ 𝑥𝑓(𝑥)𝑑𝑥

There are two other measures of a distribution , mode and median. When the probability
density function has a peak, the value of x at which the peak occurs is called a mode. If there
is only one peak occurs in the function, the probability density function is said to be unimodal.
The median is the value separating the higher half from the lower half of a data sample,
a population, or a probability distribution. Also it is not even necessarily true that the values of
a random variable will fall below the mean value. The value of x which defines the point is
called the median. The probability density function is sometimes described in terms of fractiles,
which are a generalization of the median. When considering percentages, the fractiles are called
percentiles.

In general, however, the mode and the median are not particularly significant when
representing probability functions in a system simulation, but it is important them with the
mean when interpreting input data. In addition, when certain well-known functions are to be
fitted to experimental data, the calculations determining the best fit sometimes involve the use
of modes, medians , or fractiles.

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

Another measure of a stochastic variable that is important is the variance of the variable ,
denoted by s2. The practical form in which the variance is used is as a standard deviation,
which is the (positive) square root of the variance , denoted by s. If there are N observations
taking the values xr (r = 1,2,3,….,N) and having the mean value m, the standard deviation is
estimated with the formula,
1 𝑁
s={
(𝑁−1)
∫𝑟=1(𝑚 − 𝑥𝑟 )2 }1/2

The significance of the standard deviation is that it is a measure of the degree to which the data
are dispersed.

Random Number
Random numbers are numbers that occur in a sequence ,are uniformly distributed over a
defined interval or set, and impossible to predict future values based on past or present ones.
Random numbers are important in statistical analysis and probability theory.
We know simulations are experimental in nature and most simulation be done on the basis of
random selection. In such simulations, random numbers are used for interarrival times, service
times, allocation amounts, and routing probabilities. For each application of random numbers
in a simulation, a distribution must be chosen. The distribution determines the likelihood of
different values occurring.
Continuous random variable – Random variable X is continuous if its sample space is a range
or collection of ranges of real values. Example: The height of people in Nepal lies between 0.5
and 6 feet.
Discrete random variable – is said to be discrete variable if it takes at most countable values.
In other word , a real valued function defined on a discrete sample space is called a discrete
random variable. Examples: 1) The number of people in queue in bank. 2) The number of
patients arrived in hospital.

Properties of Random Number:


Random number occur in sequence , distributed over a defined interval or set, and impossible
to predict future values. A sequence of random numbers, R1,R2,R3,……. must have two
important properties:
1. Uniformity ,i.e. they are equally probable every where
2. Independence , i.e. the current value of a random variable has no relation with the
previous values
Each random number Ri is an independent sample drawn from a continuous uniform
distribution between zero and one.
• pdf

• expectation

• variance

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

Some consequences of the uniformity and independence properties


1. If the interval (0,1) is divided into n sub-intervals of equal length, the
expected number of observations in each interval is N/n where N is the total
number of observations. Note that N has to be sufficiently large to show this
trend.
2. The probability of observing a value in a particular interval is independent of
the previous values drawn.
Pseudo Random Number
Random numbers that are generated in computer using algorithms is known as pseudo random
number. Pseudo means false, in the sense that the number are not really random! They are
generated according to a deterministic algorithm whose aim is to imitate as closely as
possible what randomness would look like.
For large enough sample, the generated values will pass all tests for a uniform distribution
and independence. Some important properties/considerations that need to be taken into
account when generating pseudo-random numbers:
• The random generation should be very fast.
• The cycle of random generated numbers should be long. The cycle is the length of
the sequence before numbers start to repeat themselves.
• The random numbers should be repeatable.
• The method should be applicable in any programming language/platform.
• The random numbers should be independent and uniformly distributed.
Challenges in generating pseudo random number:
• The numbers may not be uniformly distributed;
• The mean of the numbers may be too high or too low (might not be ½);
• The variance of the numbers may be too high or too low (might not be 1/12);
• The numbers might be discrete-valued instead of continuous;
• Independence might not hold.
Technique for generation of random number
As we know simulation is done with sequence of random variables called Stochastic variables.
All stochastic simulation need to "generate" identical, independence and uniform random
variables.
Density function:

Computer programs have been developed for generating sequences of numbers uniformly
distributed over given range(usually 0 to 1). Starting with initial number, second number is
generated. Using second number as input, the procedure is repeated to produce a third number
and so on. In general , the (i+1)th number of the sequence is generated from the ith number.
There are different technique to generate random number. Here we study about congruential
method( Linear Congruential Generator or sometimes, residue method). This procedure is
described mathematically by the expression,
Xi+1 = (λXi + µ)(modulo m) i= 0,1,2,3,4,……

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

Given three constants λ, µ, and m, the procedure derives the (i+1)th number from the ith
number by multiplying by λ , adding µ , and then taking the remainder or residue, upon dividing
by m.
To begin the process , an initial number X0 is needed, and this is called a seed. For complete
process therefore needs four numbers, λ , µ ,X0 and m. Then random number,
Ri = Xi/m i=1,2,3,4,……
Three types of congruence pseudo-random number generators have been used:
1) mixed congruential generator(defined by above formula)
2) additive congruential generator(if λ =1)
3) multiplicative congruential generator(if µ =0)
Example 1: Use linear congruential method to generate a sequence of random number with
seed=179.multiplier=43 and modulus 1000.
Solution:
Given,
λ = 17
µ = 43
X0 = 27
m = 100
According to LCG(Mixed LCG):
Xi+1 = (λ Xi + u) %m (i=0,1,2,3,…..)
Ri=Xi/m (i=1,2,3,4,…..)

i=0: X1 = (17*27 + 43) % 100 = 502 %100 = 2 R1 = X1/m = 2/100 = 0.02


i=1: X2 = (17*2 + 43) % 100 = 77 %100 = 77 R2 = X2/m = 77/100 = 0.77
i=2: X3 = (17*77 + 43) % 100 = 1352 %100 = 52 R3 = X3/m = 52/100=0.52
i=3: X4 = (17*52 + 43)%100 = 927 % 100 = 27 R4 = X4/m = 0.27
so, generated random numbers: 0.02,0.77,0.52,0.27

Example 2: Use multiplicative congruential method to generate a sequence of four_three digit


random number with seed=179.multiplier=43 and modulus 1000.
Solution:
seed(X0) = 179
multiplier(λ) = 43
modulus (m) = 1000
According to LCG(Multiplicative);
meu(µ) = 0
Then,
Xi+1 = λ Xi % m
for i=0: X1 = (43*179) % 1000 = 7697 % 1000 = 697 R1 = 0.697
for i=1: X2 = (43*X1) % 1000 = (43*697) %1000 = 971 R2 = 0.971
for i=2: X3 = (43*X2) % 1000 = 41753%1000 = 753 R3 = 0.753
for i=3: X4 = (43*X3) % 1000 = 32379%1000 = 379 R4 = 0.379
so, generated random numbers: 0.02,0.77,0.52,0.27

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

Test for Random number generation


Uniformity Test(K-S test and Chi-square test)

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

Example: The sequence of random numbers 0.54, 0.73, 0.97, 0.10, and 0.67 has been
generated. Use the Kolmogorov-Smirnov test at 𝛼 5% to determine if the hypothesis that the
numbers are uniformly distributed on the interval[0,1] can be rejected. [Note: critical value of
D for 5% significance level and N/𝜇=5 is 0.565].
Solution:
Given,
Random numbers = 0.54, 0.73, 0.97, 0.10, 0.67
Total observation N or μ = 5
Level of significance (𝛼 ) = 5%
critical value(D 𝛼 , N/𝜇) = 0.565
we know,
D = Max{D+, D-}
where,
𝑖
D+ = Max{ -Ri }
𝑁
(𝑖−1)
D- = Max{ Ri - }
𝑁
Then,
i Ri(order) i/N (i-1) / N D+ D-
1 0.10 0.2 0 0.1 0.10
2 0.54 0.4 0.2 -0.14 0.34
3 0.67 0.6 0.4 -0.07 0.27
4 0.73 0.8 0.6 0.07 0.13
5 0.97 1.0 0.8 0.03 0.17

Here,
D+ = 0.1
D- = 0.34
D = Max{D+, D-} = 0.34
Here, D(calculated value) < D(critical value), null hypothesis not rejected i.e. numbers are independence.
So , given sample is random numbers sample(generated using random process).

Chi-square test:

• A Chi-square (X2) statistic is a test that measures how a model compares to actual observed data.
• It was developed by Karl Pearson in 1900.
• Chi-square test is a non-parametric test (based on frequency and not on the parameters like mean
and standard deviation).
• This statistical test follows a specific distribution known as chi-square distribution.
• In general , the measure of difference between what is observed and what is expected according to
an assumed hypothesis is called the chi-square test. Given as :
(𝑜𝑖 −𝑒𝑖 )2
X2 = ∑𝑛𝑖=1 𝑒𝑖

where,
oi – observed frequency or observed value in the class.
ei – expected frequency or expected value in the ith class.
Sampling distribution of X2 is approximately the chi-square distribution with (n-1) degree of freedom.

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

If X2(sampled/calculated) < X2(Critical value/tabulated value) , Hypothesis(h0) accepted , i.e. the given
sample is uniformly distributed and is a sample of random number.

Example: Perform chi-square test for the test of randomness of occurrence at 1% significance
level. For n=10 classes, critical value = 2.09.

Solution:
Given:
no. of class(n) = 10
degree of freedom = (n-1) =9
level of significance (𝛼) = 1%
X2(critical value) = 2.09
we know ,
(𝑜𝑖 −𝑒𝑖 )2
X2(calculated) = ∑𝑛𝑖=1 𝑒𝑖
Then,

Expected value(ei) = N/n = 387.4


X2(calculated value) = 15.272
Here, X2(calculated value) > X2(critical value), null hypothesis rejected i.e. sample are not uniformly
distributed. So , given sample is not a random numbers sample.

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

Independence test(Runs test and Auto Correlation test)

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

Some old Questions


1. What are DSSLs ? Explain GPSS with example to solve discrete system problem.
2. Differentiate facilities and storage in details. Draw block diagram for simple
manufacturing shop model having more than one inspector.
3. List the advantage of using simulation package over programming language. Explain
the types of discrete system simulation language.
4. Consider a bank with 3 service counter where customer arrival time is in average of 5,
with a variance of 2 minutes. If any customers find the first service counter busy, he/she
goes to another service counter but it takes 3 extra minutes to move into the another
service counter, similar condition for reaching to third counter. It takes average of 10
minutes to provide service to any customer with 2,3,4 minutes variance respectively at
counter 1,2,and 3. Develop GPSS model considering 20% customer do not get proper
services.
5. Workers come to a supply store at the rate of one every 5,2 minutes. Their requisitions
are processed by one of two clerks who take 8,4 minutes for each requisition. The
requisitions are then passed to a single storekeeper who fills them one at a time, taking
4,3 minutes for each request. Write a GPSS block diagram to simulate the problem
from 1000 requisitions to be filled.
6. Parts are being made at rate of 1 every 8,2 minutes. They are of two types X and Y and
are mixed randomly with about being type Y . A separate inspector is assign to examine
each type of part. The inspector of X part takes 6,2 minutes and Y parts takes 10,5
minutes. Both inspector reject about 10% of parts they inspects. Simulate it for 1000
parts. Draw GPSS diagram and write code for them.
7. People arrive at the rate of one every 12,6 minutes to make a call from a public
telephone booth. If the telephone is busy, 50% of the people come back 10 minutes later
to try again. The rest give up. Assuming a call takes 5,2 , count how many people will
have given up by the time 100 calls have been completed. Give GPSS block diagrams.
8. Draw GPSS diagram and write code for manufacturing shop having at least two
inspectors.
9. What is DSSLs and CSSLs ? Explain various GPSS blocks that can be used to solve
discrete system.
10. For discrete system GPSS is used. Describe any four GPSS block diagram to represent
discrete system with example.
11. Explain about facility and storage entity with reference to manufacturing shop.
12. Explain the different types of BLOCK TYPES and their function.
13. Write the format and example of SIMSCRIPT statements for – i) Defining event with
parameter ii) Defining event without parameter
14. Explain the concept of System SIMSCRIPT.
15. Explain the SIMSCRIPT execution life cycle.
16. What is SIMSCRIPT ? Explain SIMSCRIPT program orientation.
17. Explain the organization of a SIMSCRIPT program with suitable diagram.
18. Write a SIMSCRIPT program for MAIN routine of the telephone system.

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

Chapter 6: Simulation Languages


A computer simulation language describes the operation of a simulation on a computer. There
are two major types of simulation: continuous and discrete event though more modern
languages can handle combinations. Most languages also have a graphical interface and at least
simple statistical gathering capability for analysis of the results. In a sense , these languages
are similar to language like Fortran, Java or vb.net but also include specific features to facilitate
the modelling process. Some example of modern simulation languages are CPSS/H, GPSS,
SLX, SIMSCRIPT, DSL, etc.
Merits of Simulation Language
• Since most features to be programmed are in-built with simulation language like
comparatively less programming time and effort.
• Simulation Language consists blocks, specially constructed to simulate the common
features, they provide a natural framework for simulation modeling.
• The simulation models coded in simulation languages can easily be changed and
modified.
• The error detection and analysis is done automatically is simulation language.
• The simulation models developed in simulation languages, especially the specific
application packages, called simulators, are very easy to use.
• Random number generator and related set of tools for reporting result.
• Simulation clock or mechanism for advancing simulated time.
Comparisons / Advantage of using simulation packages over programming language
1. Simulation package automatically provide features needed to build a simulation model,
resulting significant decrease in programming time and project cost.
2. It provides natural framework for simulation modelling.
3. Simulation models are generally easier to modify and maintain when written in a
simulation package.
4. They provide better error detection because many potential types of error are checked
for automatically.
However, Simulation model are still written in programming language because it offers
following advantages.
1. Analysis modeler already know a programming language this is often not the case with
the simulation package.
2. Simulation model efficiently written in C or C++ may require less execution time then
a model developed by simulation package.
3. A simulation package is designed to address a wide variety of systems with one set of
modelling constructs however, a C program may be more closely tailored to a particular
application.
4. Programming language may sometime allow greater programming than certain
simulation package.

Types of Simulation Language


There are three sorts of simulation languages:
1. Continuous System Simulation Language(CSSLs)

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

2. Discrete System Simulation Language(DSSLs)


3. Hybrid System Simulation Language(HSLs)

Continuous System Simulation Language


Before digital computers come into common use, analog computers were being used for
simulating continuous system. The system in an analog computer was represented by the block
of electronic devices such as operational amplifier to carry out the required operation. As soon
as the digital computer came, it provides many advantages over analog computer like greater
accuracy, freedom for scaling , easily stored for reuse etc. Therefore, a special program package
were implemented on digital computer to make a digital computer appear like analog computer.
This is called a digital analog simulators. Example: DEPI, DEPI-4, DAS, MIDAS, IBM 1130,
CSMP etc.
Types:
1. Block structured continuous simulation language
These are designed to simulate only those system that could be represented as analog
block diagrams and thus their application are limited. It requires user to prepare a analog
computer type block diagram and then input this diagram.
2. Expression based language
A block oriented continuous system simulation language is limited because of its small
specialized vocabulary. Since, the system must be represented first in analog block
diagram so this language are suited only for analog system and not for those who model
the system as set of equations. Expression based language or statement based language
overcome this drawback. Expression based language do not follow block structure
diagram but directly implements the differential equation of the model.

Discrete System Simulation Language


These languages are used to simulate discrete system and provide the following facilities:
• Automatic generation of random number.
• Automatic data collection.
• Statistical analysis of data.
• Report generations, etc.
The other classification of discrete simulation languages is based on the general world view
inherent in the language. Event, activity and process form the basis of three primary conceptual
frameworks(world view ) within discrete event simulation.
Note: Each language is based upon a set of concepts used for describing the system, this aspect
of simulation programs described using term world-view. The user of the program must learn
the world-view of the particular language he/she is using and be able to describe the system in
those terms.
Types:
1. Event oriented languages
In event oriented language each evet is represented by an instantaneous occurrence in
simulated time and must be scheduled to occur in advance when a proper set of
conditions exists. The system image changes i.e. state of system changes at the
occurrence of event. Example: SIMSCRIPT, GASP

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

2. Activity oriented languages


In an activity oriented language, the discrete occurrences are not scheduled in advance.
They are created by a program which contains description of the conditions under
which an activity can take place. The activity oriented language have two components:
Test component and action component. Here the event occurrence must e controlled
by a cyclic scanning activity program . Example: MILITRAN
3. Process oriented languages
Here a single process routine, composed of number of segments describe a sequence
of activities. Each segment behaves has an independently controlled program. On
receiving control, only the statement composing the segments are executed, and then
control is returned. Example: ASPOL, SIMUFOR
4. Transaction flow oriented languages
These languages are the sub category of process oriented language where flow of
activities passes through specially defined block system model is represented by a flow
chart consisting of language. The program creates transaction (entities), executes them
in the block and moves them along the flowchart. These languages are flow chart
oriented: the best known example is GPSS.
Hybrid System Simulation Language
Some language has been developed which are suitable for both discrete as well as continuous
models . This type of language is called hybrid system simulation language or combined
simulation language. These are written particularly for system models in which some of the
variable changes continuously and other variable changes discretely. Example: GASP IV.

GPSS(General purpose Simulation System)


• One of the earliest DSL was developed by Geoffrey Gordon(1961-1962).
• The first release of this language was implemented on the IBM 704, 709 and 7090
computers.
• Later on improved and more powerful versions have been developed and implemented,
including GPSS 2nd, GPSS 3rd(1965), GPSS 1360(1967), and GPSS V(The latest
version).
• GPSS was designed especially for those analysis who weren't necessary computer
programmer because they do not write programmed in the logic as the SIMSCRIPT
programmer does.
• Instead constructs a block diagram – an n/w of inter connected blocks, each performing
a special simulation oriented function.
• GPSS is particularly suited for traffic and queuing system.
Characteristics of GPSS
• Designed for analyst not programmers.
• GPSS is described as block diagram in which the block represents the activities, and
the lines joining the block indicates the sequence in which the activities can be
executed.
• GPSS V is a set of 48 different block types which perform some specific task.
• Machine efficiency is poor because GPSS is interprets system.
• Restricted to simple queuing problems.

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

GPSS Block Diagram


The development of a simulation model in GPSS is a block-by-block construction. A set of
standard block is arranged in the form of a block diagram that represents the flow of
entities(transaction) through the various paths of the system.
To build a block diagram , it is essential to have a complete description of the system. The
meanings of the blocks used in the system must be clearly defined. Each block must be assigned
the block time, i.e. the time which the execution of the block will take.
A set of block types have been designed, which can be used in the construction of a block
diagram. Each block type can be used any number in a block diagram, but the total number of
blocks should not exceed 2047. On the completion of the block diagram, each block is assigned
a number, between 1 and 2047, automatically called the block number or block identification
number or location.
The entities of the system being simulated are called as transaction . Example: customer in a
queuing system, message in communication system, a communication system is concerned
with the movement of messages, a road transportation system with motor vehicles, a data
processing system with records , and so on.
There can be many transactions simultaneously moving through the block diagram. Each
transaction is always positioned at a block and most blocks can hold many transactions
simultaneously . The transfer of a transaction from one block to another occurs instantaneously
at a specific time or when some change of system condition occurs.

Typical blocks are:


1. GENERATE: Create transaction and place on future event chain.
• GENERATE A, B, C, D, E
create Xact (transaction) for future entry into system
birth block
▪ A: mean value of inter-arrival time
▪ B: modifier
B≤A
▪ C: start delay time(offset time)
▪ D: creation limit(count)
▪ E: priority
• inter-arrival time uniformly distributed in
A±B
2. TERMINATE: Removes transaction from the system.
TERMINATE A
• Destroy transaction (Xact) or removed from simulation
Death block
A: Termination count increment
• when Xact move into bock, transaction count(tc) value is incremented by A and
continues until it reach predefined simulation steps.

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

3. ADVANCE: The block type "ADVANCE" is concerned with representing the


expenditure of time. The program computes an interval of time called an action time
for each transaction as it enters an "ADVANCE" blocks and transaction remain at the
block for this interval of simulated time before attempting to proceed.
• ADVANCE A, B
delay movement
▪ A: mean value for delay amount
▪ B: half-range for delay amount(modifier)
delay amount uniformly distributed in A±B
4. TRANSFER: The " TRANSFER " block allows some location other than the next
sequential location to be selected i.e. when there is choice of activities , we use this
block by stating the condition for the choice. The choice is normally between 2 blocks
refer to as next block 'A' and 'B'.
• TRANSFER A, B, C
jump to new location
▪ A: probability or mode determines which block to
choice
▪ if empty : unconditional transfer to location B
▪ Both: choose empty block(B first if both empty)
B and C block location
Note: A is selection factor, B and C fields are exit1 and exit2 respectively. Example:
TRANSFER 0.1,ACC,REJ means 10% go to location REJ(exit2) and 90% to ACC
(exit1).
GPSS Program Example: Simulation of Manufacturing shop
In a manufacturing shop, a machine tools turns out parts at the rate of one every five
minutes. As they are finished the parts go to inspector, who takes 4±3 minutes to
examine each part and rejects 10% of parts. Each part will be represented by one
transaction and time unit selected for problem will be one minute. Simulate for 100
parts to leave the system.
A GPSS block diagram for the system is as follows:

GPSS coding of the above block diagram of the manufacturing shop:

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

Description:
A GENERATE block is used to represent the output of machine by creating one
transaction every five minutes of time. The ADVANCE blocks with a mean of 4 and
modifier of 3 is used to represent inspection will therefore be anyone of values
1,2,3,4,5,6,7. After completion of the inspection transaction go to a TRANSFER block
with a selection factor of 0.1, so that 90% of the parts go to next location i.e. exit1 called
ACC and 10% go to another location i.e. exit2 called REJ . Since there is no further
interest both location reached from the TRANSFER blocks to TERMINATE blocks.
The program runs until a certain count is reached as a result of transaction terminating
. Field A of terminate block carries a number indicating by how much the termination
count should be incremented when transaction terminates at that block . The control
statement START has a field A that indicates a value the terminating counter should
reach to end the simulation. When the simulation is completed , the program
automatically generate a report , in a prearranged format.
Note:
i. In this case exit1(i.e. ACC) is the next sequential block so it is allowed to omit
the name ACC in both the TRANSFER Field B and the location field of first
terminate block. The GPSS code becomes like this TRANSFER 0.1, ,REJ. Both
comma must be given to indicate B is missing.
ii. If Transfer block is used as unconditional mode, then we need not have to
specify field A. However comma must be given to indicate A is missing. The
GPSS code become like this TRANSFER ,REJ.
Characteristic of the Block
1. Transactions(Xact)
In each system represented by a block diagram , some entities pass through the system.
In petrol pump system , they may be vehicles, in a production system they may be parts
and in supermarket system they may be customer . Those entities are referred to as
Transactions. In simulation the transaction are created, which move through the block
diagram in the same way , as the entities pass through the actual system being simulated.
There can be many transactions simultaneously moving through the block diagram.
2. Block / Action Time
The block time also called action time is an integer giving the number of units required
to execute the action represented by the block . The program computes an action time
for each transaction entering a block to represent the time taken by the system action
simulated by the block. The program compute an interval of time called action time for
each transaction as it enters and ADVANCE block, and the transaction remains at the
block for this interval of simulated time before attempting to proceed. The action time
may be a fixed interval or a random variable. An action time is defined by giving a
mean and modifier . Example: T = A ± B where A is the mean and B is the modifier.
3. Succession of Events

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

The program maintains records of when each transaction in the system is due to move.
It proceeds by completing all movements that are scheduled for execution at a particular
instant of time and that can be logically performed. When there are more than one
transaction due to move, the program processes transactions in the order of priority or
FCFS basis. Once the program begun moving a transaction, it continuous to move the
transaction through the block diagram until the transaction enters ADVANCE (wake
up other transaction and return to itself when action time is expended) or
TERMINATE(transaction is removed from simulation) block or the transaction is
blocked(action the transaction is attempting to perform can't be perform currently)
4. Selection Factor / Choice of path
The TRANSFER block allow some location other than the next sequential location to
be selected. The choice is normally between two blocks referred to as blocks A and
B(also called as exit1 and exit2). The choice of which exits to be followed is given by
a number called the selection factors. S(0<S<1) which is entered in the block. S is the
probability of selecting exit 2 and 1. S is the probability of selecting exit 1. Also if the
selection factor is BOTH, it first chooses empty block A i.e. exit1.
5. Items of Equipment
In each system, there are physical equipment, which perform some operation on the
transactions. Machine tools in a production shop perform machining operations on
work pieces. Example: In transportation system, a toll booth on a road is equipment,
while vehicles are transactions. In Factory Manufacturing system , an inspector is
equipment, while parts are transaction, etc. The item of equipment may operate upon
transactions individually or may handle groups.
6. Storage and Facilities
Item of equipment can be classified into storage and facilities, depending upon the
capacity for handling the transactions. An item of equipment , which can handle only
one transaction at a time, is called a facility while the items of equipment, which can
handle a large number of transactions at the same time is called storage.
Example: In communication system , message is transaction, switch(pass only one
message) is facility while trunk(collection of wirer carrying several messages) is
storage.
Facilities and Storage
A facility is defined as an entity or resources that can be engaged by a single transaction at a
time. Storage is defined as an entity or resource that can be occupied by much transaction at a
time up to some pre-determined limit.
Once a transaction seizes(holds) a facility any other transaction trying to seize the same facility
is delayed until the first transaction releases the facility (resources) but not in case of storage
until storage limit reaches. Some example of the system entities might be interpreted in
different system are:
Types of System Transaction Facility Storage
Communication Message Switch Trunk
Transportation Car Roll Both Road
Data processing Record Key stroke Computer memory
Computer Process CPU Memory

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

There are additional four block types concerned with using facilities and storages:
1. SEIZE: The SEIZE block allow a transaction to engage a facility if it is available.
2. RELEASE: The RELEASE block allows the transaction to disengage the facility.
3. ENTER: The ENTER block allows the transaction to occupy space in storage, if it is
available.
4. LEAVE: The LEAVE allows a transaction to give up the occupied space.

Field A in each case indicates which facility or storage is intended, and the choice is usually
marked in flag attached to the symbols of the block. If the field B in ENTER and LEAVE
blocks are blank, the storage contents are changed by 1. If there is a numeric(≥ 1). Then the
content changes by that value.
Example:
Let us consider a situation as below:
SEIZE CPU
ADVANCE 7
RELEASE CPU
Here CPU is a facility and it seems that a transaction needs to use the resource for 7 times units.
Any other transaction arriving at the block 'SEIZE' is refused to enter until the former
transaction has entered 'RELEASE' block.
Resources which can be shared by several transactions are modeled using storage. Suppose we
want to model a computer system which has 64kb of memory then we might declare
'MEMORY STORAGE 64' and then a request for 16kb memory might be represented by the
sequences of blocks.
ENTER MEMORY 16
LEAVE MEMORY 16
As the facilities, a transaction arriving at ENTER block at a time when it is used by other
transactions, is delayed until the previous transaction LEAVE the necessary memory with. A
transaction controlling and facility can be interrupted or preempted by other transactions.
Example 1:
In a manufacturing shop, a machine tools turns out parts at the rate of one every five minutes.
As they are finished the parts go to inspector, who takes 4±3 minutes to examine each part and
rejects 10% of parts. Each part will be represented by one transaction and time unit selected
for problem will be one minute. Simulate for 100 parts to leave the system assuming that there
is only one inspector.
Note: Since there is only one inspector, it is necessary to represent the inspector by a facility ,
to simulate the fact that only one part at a time can be inspected.

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

GPSS coding of the above block diagram of the manufacturing shop:


GENERATE 5 Create parts
SEIZE insp Get Inspector
ADVANCE 4,3 Inspect
RELEASE insp Free Inspector
TRANSFER 0.1,ACC,REJ Select Reject
ACC TERMINATE 1 Accepted parts
REJ TERMINATE 1 Rejected parts
START 100 Run 100 parts
Also , consider above example for more than one inspector is available, they can be
represented as a group by storage with a capacity equal to the number of inspectors.
GPSS block diagram:

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

GPSS code:
GENERATE 5 Create parts
ENTER insp Get an Inspector
ADVANCE 4,3 Inspect
LEAVE insp Free Inspector
TRANSFER 0.1,ACC,REJ Select Reject
ACC TERMINATE 1 Accepted parts
REJ TERMINATE 1 Rejected parts
STORAGE 3 Numbers of inspector
START 100 Run 100 parts
Note: STORAGE is a control statement which assigns the capacity of storage.
Example 2: Consider a factory that manufactures football taking 20 to 40 minutes. The ball is
moved from the generation to the inspection machine taking a 2 minutes. There are 3
inspection machine at one place and need 30 to 60 minutes for inspection and reject 30% of
football. Simulate for 1000 transaction . Draw GPSS block diagram to simulate this system.
solution:
Here, Manufacture of football takes 20 to 40 minutes so,
mean = (20+40)/2 =30
Generate = 30±10
product take 2 minutes to reach for inspection i.e. ADVANCE = 2, and for
inspection it take 30 to 60 minutes,
mean = (30+60)/2 = 45
ADVANCE = 45±15
GPSS Block Diagram:

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

GPSS Code:
GENERATE 30,10 Create parts
ADVANCE 2,0 To Inspect
ENTER insp Get an Inspector
ADVANCE 45,15 Inspect
LEAVE insp Free Inspector
TRANSFER 0.3,ACC,REJ Select Reject
ACC TERMINATE 1 Accepted parts
REJ TERMINATE 1 Rejected parts
STORAGE 3 Numbers of inspector
START 1000 Run 1000 parts
Gathering Statistics
Block types such as QUEUE, DEPART , MARK and TABULATE are used to gather statistic
about the system performance but not to represent the system action.

When the condition for advancing a transaction is not satisfied several transactions may be kept
waiting at a block and due to this the QUEUE block increase and DEPART block decreases
the number in field A i.e. queue block increases the queue number while depart block decreases
the queue number. A is queue number, B is the quantity by which the queue number is being
increased.
The MARK and TABULATE blocks are used to measure the length of time taken by
transaction to move the system or parts of the system. The MARK block simply notes the
arrival time on the transaction and the TABULATE blocks subtracts the time noted by
MARKED block from the time of arrival at the TABULATE block.
Example: Consider the example of manufacturing shop with 3 inspectors. Parts will now
accumulate on the inspectors works bench if inspection doesn't finish quickly enough. simulate
the situation for 1000 parts to measure how long the parts take to be inspected, excluding their
waiting time in queue.
Note:
i. Up to the above example, the properties of generate block is such that if a
transaction is unable to leave a block at the time it is cleared , no further
transactions are generated until the block is cleared so if all the inspectors are busy
, the machining of further parts stops until the machine is cleared.
ii. So if all inspectors are busy then queue is used to accumulate incoming parts/
transactions.

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

GPSS block diagram:

GPSS code
• In the above solution, a QUEUE block using queue number 1 is placed
immediately before ENTER block and a DEPART block is placed immediately
after the ENTER block to remove the part from the queue when inspection
begins.
• If some inspectors are free for inspection, then transaction doesn't have to wait
in queue otherwise they have to wait. The program will automatically measure
the length of stay in queue.
• The MARK and TABULATE block will measure how long the parts take to be
inspected , excluding their waiting time in the queue.
• If MARK block is omitted, the tabulated time is the time since the transaction
first entered the system.
GENERATE 5 Create parts
QUEUE 1 Queue for an inspector
ENTER 1 Get an Inspector
DEPART 1 Leave QUEUE
MARK
ADVANCE 12,9 Inspect
LEAVE 1 Free Inspector
TRANSFER 0.1,ACC,REJ Select Reject
TABULATE 1 Measure transit time
ACC TERMINATE 1 Accepted parts
REJ TERMINATE 1 Rejected parts

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

STORAGE 3 Numbers of inspector


START 1000 Run 1000 parts
Condition Transfer
The TRANSFER block can be used for both condition and unconditional transfer mode.
Consider again the case of three inspectors but suppose that the manufactured parts are put on
a conveyor, which carries the parts to the inspector. It takes 2 minutes for a part to reach the
first inspector who will take the part if it is not busy otherwise parts are passed to second
inspector which takes further 2 minutes to reach second inspector. If it is also busy then parts
are passed to third inspector which take another 2 minutes to reach third inspector, otherwise
they are lost.

i. In the above diagram, the movement of conveyer belt is represented by ADVANCE


block.
ii. As a transaction leave the advance block, it test whether an inspector is available by
entering a TRANSFER block with a selection factor set to BOTH.
iii. In the TRANSFER block the selection made BOTH implies A i.e. exit1 first if both
empty.
iv. TRANSFER block lead to SEIZE block that represent 1 inspector here 1,2, and 3.(NOTE:
we also can give name like ins1,ins2,ins3)

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

v. When parts finish inspection , the transaction goes to single TABULATE block where
the transit time is recorded.
vi. Because of the rule by which transactions normally pass from one block to next higher
numbered block, only one of the three release block that complete the inspection is able
to pass transactions directly to the TABULATE block.
vii. The other pass the transaction to TABULATE block using unconditional TRANSFER
block.

Program Control Statement


• Every GPSS program must contain a control statement SIMULATE. Although it need
not be the first statement in the program. Most programmers always start their programs
with the SIMULATE statement. The general form of it is : SIMULATE n , the operand
n is optional. If used, it limits that amount of time in minutes which the program will run.
This can be handy to use in the de-bugging stage to avoid infinite loops. For example ,
SIMULATE 2.5 would limit the program to 2.5 minutes running time. Without this
statement , the problem will be assembled but not executed.
• When a GPSS simulation run is finished the program does not immediately destroy the
model Instead of immediate destroy of model after GPSS simulation run, it looks for
more input following the START statement and can change the model. For example: A
storage capacity would be redefine by increasing a 'storage' statement for assigning a new
value.
• The model could also be modifying by changing existing blocks.
• Certain control statement like RESET can be included between START statement will
wipe out all the statistics gathered so far, but will learn the system loaded with transaction.
• Another control statement , CLEAR, will not only wipe out the statistics of preceding run
but will also wipe out transaction in the system so that the simulation started from the
beginning at the re-run.
• The END statement is used to terminate the run.
Example:
GENERATE 5 Create parts
ADVANCE 2 Place on conveyor
TRANSFER BOTH, ,conv1 Move to first Inspector
SEIZE 1 Get first inspector
ADVANCE 12,9 Inspect
RELEASE 1 Free Inspector
TAB TABULATE 1 Measure transit time
TERMINATE 1

conv1 ADVANCE 2 Place on conveyor


TRANSFER BOTH, ,conv2 Move to second Inspector
SEIZE 2 Get second inspector
ADVANCE 12,9 Inspect
RELEASE 2 Free Inspector
TRANSFER ,TAB

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

conv2 ADVANCE 2 Place on conveyor


TRANSFER BOTH, ,conv3 Move to third Inspector
SEIZE 3 Get third inspector
ADVANCE 12,9 Inspect
RELEASE 3 Free Inspector
TRANSFER ,TAB

conv3 TERMINATE
1 TABLE M1,5,5,10 Tabulation Intervals
START 10,NP Initialize with ten parts
RESET
START 1000 Main run

SIMSCRIPT Program
• The SIMSCRIPT programming system is especially designed to facilitate the writing
simulation program.
• SIMSCRIPT is a very widely used language for simulating discrete system and similar
to FORTRAN in appearance.
• SIMSCRIPT 11.5 can be view as a general programming language with extra features for
discrete event simulation.
• Because of this general power and FORTRAN based, SIMSCRIPT has been widely
implemented and used discrete simulation language.
• The language can be considered more than just a simulation language since it can be
applied to general programming problems.

SIMSCRIPT System Concept


• The system to be simulated is considered to consist of entities having attributes that
interact with activities. The interaction causes event that change the state of the system .
• In describing the system, SIMSCRIPT uses the terms entities, attributes, sets, event
routine.
• When and entity is created it can be interpreted as generic definition for a class of entities.
Individual entities have values all attributes which define particular state of the entity
attributes are named not a number. For example: we may define employee to be an entity
and AGE, SALARY are attributes.
• Entities can be : Permanent – entities that are created and remains during the run.
Temporary – entities that are created and destroyed during the execution of simulation.
• Temporary entities form sets. The user can define sets, and facilities are provided for
entering and removing entities into and from sets. Commands are available to manipulate
these sets , where pointer is used to chain together entities in sets.
• Activities are considered as extending over time with their beginning and their end being
mark as events occurring instantaneously. Each type of event is described by an event
routine, each of which is given a name and programmed as a separate closed sub routine.
Events may be
1. Endogenous event(internal)
• Results from action within the system

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

• An endogenous event is caused by scheduling statement in some event


routine.
• The event marking the beginning of an activity will usually schedule the event
that marks the end of the activity.
• If the beginning or ending of an activity implies the beginning of some activity
, then the event routing marks the beginning or ending of the first activity will
schedule the beginning of second.
2. Exogenous event(External)
• Results from action in the system environment.
• Exogeneous event requires the reading of data supplied by the users.
• There can be many data sets representing different sets of external event such
as time at which the event occurs.
• Event routine are needed to execute the changes that results when an external
event becomes due for execution.
• In practice, external event such as arrival are often generated using bootstrap
method.

Structure / Organization of SIMSCRIPT program


Since event routines are closed routines, some means must be provided for transferring control
between them. It is done by the use of event notice. These event notices are created when it is
determined that an event is scheduled. An event notice exists for every endogenous events
schedule to occur.
An event notice records the time the event is due to occur and the event routine that is to execute
the event . If the event is to involve one of the temporary entities, the event notice will usually
which one is involved. The event notices are filled in chronological order.
The general manner in which simulation proceed is illustrated in below fig:

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

When all events (that can be executed at a particular time) have been processed, the clock is
update to the time next event notice and the control is passed to the event routine as identified
by the notice. These actions are automatic and doesn't need to be programmed .
I the event executed by a routine results another events, the routine must create a new event
notice and filed it with the other notice.
In case of exogeneous events a series of exogenous event statements are created. For each event
this statements are similar to event notices are also filed into chronological order and are read
by the program.

Names and Label:


• User must describe each entities by giving a name and its attributes.
• Name may consist of any combination of letters and digits(at least one letter).
• Reserved name can't be used.
• For example, if an entity type is to represent a person, it could be named PERSON. If the
attributes of PERSON are age and name then they can be named as AGE and NAME or
PERSON.AGE and PERSON.NAME respectively.
• Labels are used for identifying programming statements.
• Labels are identified by being enclosed between single quotation mark.
'top' PRINT ………
……
……
……
GOTO top

SIMSCRIPT Statements:
• SIMSCRIPT statements are written in a form closely resembling the English language.
• There are many alternative terms or mode of statement which will be interpreted as
equivalent statement.
• The statement PRINT n LINES AS FOLLOWS is equivalent PRINT n LINES THUS
Example:
PRINT 1 LINE AS FOLLOWS
Hello world
The above statement Prints a single line output with Hello world message.
PRINT 1 LINE with x, y, x/y AS FOLLOWS
Value of x = ***, Value of y = ***, x divide by y = ***.*
1. The standard IF statement
Simple either or logic is supported by the IF statement.
The general form is
IF logical expression
Group of statement 1
ELSE
Group of statement 2

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

2. The SELECT CASE Statement


The SELECT CASE statement provides for choosing one among many.
The general form is
SELECT CASE expression
CASE constantlist1
Group of statement1
CASE constantlist1
Group of statement1
DEFAULT
Group of statements
END SELECT
3. Looping statement
These statements serves for iteration purpose.
The general form is
WHILE expression
DO
Group of statements
LOOP
Or
UNTIL expression
DO
Group of statements
LOOP
Or
FOR expression1 TO expression2 BY expression3
DO
Group of statements
LOOP
Or
'labelname' ……
………
GOTO 'labelname'
4. The create and destroy statement
They are used to create new temporary entity or event notice and destroy theme
The general form is
CREATE temporary entity or event notice
DESTROY temporary entity or event notice
Example: CREATE call
DESTROY call
5. The LET Statement
It is used to declare a variable.
The general form is
LET variable = expression
Example:
LET pop = 4000
LET SUM = (A+B)

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

Example 1: A simple SIMSCRIPT II program to read three number and display their
sum
READ X, Y AND Z
ADD X + Y TO Z
PRINT 1LINE WITH Z AS FOLLOWS
X + Y + Z = ***.*
STOP
The above program displays the sum of three number with label X+Y+Z = , and 4 digit
integer value as sum.
Example 2: A SIMSCRIPT II program to read a set of 100 numbers and add together
those number which are greater than 5.
'READ' ADD 1 TO COUNT
IF COUNT > 100 GO TO FINISH
ELSE READ N
IF N IS GREATER THAN 5 ADD N TO SUM
REGARDLESS GO TO READ

'FINISH' "CONTINUE PROGRAM"


Note: if a pair of single quote is enclosed then it means comment.
In addition to else, we can use REGARDLESS, OTHERWISE, ALWAYS as needed
as shown in below example:
IF X IS LESS THAN A
IF Y IS LESS THAN B
LET Z = A+B
REGARDLESS
GOTO 'A1'
OTHERWISE
GOTO 'A2'

Defining the System


• A SIMSCRIPT program with a preamble section that define the structure and
establishes the condition under which simulation will run.
• Names must be given to every entity and its attributes.
• Items in the SIMSCRIPT list can be separated by commas or the word AND.
• Variables can be real, integer or alphabetical. It is possible to process character strings,
in what is called the TEXT mode of operation.
• The statement
NORMALLY, MODE IS INTEGER (or ALPHA)

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

• If the mode is other than the normal mode(INTEGER), DEFINE statement list the
variable and declares their mode as follows:
DEFINE name1, name2,…. AS INTEGER VARIABLES
If the DEFINE statement does not mention the mode, the variables are taken to be in
the normal mode.
• Events are represented by individual routine which consists of local variable so they
need not be defined in preamble i.e. beginning . Note only global variable are defined
in the preamble.
• The permanent entities temporary entities and the event notices are defined in the list,
following the statement PERMANENT ENTITIES, TEMPORARY ENTITIES and
EVENT NOTICES respectively . Then it is followed by the statement of the form :
EVERY entity HAS A attr.1 AND A attr.2…
• If any SIMSCRIPT statement needs to go beyond 80 characters it can be extended to
another line.
• The event notices can also carry data, if needed ,the attributes are defined with a list of
EVERY statements following EVENT NOTICES statement.
• If an array or multidimensional table is needed, A DEFINE statement, giving the name
of the entity , defines the dimensions, in addition to declaring the format, if that is
necessary . For example:
DEFINE table AS AN INTEGER ,n-DIMENSIONAL VARIABLE
Example: Defining the Telephone System Model
• In telephone system simulation for lost call , telephone lines are permanent entities and
has attributes to indicate whether the line is busy or not . So the name TLINE is used
to represent the telephone line and the attribute will be called STATE. STATE is simply
an integer variable which take value 0 to indicate free and 1 to indicate busy state.
• Calls are represented by temporary entities , with two attributes for carrying the origin
and destination.
• The temporary entities has two attributes for recording the origin and destination of the
call.

The preamble for model 1 of the telephone system actually shows part of the printed
output of compilation, which lists the input.

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

• Line 1 is a comment and PREAMBLE means introduction statements for input on


compilation.
• Line 3 , define normal mode as an INTEGER.
• Three events routines are given, so there will be three event notice. Lines 4 and 5 define
the event notice.
• The event notice name and event routine name must be same. Here in this case, the
routine are going to be called ARRIVAL, DISCONNECT and CLOSING.
• Here, the ARRIVAL and CLOSING event notices do not need attribute/ parameter,
their definition is included in the event notice header.
• The DISCONNECT routine however, will need to know which particular call is to
disconnected, so the DISCONNECT event notice needs an attribute/parameter with
which to identify a call.

Referencing Variable:
• Single variables are simply referenced by using their name.
• Permanent entities such as telephone line, are respected by arrays, with an array of
attribute, identified by the attribute name. It's because they are fixed/ static in nature.
• Temporary entities and event notices are created and destroyed as simulation proceeds
so they can't be kept in fixed table.
• For example, CREATE A CALL and DESTROY A CALL , for each creation , the
program refers to data structure given in preamble and creates a block of words. Since
the number of block will fluctuate, they can't be kept in fixed table.
• So every type of temporary entity , or event notice, the system automatically reserves a
location by holding a pointer that has the same name as the entity or notice. When a
CREATE statement is used , the pointer to the entity or notice being created is placed
at that location. For example , the command CREATE CALL , puts the pointer to the
created record in a location called CALL.
• If during the current execution of a routine, it is necessary to create a second copy of
an entity or notice, the second creation will write over the pointer to the first unless
another form of CREATE statement is used. This take the form CREATE A CALL
CALLED name, the pointer to the created record then goes to the location called name.
• Also, SIMSCRIPT allow the formation of set linking groups of temporary entities
having a common property . The set are organized as list structure. Every individual
temporary entity that might belong to the set has two word push aside as pointer for
identifying its predecessor and successor in the set.

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

The MAIN ROUTINE

figure: Telephone system – model 1, MAIN routine


Explanation: Above program is for a single run only. If the simulation were to be run for many
cases, programming could be established to read an input and execute a simulation repeatedly.
• Line 1 identifies the program section, to initialize a run.
• Line 2 reads in five values, the values prepared in free format. N.TLINE (number of
telephone line), MAX.LINKS(maximum no of links), INTER.ARRIVAL.TIME,
MEAN.LENGTH(inter-arrival time of jobs/customers), STOP.TIME(simulation end
time for entity)
• Line 3, the CREATE statement is needed to establish the array.
• Selecting of lines for the origin and destination of a call is to pick a line number at
random, with a uniform distribution.
• Lines 4 through 7 illustrate how conditions can be programmed by making the test
relating the numbers of lines and links.
• Line 4, is an IF statement , if it is true, the program executes line 5. This calls for the
printing of a remark, and leads to line 6 which stops the simulation.
• If , IF statement is false, the program advances to the next ELSE statement, and
continues execution from that point.
• Line 8 is a SCHEDULE statement , calling for the creation of an ARRIVAL event
notice. Also , must specify the time at which the event is to occur and specify an
immediate execution. The SCHEDULE statement will file the event notice for later
execution.
• Line 9, is also a SCHEDULE statement, this time calling for a CLOSING event at the
STOP.TIME that was read as part of the input.
• Line 10 , initialize simulation and the MAIN routine calls for execution of the
simulation. Control will then pass from the MAIN routine to an internal routine that
executes the events of the simulation.

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

• The simulation will proceed by executing events until the time for the CLOSING event
is reached, to end the simulation. At that point control returns to the MAIN routine at
the statement following the one that started the simulation.
• Lines 14 through 19 define the report. The output lists the conditions under which the
simulation is stopped by the statement at line 20.
• As with all SIMSCRIPT routines, an END statement is needed to indicate the physical
end of the routine definition.

figure: Telephone system – model 1, output report

The Arrival Event

The Disconnect Event

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

The Closing Event

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

Some old Questions:


1. How does initial bias make an adverse effect? Discuss about the process of eliminating
initial bias effect.
2. When data gets biased at the beginning of the analysis it need to be removed , what are
the process to remove it?
3. When simulation process is to be repeated, which output analysis method is preferred?
4. Why output analysis is significant in simulation, how is it done in estimation method?
5. What is initial bias? What are different method to remove initial bias?
6. Illustrate and explain Simulation run statistics. Provide details regarding SSQM(single
Server Queue Model i.e. M/M/1 ).
7. Illustrate and explain Replication of run.
8. Explain mathematical modelling of replication of run
9. For dependent data it is difficult to analysis the output. Which method can we use for
dependent data?
10. Why analysis of output is necessary? Explain nature of problem and elimination of bias.

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

CHAPTER 7: Analysis of Simulation Output


Introduction
Simulation is defined as the process of using a model to study the behavior and performance
of an actual or theoretical system and experimental in nature i.e. we have to take experiment
for many more time , gives different/similar results as output data. So, the main goal is to
analysis output data , to make a valid statistical inference the initial and long-term average
behavior of the system based on the sample average from N replicate simulation runs.
So, Output analysis is to predict system performance or compare the performance of two or
more system designs. Here, maximum simulation system be done on the basis of stochastic
activities , needs multiple runs are always necessary and output results differ i.e. two different
random number streams will produce two sets of output which probably will differ. The
statistical tool mainly used is the confidence interval for the mean.
For most simulations , the output data are correlated and the processes are non-stationary . The
statistical (output) analysis determines:
1. Estimate the mean and variance of random variables
2. The number of observations required to achieve a desired precision of these estimates.

Nature of the Problem


When stochastic variable has been introduced into a simulation model, almost all the system
variables describing the system behavior also become stochastic. Where endogenous event
make one variable depend upon another.
The values of most of the system variables will fluctuate as the simulation proceeds, that makes
difficult to represent the values of a variable. Instead , many observations of the variable values
must be made in order to make a statistical estimate of its true values. Some statement must
also be made about the probability of the true value falling within the given interval about the
estimated value. Such a statement defines a confidence interval, without it simulation result are
of little value to the system analyst.
A large body statistical method has been developing over the years to analyze results in science,
engineering and other fields where experimental observation is made. So, because of the
experimental measurements of the system of simulation for these statistical methods can be
adapted to simulation results to analyze.
Newly Developing Statistical Methodology Concerns:
1. To ensure that the statistical estimates are consistent , meaning that as the sample size
increases the estimate tend to a true value.
2. To control biasing in measure of both mean values and variance . Bias causes the
distributions of estimates based on finite samples differ significantly from the true
population statistics, even though the estimates may be consistent.
3. To develop sequential testing methods , to determine how long a simulation should be
run in order to obtain confidence in its return.

Estimation Methods
Statistical methods are commonly used on the random variable. Usually , a random variable is
drawn from an infinite population with a finite mean '𝜇' and finite variance '𝜎'. This means ,

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

the population distribution is not affected by the number of samples already made, nor does it
change with time. Also, if the value of one sample is not affected by the value of any other
sample, the random variables are mutually independent. Random variables that meet all these
conditions are said to be independently and identically distributed(i.i.d) . The central limit
theorem can be applied to i.i.d data that hold simulation data.
The theorem states that the sum of n i.i.d. variables, drawn from a population that has a mean
of '𝜇' and a variance of ' 𝜎2 ' , is approximately distributed as a normal variable with a mean of
n 𝜇 and a variance of n 𝜎2.
Let xi( i = 1,2,3,……) be the n i.i.d random variables. Using Central limit theorem:
∑𝑛
𝑖=1 𝑥𝑖 −𝑛𝜇
z=
√𝑛𝜎
𝑥̅ −𝜇
z= 𝜎
√𝑛

The variable 𝑥̅ is sample mean. It can be a consistent estimator for the mean of the population
from which the sample is drawn. since the sample mean is the sum of random variables, it is
itself a random variable. So, a confidence interval about its computed value needs to be
established.
The probability density function on the standard normal variable (z) is shown in the figure
below.

The integral form –∞ to a value 𝜇 is the probability that z is less than or equal to 𝜇 and is
denoted by 𝜑(𝜇).
Let us consider the value of 𝜇 is chosen so that 𝜑(𝜇) = 1-𝛼/2 , where 𝛼 is some constant less
than 1 , and denote this value of 𝜇 by 𝜇𝛼/2 . Then probability that z > 𝜇𝛼/2 = 𝛼/2 .

The normal distribution is symmetric about its mean, so the probability that z < - 𝜇𝛼/2 = 𝛼/2.
Therefore the probability that z lies between - 𝜇𝛼/2 and 𝜇𝛼/2 is:

P{- 𝜇𝛼/2 ≤ z ≤ 𝜇𝛼/2 } = 1- 𝛼

In terms of the sample mean, this probability statement can be written:


𝜎 𝜎
P{𝑥̅ + ≥ 𝜇 ≥ 𝑥̅ - } = 1- 𝛼
√𝑛 √𝑛

The constant 1- 𝛼 (usually expressed as a percentage) is the confidence level and the interval
𝜎
𝑥̅ ± 𝜇𝛼/2 is the confidence interval. The size of confidence interval depends upon the
√𝑛
confidence level chosen. Typically , the confidence level might be 90% in which case is 1.65.
𝜎
Then confidence interval 𝑥̅ ± 1.65 with probability 0.9; meaning that , if the experiment is
√𝑛

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

repeated many times, the confidence interval can be expected to cover the value 𝜇 on 90% of
the repetitions.
In practice , the population variance is not usually known: in which case, it is replaced by an
estimate calculated from the formula:
1
s2 = ∑𝑛𝑖=1(𝑥𝑖 − 𝑥̅ )2
𝑛−1

Simulation Run Statistics


When simulation proceeds , some statistics measure based on some assumption: It is assumed
that the observations are mutually independent, and it is assumed that the distribution from
which they are drawn is stationary. But many statistics of interest in a simulation do not meet
these conditions. To illustrate the problems that arise in measuring statistic from a simulation
run with the example of a single server system i.e. M/M/1.
M/M/1 is Queue model in which arrival is Poisson distribution(i.e. inter-arrival is exponential
distribution) , service time is exponential distribution and queue discipline is FIFO with single
server. Let the study objective is to measure the mean waiting time.
In a simulation run, the simplest approach is to estimate the mean waiting time by accumulating
the waiting time of n successive entities and dividing by n. The sample mean , is denoted by
𝑥̅ (n) to emphasize the fact that its value depends upon the number of observations taken.
1
𝑥̅ (n) = ∑𝑛𝑖=1 𝑥𝑖 where xi (i=1,2,……) are the individual waiting times
𝑛

But waiting times measured this way are not independent because whenever a waiting line
forms, the waiting time of each entity on the line depends upon the waiting time of its
predecessor (i.e. the entities are autocorrelated).
The usual formula for estimating the mean value of the distribution remains on satisfactory
estimate for the mean of autocorrelated data. However, the variance of autocorrelated data is
𝜎2
not related to the population variance by simple expression as occurs for independent data.
𝑛

Another problem is that the distribution may not be stationary; it is because a simulation run is
started with the system in some initial state, frequently the idle state, in which no service is
being given and no entities are waiting, thus the early arrivals have a more probability of
obtaining service quickly. So a sample mean that includes the early arrivals will be biased. As
the length of the simulation run extended and the sample size increases, the effect of bias will
die out.

figure: Mean wait time in M/M/1 system for different sample sizes

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

Above figure shows how the expected value of the sample mean depends upon the sample
length, for the M/M/1 system, starting from an initial empty state, with a server utilization of
0.9. Also steady state mean in this case is 8.1. Where mean value is biased below the steady
state value. The bias diminishes as the sample size increases but , even with a sample size of
2,000 , the mean has still only reached about 95% of the steady state value.

Replication of Runs
This approach is used to obtain independent results by repeating simulation. Repeating the
experiment with different random numbers for the same sample size n gives a set of
independent determinations of the sample mean 𝑥̅ (n) .
Even though the distribution of the sample means depends upon the degree of autocorrelation,
this independent determination of sample mean can be used to estimate the variance of the
distribution.
Suppose the experiment is repeated p times with independent random number series. Let xij be
the ith observation in the jth run. Then,
1
Estimates for sample mean , 𝑥̅ j(n) = ∑𝑛𝑖=1 𝑥𝑖𝑗
𝑛
1
Estimates for variance, s2j = ∑𝑛𝑖=1[𝑥𝑖𝑗 − 𝑥𝑗 (𝑛)]2
𝑛−1

Combining the results of p independent measurements gives the following estimates for the
mean waiting time, 𝑥̅ , and the variance, s2 , of the population.
1
𝑥̅ = ∑𝑝𝑗=1 𝑥̅𝑗 (𝑛)
𝑝

1
s2 = ∑𝑝𝑗=1 𝑠𝑗2 (𝑛)
𝑝

The value of is an estimate for the mean waiting time, and s2 can be used to establish a
confidence interval.

Elimination of Initial Bias


There are two general approaches that can be used to remove the initial bias:
1. The system can be started in more representative states rather than in the empty state.
2. The first part of the simulation run can be ignored.
First , it is necessary to know the steady-state distribution for the system and select the initial
condition from the distribution . In some simulation studies, particularly of existing systems,
there may be information available on the expected conditions that makes it feasible to select
better initial conditions and thus eliminating the initial bias.
Second ,the most common approach to removing initial bias is to eliminate an initial section of
the run. In this method, the initial section of the run which has a high bias(simulation) result is
eliminated.
The run is started from an idle state and stopped after a certain period of time. The entities
existing in the system at that are left as they are and this point is the of a restart for other
repeating simulation runs. The run is then restarted with statistics being gathered from the point
of restart.

Downloaded by Kanchan Shrestha ([email protected])


lOMoARcPSD|50663938

These approaches have the following difficulties:


1. No simple rules can be given to deciding how long an interval should be eliminated.
For this, we have to use some pilot run starting from the ideal state to judge how long
the initial bias remains. These can be done by plotting the measured, statistics against
the run length.
2. Another disadvantage of eliminating the first part of the simulation run is that the
estimate of variance will be based on less information affecting the establishment of
confidence limit. These will then cause to increase in confidence interval size.
How does initial bias make an adverse effect? Discuss about the process of eliminating initial
bias effect.
Answer: Initial bias is a condition to choose initial values for the state variables that are not
representative of the steady state distribution. Similarly, steady-state is a situation where all
state variable are constant i.e. no further value of state variable changes. When simulation run
started with some initial state , frequently the idle state, in which no service is being given and
no entities are waiting. So , early arrival don't need to wait for service than normal probability
of obtaining service quickly. So, a sample mean that includes the early arrivals will be biased.
Also , if the distributions could be compared for different sample sizes, the distributions would
be slightly different. Therefore , if initial bias not resolve it shows adverse effect. i.e. results
will be vary .
There are two general approaches that can be used to remove the initial bias:
1. The system can be started in more representative states rather than in the empty state.
2. The first part of the simulation run can be ignored.
(Explain from above topic Elimination of Initial Bias)

Downloaded by Kanchan Shrestha ([email protected])

You might also like