Simulation Notes
Simulation Notes
System Concept:
The term system is derived from the Greek word Systema, which means an organized relationship
between functioning units or components. It is aggregation or association of objects joined in some
regular manner/interactions or independence. The interaction/independence between the objects
causes a change in the system. The system exists because it is designed to achieve one or more
objectives. There are more than a hundred definitions of the word system, but most seem to have
a common thread that suggests that a system is an orderly grouping of interdependent components
linked together according to a plan to achieve a specific objective.
As shown in the above figure, two major components of the systems are the fabrication department
making the parts and the assembly department producing the products. A purchasing department
maintains a supply of raw materials and a shipping department dispatches the finished products. A
production control department receives orders and assigns work to the other departments.
Components of System:
1. Entity:
An entity is an object of interest in a system. Example: In the factory system, departments, orders,
parts, and products are the entities.
An attribute denotes the property of an entity. Example: Quantities for each order, type of part, or
several machines in a Department are attributes of the factory system.
3. Activity:
Any process causing changes in a system is called an activity. Example: Manufacturing process of
the department.
The state of a system is defined as the collection of variables necessary to describe a system at any
time, relative to the objective of study. In other words, the state of the system means a description
of all the entities, attributes and activities as they exist at one point in time.
5. Event:
An event is defined as an instantaneous occurrence that may change the state of the system.
State
System Entities Attributes Activities Events Variables
No. of busy
Balance, tellers, No. of
Credit Depositing, Arrival, customers
Bank Customers Status Withdrawal Departure waiting
Status of
machine (busy,
Speed, Welding, idle or down)
Production Machines Capacity Stamping Breakdown
Number
Length, Arrival at waiting to be
Communication Messages Destination Transmitting destination transmitted
a. Traffic System
b. Telephone System
c. Supermarket System
d. Transportation Operation System
e. Hospital Facilities System and so on.
System Environment:
Everything that remains outside of the system under Consideration is called system environment.
The system is often affected by change occurring outside the environment. Some system activity
may also produce changes that don’t react on the system (but react outside the system). Such
changes occurring outside the system is said to occur in the system environment.
When we are going to model the system, we must decide the boundary between the system and
the environment. This decision depends on the purpose of the system study. In the case of the
factory system, factors controlling the arrival of the order may be considered to be the influence of
the factory (i.e. part of the environment). However, if the effect of the supply and demand is to be
considered, there will be a relationship between the factory output and arrival of the order and this
relationship must be considered as the activity of the system.
System Types:
1. Closed System:
If any system shows endogenous activity then the system is said to be a closed system. A
closed system is one where there is no interaction between the environment and the system
components.
If any system shows exogenous activity then the system is said to be an open system. The term
exogenous is used to describe the activity in the environment that affects the system.
3. Isolated System:
The system, which is isolated from the external world (environment) is called an isolated system.
System Activities:
1. Endogenous Vs. Exogenous Activity:
The term endogenous is used to describe the activity that occurs within the system (activity occurs
within an entity of system). And if there is only endogenous activity then the system is said to be
a closed system. The term exogenous is used to describe the activity in an environment that affects
the system. Hence system, where there is an exogenous activity, is called an open system.
If the outcome of the activity/system can be described in terms of the input (in terms of some
mathematical function/formulae) then the activity is deterministic activity. When the effect of
(outcome) of the activity vary over possible outcomes (can’t be predicted using some mathematical
function) then the activity is called stochastic activity. The randomness of the stochastic activity
is the part of the system environment because the exact outcome at any time is unknown. However,
the random output can be measured and described in a probability distribution.
Those systems whose state variable changes instantly at separate points in time is a discrete system.
Example: Bank System. State variable: Number of customers.
Conclusion:
Due to these reasons in a bank, the number of customers may arrive only when a new customer
arrives or leaves the bank. Here, the changes in the number of customers are in discrete time.
Therefore, a bank can be taken as an example of a discrete system.
2. Continuous System:
Those systems whose state variables change continuously concerning time is a continuous system.
Example: Aeroplane moving through the air. State variable: position and velocity.
Conclusion:
Here, the position of the Aeroplane is changing continuously with time. Therefore, an Aeroplane
moving through the air is an example of a continuous system.
A model of a system is a set of assumptions and approximations about how the system works and
the task of deriving a model of a system is called system model. Since the purpose of the study will
determine the nature of the information that is gathered, there is no unique model of a system.
Different model of the same system will be produced by different analysts interested in different
aspect of the system or by the same analyst as his understanding of the system changes. Studying
a model instead of a real system is usually much easier, faster, cheaper and safer.
Deriving a Model:
A model of a system can be derived in the following two ways:
It determines the system boundary, entities, attributes, activities and state of a system.
2. Supplying Data:
In this phase, the values are provided to the system attributes that can have and relationships involve
in the activities are defined.
The assumption about the system directs the gathering of data, and analysis of the data confirms
the assumption. To illustrate this process, we consider the description of a supermarket.
Shoppers needing several items of shopping arrive at a supermarket. They get a basket, if one
available, carry out their shopping, and then queue to check-out at one of several counters.
After checking out, they return the basket and leave.
Here, in the assumption of the supermarket system, some keywords are made italic to point out the
features of a system that must be reflected in the model. In this system, the entities are shopper,
basket and counters. The attributes are the number of items, availability, and number of occupancy.
The activities are arriving at the supermarket, getting a basket, returning a basket and leaving the
supermarket.
Types of Models:
1. Physical Model:
In a physical model of a system, the system attributes are represented by measurement such as
voltages or position of shafts. Here, the system activities are deflected in physical logic that derives
a model. For example, the rate at which the shaft of the dc motor turn depends upon voltage applied
to the motor. If the applied voltage is used to represent the velocity of the vehicle, then the number
of revolution of the shaft is a measure of the distance the vehicle has travelled.
2. Mathematical Model:
This model uses symbolic notation and mathematical equation to represent a system. In this model,
attributes are represented by variables and activities are represented by a mathematic function that
inter-relates variables.
This model can only show the values that system attributes takes when the system is in balance.
4. Dynamic Model:
This model can show the values of the system attributes that changes over time due to the effect
of the system attributes.
Once a mathematical model is built, it must be then examined to see how it can be used to answer
the question of interest in the system. The two methods that are used to solve the mathematical
model are:
i. Analytical Methods:
If the model is simple enough, it may be possible to work with its relationship and quantities to get
an exact analytical method. This method uses the deductive region of mathematical theory to solve
a model. It directly produces a general solution.
Let us consider the , if we know the distance to be travelled and velocity , then we can work with
the model to get as the time that will be required.
Principle of Modeling:
It is not possible to provide rules by which mathematical models are built, but several guiding
principles can be stated. They do not describe distinct steps carried out in building a model. They
describe different viewpoints from which to judge the information to be included in the model.
1. Block Building:
The description of the system should be organized in a series of blocks. The aim of constructing
the blocks is to simplify the specification of the interactions within the system. Each block
describes a part of the system that depends upon a few, preferably one, input variables and results
in a few output variables. The system as a whole can then be described in terms of the
interconnections between the blocks. Correspondingly, the system can be represented graphically
as a simple block diagram.
2. 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 the study aims to compare the effects of
3. Accuracy:
The accuracy of the information gathered for the model should be considered. In an aircraft system,
the accuracy with which the movement of aircraft is described depends upon the representation of
the airframe. If these are not accurate it gives a false result while testing a system for output.
4. Aggregation:
A further factor to be considered is the extent to which several individual entities can be grouped
together into larger entities.
Areas of Application:
System simulation is a technique, which finds application in almost each and every field. Some of
the areas in which it can be successfully employed are listed below:
1. Manufacturing:
Design analysis and optimization of the productions system, materials management, capacity
planning, layout planning and performance evaluation, evaluation of process quality.
2. Business:
Testing of alternative combat strategies, air operations, sea operations, simulated war exercises,
practicing ordinance effectiveness, and inventory management.
4. Healthcare Application:
Such as planning health services, expected patient density, facilities requirement, hospital staffing,
estimating the effectiveness of a health care program.
5. Communication Application:
Such as network design and optimization, evaluating network reliability, manpower planning,
sizing of message buffers.
6. Computer Application:
Such as designing hardware configuration and operating systems protocols, sharing, and
networking.
7. Economic Application:
Such as portfolio management, forecasting the impact of Govt. Policies and internal market
fluctuations on the economy, budgeting and forecasting market fluctuation.
8. Transport Application:
Design and testing of alternative transportation policy, transportation network- road, railways,
airways, etc., evaluation of timetables, traffic and planning.
Verification:
Verification focuses on the internal consistency of a model. Verification checks that the
implementation of the simulation model (program) corresponds to the model. It concerns with the
building the model right. It is utilized in the comparison of the conceptual model to the computer
representation that implements the conception. It asks the question, is the model implemented
correctly in the computer? Are the input parameters and logical structure of the model correctly
represented? It is the process of comparing the computer code with the model to ensure that the
code is a correct implementation of the model.
Validation:
Validation is concerned with the correspondence between the model and the reality. Its concern
with building the right model. It is utilized to determine that a model is an accurate representation
of the real system. Validation is usually achieved through the calibration of the model, an iterative
process of comparing the model to actual system behaviour and using
Calibration:
It is an iterative process of comparing the model to the real system, making adjustments or major
changes to the model, comparing the revised model to reality, making additional adjustments,
comparing again and so on. It Checks that the data generated by the simulation matches real
(observed) data. The process of parameter estimation for a model. Calibration is a tweaking/tuning
of existing parameters and usually does not involve the introduction of
Simulation can be defined as the process of designing a model of a real system and conducting an
experiment with these models of system and, or evaluating various strategies for the operation of the
system. Thus, it is important that the model we design in such a way, model behaviour mimics the
behaviour of a real system.
Simulation allows us to study the situation even though we are unable to experiment directly with the
real system, either the system doesn’t exist or it is too difficult or expensive to directly manipulate
it.
We consider the simulation to include both constructions of the model and experimental use of the
model for studying problems. Thus, we can think of simulation as an experiment and applied
methodology which seeks to:
Advantages:
Simulation has several advantages. First of all basic concept of simulation is easy to understand
and hence often easier to justify to management or customer than some of the analytical methods.
Also, a simulation model may be more. Because its behaviour has been compared to that of a real
system or because it requires fewer simplifying assumptions and hence captures more of true
characteristics of the system understudied.
e. It allows us to control time. Thus we can operate the system several month
or years of experience in a matter of seconds allowing us to quickly look at a
long time or we can slow down the phenomenon for study.
f. It allows us to gain insights into how a model the system actually works and
understanding of which variables are most important up to a performance.
g. Its great strength is its ability to let us experiment with new and unfamiliar
situations.
Disadvantages:
Even though simulation has many strengths and advantages, it is not without drawbacks. And
some are:
a. Simulation is an art that requires specialized trainers and therefore, skill labels
of practice vary widely. The utility of the study depends upon the quality of the
model and the skill of the models.
b. Gathering highly reliable input data can be time consuming and the resulting
data is sometimes highly comprised of insufficient data or poor management
decisions.
c. Simulation models are input and output models i.e. they yield the portable
output of the system for a given input. These are, therefore, run rather than
solved. They do not yield optional rather they serve as a tool for analysis of the
behaviour of a system under conditions specified by the experiments.
This method was first used by scientists working on the atom bomb in 1940. This method can be
used in those situations where we need to make an estimate and uncertain decisions such as weather
forecast predictions.
Important Characteristics:
Following are the three important characteristics of Monte-Carlo method.
a. Its output must generate random samples.
b. Its input distribution must be known.
c. Its result must be known while performing an experiment.
a. Easy to implement.
b. Provides statistical sampling for numerical experiments using the computer.
c. Provides an approximate solution to mathematical problems.
d. Can be used for both stochastic and deterministic problems.
Disadvantages:
Flow Diagram:
The following illustration shows a generalized flowchart of Monte Carlo simulation.
For example, we shall consider the problem taking integral of a single variable over a range which
corresponds to finding the area under graph representing the function f(x). Let us suppose that f(x)
is positive and has a and b as bounds above by c. Then as shown in the figure, the function f(x)
will be contained within the rectangle of sides c and (b-a). Now, we can pick up points at random
within the rectangle and determine whether they lie beneath the curve or not. The points selected
are assumed to be obtained from a uniformly distributed random number generator. Two successive
samplings are made to get X and Y coordinates so that X is in the range a to b and Y is in the range 0
to c. The fraction of points that fall or below the curve will be approximately the ratio of the area under
the curve to the area of the rectangle. If N points are drawn and n of them fall under curve then;
Here,
Curve = f(x),
n=randomly selected points laying inside the curve,
N=total numbers of points selected,
Area of rectangle=c*(b-a) Now
we have;
The computational technique is shown in the figure. At each trial, the value of x is selected at random
between ‘a’ and ‘b’, say X0. Similarly, the second random number is selected between 0 and C to give y.
If y <= f(x0) then point is inside the curve and count ‘n’ otherwise point will not lie in the curve and
the next point will be picked.
The application of the Monte Carlo Method for evaluation of Pi (π) is converting a deterministic
model into a stochastic model. Some examples that use random sampling in problem-solving are as
follows:
a. To find the area of irregular surface figure
b. Numerical Integration of single-variable function
c. A Gambling Game.
d. Random Walk Problem
Example:
We have circle equation = x2 + y2 = 1 or y = √(1 - x²) Now, generate the random numbers x and y
within the interval 0 and 1.
For x: x0 = 27, a = 17, c = 0, m = 100
For y: y0 = 47, a = 17, c = 0, m = 100
X’ Y’ √(1 - x²) In/Out
0.59 0.99 0.962 In
0.03 0.83 0.99 In
0.51 0.11 0.86 In
0.67 0.87 0.74 Out
Now,
Points inside the curve (n) = 3
Points inside the rectangle (N) = 4
Value of pi = (n/N)*4
=3
Here, the area of the rectangle under the given condition = (5 - 2) * (125 - 8) = 351, also we know, I =
n/N * area of rectangle
Now, we can select the random points inside the curve (using the random number generation method).
For x: x0 = 23, a = 17, c = 0, m = 50
Fir y: y0 = 61, a = 59, c = 0, m = 125
X X’ = X*0.1 Y X’3 In/Out
23 2.3 59 12.167 Out
41 4.1 99 68.921 Out
47 4.7 91 103.823 In
49 4.9 119 117.649 Out
33 3.3 21 35.937 In
11 1.1 114 1.331 Out
37 3.7 101 50.653 Out
We get,
Points inside the curve (n) = 2
Points inside the rectangle (N) = 6 I
= n/N * area of rectangle
I = 2/6 * 351
I = 117
In the d = v*t example, if we know the distance to be travelled and the velocity, then we can work
with the model to get t = d/v as the time that will be required. This is a very simple, closed-form
solution obtainable with just paper and pencil, but some analytical solutions can become
extraordinarily complex, requiring vast computing resources; inverting a large non- sparse matrix is a
well-known example of a situation in which there is an analytical formula known in principle, but
obtaining it numerically in a given instance is far from trivial.
While there may be an element of truth to pejorative old saws such as “method of last resort”
sometimes used to describe simulation, the fact is that we are very quickly led to simulation in many
situations, due to the sheer complexity of the systems of interest and of the models necessary to
validly represent them.
Given, then, that we have a mathematical model to be studied using simulation (henceforth referred
to as a simulation model), we must then look for particular tools to execute this model (i.e. actual
simulation).
1. Live:
Simulation involving real people operating real systems.
a. Involve individuals or groups
b. May use actual equipment
c. Should provide a similar area of operations
13 |Simulation & Modeling
d. Should be close to replicating the actual activity
2. Virtual:
Simulation involving real people operating simulated systems. Virtual simulations inject
Human-In-The-Loop in a central role by exercising:
a. Motor control skills (e.g. flying an aeroplane)
b. Decision skills (e.g. committing fire control resources to action)
c. Communication skills (e.g. members of a C4I team)
3. Constructive:
Simulation involving simulated people operating simulated systems. Real people can stimulate
(make inputs) but are not involved in determining outcomes. Constructive simulations offer the
ability to:
a. Analyze concepts
b. Predict possible outcomes
c. Stress large organizations
d. Make measurements
e. Generate statistics
f. Perform analysis
In economic studies, some economic data are collected over uniform time intervals such as a month
or year. This model consists of linear algebraic equations that represent continuous system but data
are available at fixed points in time.
Let,
C = Consumption
I = Investment
T = Taxes
G = Government Expenditures
Y = National Income
Then
C = 20 + 0.7 (Y – T)
I = 2 + 0.1 Y
15 |Simulation & Modeling
T = 0.2 Y
Y=C+I+G
All the equation are expressed in billions of rupees. This is static model and can be made dynamic
by lagging all the variables as follows:
C = 20 + 0.7(Y-1 – T-1)
I = 2 + 0.1Y-1
T = 0.2Y-1
Y = C-1 + I-1 + G-1
Any variable that can be expressed in the form of its current value and one or more previous value is
called a lagging variable. And hence this model is given the name distributed lag model. The
variable in a previous interval is denoted by attaching –n suffix to the variable. Where -n indicates
the nth interval.
Cobweb Model:
Cobweb theory is the idea that price fluctuations can lead to fluctuations in supply which cause a
cycle of rising and falling prices.
In a simple cobweb model, we assume there is an agricultural market where supply can vary due to
variable factors, such as the weather.
b. A key determinant of supply will be the price from the previous year.
c. A low price will mean some farmers go out of business. Also, a low price
will discourage farmers from growing that crop in the next year.
4. If farmers see high prices (and high profits), then next year they are
inclined to increase supply because that product is more profitable.
In theory, the market could fluctuate between high price and low price as suppliers responds to past
prices.
If the slope of the supply curve is less than the demand curve, then the price changes could become
magnified and the market more unstable.
At the equilibrium point, if the demand curve is more elastic than the supply curve, we get the price
volatility falling, and the price will converge on the equilibrium
The model assumes farmers base next year’s supply purely on the previous price and assume that next
year’s price will be the same as last year (adaptive expectations). However, that rarely applies in
the real world. Farmers are more likely to see it as a ‘good’ year or ‘bad year and learn from price
volatility.
The idea that farmers only base supply on last year’s price means, in theory, prices could
increasingly diverge, but farmers would learn from this and pre-empt changes in price.
A potato grower may concentrate on potatoes because that is his speciality. It is not easy to give up
potatoes and take to aborigines.
There are many other factors affecting price than a farmers decision to supply. In global markets,
supply fluctuations will be minimized by the role of importing from abroad. Also, demand may vary.
Also, supply can vary due to weather factors.
Governments or producers could band together to limit price volatility by buying surplus.
The study begins with defining the problem statement. It can be developed either by the analyst or
client. If the statement is provided by the client, then the analyst must take extreme care to ensure
that the problem is clearly understood. If a problem statement is prepared by the simulation analyst,
the client must understand and agree with the formulation. Even with all of these precautions, the
problem may need to be reformulated as the simulation study progresses.
Another way to state this step is to "prepare a proposal." The objectives indicate the questions to
be answered by the simulation study. Whether the simulation is appropriate or not is to be decided at
this stage. The overall project plan should include a statement of the alternative systems and a
method for evaluating the effectiveness of these alternatives. The plan includes several personnel,
number of days to complete the task, stages in the investigation, output at each stage, cost of the
study and billing procedures if any.
3. Model Conceptualization:
Maintaining client involvement will enhance the quality of the resulting model and increase the
client's confidence in its use.
4. Data Collection:
This step involves gathering the desired input data. The data changes over the complexity of the
model. Data collection takes a huge amount of total time required to perform a simulation. It should
be started at early stages together with model building. The collection of data should be relevant to
the objectives of the study.
5. Model Translation:
The conceptual model constructed in Step 3 is coded into a computer recognizable form, an
operational model. The suitable simulation language is used.
6. Verified:
Verification is concerning the operational model. Is it performing properly? If the input parameters
and logical structure of the model are correctly represented in the computer, then verification is
completed.
7. Validated:
Validation is the determination, that the model is an accurate representation of the real system. This
is done by calibration of the model; an iterative process of comparing the
8. Experimental Design:
The alternatives to be simulated must be determined. For each the scenario that is to be simulated,
decisions need to be made concerning the length of the simulation run, the number of runs (also
called replications), and the length of the initialization period.
The production runs, and their subsequent analysis is used to estimate measures of performance
for the system design that is being simulated.
After the completion of the analysis of runs, the simulation the analyst determines if additional
runs are needed and any additional experiments should follow.
There are two types of Documentation: Program and Progress. Program documentation is necessary
for numerous reasons. If the program is going to be used again by the same or different analysts,
it may be necessary to understand how the program operates. This will enable confidence in the
program so that the client can make decisions based on the analysis. Also, if the model is to be modified,
this can be greatly facilitated by adequate documentation. Progress reports provide a chronology of
work done and decisions made. It is the written history of a simulation project. The result of all the
analyses should be reported clearly and concisely. This will enable the client to review the final
formulation.
If the client has been involved throughout the study period, and the simulation analyst has followed
all of the steps rigorously, then the likelihood of a successful implementation is increased.
Simulation time means the integral clock time and not the time a computer was taken to carry out the
simulation. Two principal approaches for advancing the simulation clock are:
a. Next Event Time Advance
b. Fixed Increment Time Advance
These predictions help us to anticipate situations and to take appropriate measures to shorten the
queues.
A further attractive feature of the theory is quite an astonishing range of its applications. Some of
the more prominent of these are telephone conversation, machine repair, toll booths, taxi stands,
inventory control, the loading, and unloading of ships scheduling patients in the hospital clinics,
production flow and applications in the computer field concerning program scheduling, etc.
A queuing system may be described as one having a service facility, at which units of some kind
(called customers) arrive for service and whenever there are more units in the system than the service
facility can handle simultaneously, a queue or waiting line develops. The waiting units take their
turn for service according to a pre-assigned rule and after service, they leave the system. Thus, the
input to the system consists of the customers demanding service and the output is the serviced
customers.
The arrival pattern describes how a customer may become a part of the queuing system. The arrival
time for any customer is unpredictable. Therefore, the arrival time and the number of customers
arriving at any specified time intervals are usually random variables. A Poisson distribution of arrivals
corresponds to arrivals at random. In Poisson distribution, successive customers arrive after intervals
which independently are and exponentially distributed. The Poisson distribution is important, as it is
a suitable mathematical model of many practical queuing systems as described by the parameter
“the average arrival rate”.
The service mechanism is a description of the resources required for service. If there are an infinite
number of servers, then there will be no queue. If the number of servers is finite, then the customers are
served according to a specific order. The time taken to serve a particular customer is called the
service time. The service time is a statistical variable and can be studied either as the number of
services completed in a given time or the completion period of service.
The most common queue discipline is the “First Come First Served” (FCFS) or “First-in, First- out”
(FIFO). Situations like waiting for a haircut, ticket-booking counters follow FCFS discipline. Other
disciplines include “Last In First Out” (LIFO) where the last customer is serviced first, “Service
In Random Order” (SIRO) in which the customers are serviced randomly irrespective of their
arrivals. “Priority service” is when the customers are grouped in priority classes based on urgency.
“Preemptive Priority” is the highest priority given to the customer who enters into the service,
immediately, even if a customer with lower priority is in service. “Non-preemptive priority” is
where the customer goes ahead in the queue but will be served only after the completion of the
current service.
On the other hand, if a service system can accommodate any number of customers at a time, then it is
referred to as an infinite (or unlimited) source queue. For example, in a sales department, where
the customer orders are received; there is no restriction on the number of orders that can come in so
that a queue of any size can form.
1. Estimate the expected average delay in a d(n) queue of (n) customers. The
actual average delay for n customers depends on the inter-arrival and service
time. From a single sum of simulation with customers delays D1, D2… Dn, the
estimate of d(n) is given by:
This estimate of d(n) gives information about the system performance form the customer point of
view.
2. Estimate the expected average number of customers in the queue (but not
being served), denoted by q(n). It is different from the average delay in the
queue because it takes over continuous time rather than over the customer
(being discrete).
a. A customer who arrives and finds the server busy, joins the end of the single
queue.
b. After completing service for a customer1, the server chooses the next
customer from the queue (if any) in a FIFO manner.
c. The simulation will begin in the empty and idle state i.e. no customers are
present and the service is idle.
d. At time 0, the system will begin waiting for the arrival of the 1st customer will
occur, after the 1st inter-arrival time A1 rather than at time 0.
Modern modelling and simulation environments relieve the occasional user from having to understand how
simulation really works. Once a mathematical model of a process has been formulated, the modelling and simulation
environment compiles and simulates the model and curves of result trajectories appear magically on the user’s
screen. Yet, magic has a tendency to fail, and it is then that the user must understand what went wrong, and why the
model could not be simulated as expected.
System Dynamics:
SystemDynamicsisa computer-aidedapproachtopolicyanalysisanddesign. Itappliesto dynamic problems arising
in complex social, managerial, economic, or ecological systems, literally any dynamic systems characterized by
interdependence, mutual interaction, information feedback, and circular causality.
c. Thinking of all concepts in the real system as continuous quantities interconnected in loops
of information feedback and circular causality.
d. Identifying independent stocks or accumulations (levels) in the system and their inflows
and outflows (rates).
f. Deriving understandings and applicable policy insights from the resulting model.
g. Implementing changes resulting from model-based understandings and insights.
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.
We can use the differential equation to represent the behaviour of a continuous system. An example of a linear
differential equation with constant coefficient is one that describes the wheel suspension of an automobile.
Where,
x ̈ = acceleration
x ̇= velocity
x = displacement
K = stiffness of spring
D = measure of viscosity (thickness) of shock absorber F(t) = input of
system depends on independent variable t
When more than one independent variable occurs in a differential equation, the equation is said to be a partial
differential equation. It can involve the derivatives of the same dependent variable with respect to each of the
independent variables. An example is an equation describing the flow of heat in a three-dimensional body.
There are four independent variables, 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 a growth rate, continuous models
can also be applied to a
Linear differential equations are the differential equations that are linear in the unknown function and its
derivatives. Their theory is well developed, and, in many cases, one may express their solutions in terms of
integrals.
Most ODE that is encountered in physics are linear, and, therefore, most special functions may be defined as
solutions of linear differential equations.
PDEs can be used to describe a wide variety of phenomena in nature such as sound, heat, electrostatics,
electrodynamics, fluid flow, elasticity, or quantum mechanics. These seemingly distinct physical phenomena can
be formalized similarly in terms of PDEs. Just as ordinary differential equations often model one-dimensional
dynamical systems, partial
Analog Computers:
Analog computers are generally used to solve continuous model but sometimes are also used to solve static models.
Some device whose behaviour is equivalent to a mathematical operation such as addition or integration is
combined together in a manner specified by a mathematical model of a system to allow the system to be simulated.
That combination is used in the simulation of a continuous system is referred to as an analogue computer or when they
are used to solve differential equation they are referred to as differential analyzer.
With appropriate circuits, an amplifier can be made to add several input voltages, each representing a variable of
model, to produce a voltage representing the sum of the input variables. Different scale factors can be used on the
input to represent the coefficient of the model equations. Such amplifiers are called summer. Another circuit
arrangement produces an integrator for which the output is the integral with respect to time of single input voltage or
the sum of several input voltages. All voltages can be positive or negative to correspond to the sign of the variable
represented.To satisfythe equationof the model,it issometimes necessary to use a sing inverter.
Advantages:
b. Computation can be done for some applications without the requirement for transducers
to convert the inputs/outputs to/from digital electronic form.
c. Setup requires the programmer to scale the problem for the dynamic range of the
computer. This can give insight into the problem and the effects of various errors.
Disadvantages:
a. Computation elements have a limited useful dynamic range, usually not much more than
120 dB, about 6 significant digits of accuracy.
b. Useful solution to problems of any size can take an inordinate amount of setup time
(though modern analog computers have interfaces that make setup substantially easier
than it used to be).
d. Solutions appear in real (or scaled) time, and maybe difficult to record for later use or
analysis.
e. The range of useful time constants is limited. Problems that have components operating
on vastly different time scales are difficult to deal with accurately.
With an appropriate circuit, an amplifier made to add several input voltage each representingthe variable
of the model to produce a voltage each representinga sum of the input voltage.
2. Subtractor:
With an appropriate circuit, an amplifier made to subtract several input voltage each representing the variable
of the model to produce the voltage each representing a difference of input voltage.
3. Differentiator:
An op-amp differentiator or a differentiating the amplifier is a circuit configuration which produces output voltage
amplitudethat isproportional to the rate of changeof the applied input voltage.
The circuit arrangement for which the output is integral with respect to time of single input voltage or the sum of
several input voltage.
5. Invertor:
It is an amplifier designed to cause the output to reverse the sign of the input.
6. Scale Factor:
This circuit multiplies each input by a factor (the factor is determined by circuit design) and then adds these values
together. The factor that is used to multiply each input is determined by the ratio of the feedback resistor to the input
resistor.
Analog Method:
The general methods by which analog computer are applied can be demonstrated using the second-order differential
equation given as: Mx ̈+Dx ̇+Kx=KF(t)
Solving the equation for the highest order derivate gives: Mx ̈=KF(t)-Dx ̇-Kx
A block diagram to solve the problem in this manner is shown below. The symbols used in the figure are standard
symbols for drawing block diagrams representing analog computer arrangements. The circle indicates scale factors
applied to the variable. The triangular symbol at the left of the figure represents the operating of the adding
variables. The triangular symbol with a vertical bar represents integration, and the containing a minus sign is a sign
changer.
Draw the analog model of the Liver with following set of equations:
(dx_1)/dt=-k12x_1+k21x_2
(dx_2)/dt=k12x_1-(k21+k23) x_2
(dx_3)/dt=k23x_2
A CSSL include macros or subroutines that forms the function of specific analog elements so that it is possible to
incorporate the convenience of an analog simulator. To allow the users to define special-purpose elements that
correspond to an operation that are particularly important in a specific type of application.
Structural Statement:
It defines the model. They consist of FORTRAN like statement and functional block designed for an operation that
frequently occurs in a model definition. It can make use of the operation of addition, subtraction, multiplication,
division, and exponential using the same notation and rules used in FORTRAN.
Data Statement:
It assigns numeric values to the parameter constant and initial condition.
Control Statement:
Itspecifiestheoptionintheassemblyandexecutionofprogramandthechoiceofoutput. For example, the model
includes the equation: X=6Y/W+(Z-2)^2
The following statement would be used: X=6.0*Y⁄W+(Z-2.0)**2.0
Note that real constants are specified in decimal notation. Exponent notation may also be used; for example, 1.2E-4
represents 0.00012. Fixed value constants may also be declared. Variable names may have up to six characters.
Here,
Structural Statement
Mx ̈=KF(t)-Dx ̇-Kx
x ̈=(KF(t)-Dx ̇-Kx)/M
x_2 dot= 1.0/M [KF(t)-Dẋ-Kx] x_2
dot= 1.0/M[K*F(t)-D*ẋ-K*x]
x_2 dot=(1.0/M)*[K*F(t)-D*x ̇-K*x] x_2
dot=INTGRL (O.O,x_2 dot)
x=INTGRL(0.0,x_1 dot)
Data Statement
M = 3.0
F(t) = 1.0
K = 4.0
Control Statement
DELT (Integral Interval) = 0.05
FINTIME (Finish Time) = 1.5
PRDEL (Integral at which to print result) = 2
Hybrid Statement:
The system to be studied is either continuous or discrete and we have to select the analog or digital computer for the
study of the system. There are many advantages and disadvantages of analog and digital computer. To achieve the
advantages of both (analog and digital computer) we can combine both analog/digital computer system into a
single form and simulate the system through it.
Feedback System:
Feedback systems have a closed-loop structure that brings results from past action of the system back to control
future action, so feedback systems are influenced by their own past behaviour. Extending the blind control example,
a feedback system would be a system that not only opens the blinds when the sun rises but also adjusts the blinds
during the day to ensure the room is not subjected to direct sunlight.
Even though the open system can consist of many parts and thus become very complex (these systems have high
detail complexity), experience shows that the behaviour of even small feedback systems consisting of only a few
parts (and thus low detail complexity) can be very difficult to predict in practice: despite low detail complexity, these
systems have high dynamic complexity. In business prototyping, we deal with both kinds of systems; system
dynamics is particularly good at capturing the dynamics of feedback systems.
Interactive Systems:
Interactive systems are computer systems characterized by significant amounts of interaction between humans
and the computer. Most users have grown up using Macintosh or Windows computer operating systems, which are
prime examples of graphical interactive
Some estimates suggest that as much as 90 percent of computer technology development effort is now devoted to
enhancements and innovations in interface and interaction. To improve efficiency and effectiveness of computer
software, programmers, and designers not only need a good knowledge of programming languages, but a better
understanding of human information processing capabilities as well. They need to know how people perceive screen
colors, why and how to construct unambiguous icons, what common patterns or errors occur on the part of users,
and how user effectiveness is related to the various mental models of systems people possess.
Real-Time Simulation:
Real-time simulation refers to a computer model of a physical system that can execute at the same rate as the actual
"wall clock" time. In other words, the computer model runs at the same rate as the actual physical system. For
example,ifa tanktakes 10minutes to fillinthe real-world, the simulation would take 10 minutes as well.
Predator-Prey Model:
It is also called the parasite-host model. An environment consists of two population i.e. predator and prey. It 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.
r.x(t) =rate of growth of prey for some +ve ‘r’, where r = natural birth anddeath rate.
Where a is positive constant of proportion. Also, the predator population depends on the prey for their existence,
the rate of the predator in the absence of prey is –s.y(t) for some positives.
The interaction between two population cause predator population to increase at a rate of proportion x(t).y(t). Thus,
overall change predator population dy/dt=-s.y(t)-b.x(t).y(t). Where, b is positive constant.
As the predator population increases the prey population decreases. This cause a decrease intherateofanincreased
predator, which eventually results in a decrease in the number of predators. These in turns cause the number of
prey population to increase.
Representation of Time:
It refers to a number that records the passage of time. It is usually set to zero at the beginning of a
simulation and subsequently indicates how many units of simulated time have pass since the
beginning of the simulation.
Simulation Time:
It refers to the indicated clock time, not the time that a computer has taken to carry out the
simulation. The ratio of simulated time to the real-time taken can vary to a great extent depending
on the following factors:
a. Nature of the system being simulated.
b. The detail to which it is modelled.
In these methods, the clock is advanced to the time at which next event is due to occur. Discrete
system simulation is usually carried out by using the event-oriented method.
In these methods, the clock time is advanced by small and usually, a uniform interval of time and
it is determined at each interval whether an event is due to occur at that time. Continuous system
simulation normally uses the interval oriented method. But it should be noted that no firm's (visit)
rule can be made about the way the time is represented in simulation for discrete
and continuous system because:
a. An interval oriented program will detect discrete changes and can, therefore,
simulate a discrete system.
If the initial conditions are known, the elapsed time for each these possible events can be
calculated from a simple formula.
Trace-Driven Simulation:
It refers to the process of gathering a sequence of inputs based on the observation of a system.
When there is no interaction between exogenous arrivals and the endogenous events of a system,
it is permissible to create a sequence of arrival in preparation for the simulation. Usually, however,
the simulation proceeds by creating new arrivals as they are needed.
Bootstrapping:
It is the process of making one entity creates its successor. These methods require keeping only
the arrival time of the next entity, it is, therefore, the preferred method of generating arrivals for
computer simulation programs.
Object of Simulation:
To process a given number of calls and determine what, portion is successfully completed, blocked
or found to be busy calls. Let’s consider the current state of the system as below:
Figure 2
The “call-in progress” tables show the lines that are currently connected and finish time. Arrival
time and detail of next call are also shown to generate the arrival of calls; here bootstrap method
can be used. It is assumed that the call is equally likely to come from any line, i.e. not busy at the
time of arrival and that is can be directed to any line other than itself. To make easy to explain, the
action of the simulation the attributes of next events are shown in figure 2, although in real practice,
they would not have been generated until the clock reaches 1057, the clock of next arrival.
Two possible attributes can make to change to occur in the system state; a new call can arrive or an
existing call can be finished. From figure 2, it can be seen that three events can occur in the figure:
a. Call between 2 & 5 will finish at 1053
b. A new call will arrive at 1057
c. Call between 4 & 7 will finish at 1075
The simulation proceeds by executing a cycle below state to simulate each event:
1. Scans the events to determine which the next potential event is. Here, it
is at 1053. The clock is updated then.
2. Select the activity that is to cause the event. Here, the activity is to
disconnect a call between lines 2 & 5.
3. Test whether the potential event can be executed. Here, however, there
are no conditions to disconnect a call.
5. Gather some statistics for the simulation output. Here call counter is changed
to record the number of calls that have been processed, completed, blocked
or busy. The state of the system appears as shown
in figure 3.
Figure 3
In the figure, it can be seen that the next potential event is the arrival of a call at time 1057 sec. the
clock is updated to 1057 and the attributes of the new arrival are generated. Since the selected
activity is to connect a call, it is necessary to test; to find whether a link is available and to find
whether the party is busy or not. In this case, the called party, line 7 is busy so the call is lost. Both
the processed call and the busy call counter are increased by one. New arrival is generated. These
are shown in figure 4.
Suppose the next arrival time is 1063, and the call will be from line 3 to 6 and will spend 20 sec
and at this time, the arriving call can be connected. The new state of the system is shown in figure
5. The procedural is repeated to a certain limit until good statistics can be gathered.
Figure 5
To keep a record of the delayed call, it is necessary to build another list like the call in progress
list. After arriving a call, if it cannot be connected, then it is placed in the delayed call list, waiting
to next time. When a previous call is completed, it is necessary to check the delayed call list to
find if a waiting call can be connected. This is illustrated in figures 6, 7, and 8.
From figure 5, it is clear that the next potential event is the arrival of the next call from line 1 to 7.
Since the line 7 is not free the next call cannot be executed. It is then placed in the delay call list
waiting for the next time and the new stated of the system is shown in the below figure.
Figure 6
https://www.ckundan.com.np/2019/06/discrete-system-simulation.html
When the call from line 4 and 7 completed at time 1075, then for the next event, the delayed call
list is checked first. At these time, lines 1 and 7 can be connected which is shown in the below
figure.
Figure 8
2. Simulation:
After generating a model, the next is to program the procedure that executes the cycle of actions
involved in carrying out the simulation. This procedure is referred to as a simulation algorithm.
3. Generating Report:
After programming the simulation algorithm, the next and final task is to run the simulation to
generate an output report. The statistic gather (data collected) during the simulation will be
organized by a report generator.
The general flow of control during the execution of the simulation program is shown above. At the
top of the figure is the task of generating a model which is executed once. At the bottom is the report
generation task, which is usually executed once at the end of the simulation. Carrying out the
simulation algorithm involves repeated execution of five steps. These steps are:
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.
c. Utilization: This measure the time infraction or percentage, that some entity
is engaged.
f. Transit time: These records the time taken from an entity to move from
one part of the system to some other part.
When stochastic effects are operating in the system, all these measures will fluctuate as a
simulation proceeds and the particular values reached the simulation are taken as estimates of the
true values they are designed to measure.
A mean is derived by accumulating the total value of the observation, and also accumulating a
count of the number of observations.
The accumulated sum of the observations must be kept to derive the mean value, and so the
additional record needed to derive a standard the deviation is the sum of the squares.
The below figure might also represent several entities waiting on queues.
https://www.ckundan.com.np/2019/06/discrete-system-simulation.htm
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.
If M= links in a telephone
ni = number of busy in the interval ti and ti+1 then the average occupancy, assuming the number
ni changes n times is given by:
The definition of a destination table required specification for the lower limit of the tabulation, the
interval size and the number of intervals. Normally, the tabulation interval sizes are uniform.
https://www.ckundan.com.np/2019/06/discrete-system-simulation.html
Generally, it is required to keep count the number of time and observation falls below the lower
limit and beyond the upper limit rather than to obtain accurately the potential range of valuation.
The instances when the observations are made are determined by the native of the random variable
being measured. To understand this, consider the following two examples:
A clock is used in the manner of the time stamp to measure transit time. When an entity reaches a
point from which a measurement of transit time is to start. A note of the time of arrival is made.
These languages are used to describe a system and establish a system image and execute a
simulation algorithm. Most programming also provides report generators. These languages also
offer many convenient facilities such as,
a. Automatic generators of streams of pseudo-random numbers for any
desired statistical destination.
b. Automatic data collection
c. Their statistical analysis and report generations
d. Automatic handling of queues, etc.
Also, a good simulation provides a nodded builder with the view of the world that next nodded
building easier. Every discrete system simulation language must provide the concept and statement
for:
a. Representing the state of a system at a single point in time (static modelling)
b. Moving a system from state to state (Dynamic modelling), &
c. Performing relevant task such as the random number of generation, data
analysis and report generation.
Discrete system simulation languages can be classified into three main categories:
a. Event oriented languages
b. Activity-oriented languages
c. Process-oriented languages.
The description of activities can be of two types deterministic and stochastic. The process on which,
the outcome of an activity can be described completely in terms of its input is deterministic and
the activity is said to be deterministic activity. On the other hand, when the outcome of an activity
is random, i.e. there can be various possible outcomes, the activity is said to be stochastic activity.
In case of an automatic machine, the output per hour is deterministic, while in a repair shop the
number of machines repaired will vary from hour to hour, in a random fashion. The terms random
and stochastic are interchangeable.
A random variable x is called discrete if the number of possible values of x (i.e. range space) is
finite or countably infinite, i.e. possible values of x maybe x1, x2, …, xn.
A random variable x is called continuous if its range space is an interval or a collective of intervals.
A continuous variable can assume value over a continuous range.
If a random variable x can take xi (i = 1… n) countable infinite number of values with the
probability of value xi being P(xi) is said to be Probability Distribution or Probability Mass
Function of a random variable x.
It is a function which, gives the probability of a random variable being less or equal to a random
variable being less or equal to a given value. In a discrete test, the cumulative distribution function
is denoted by P(xi). This function implies that x takes values less than or equal to xi.
If the random variable is continuous and not limited to discrete values, it will have an infinite
number of values in an interval. Such a variable is defined by a function f(x) called a Probability
Density Function (pdf). The probability that a variable x, falls between x and x+dx is expressed as
f(x)dx and the probability that x falls in the range x1 to x2 is given as:
Random Variables:
A random variable is a rule that assigns a number to each outcome of an experiment. These
numbers are called values of a random variable. Random variables are usually denoted by X.
Example:
1. If a die is rolled out, the outcome has a value from 1 through 6.
2. If a coin is tossed, the possible outcome is head ‘H’ or tail ‘T’.
A discrete random variable takes only specific, isolated numerical values. The variables which
take finite numeric values are called as Finite discrete random variables and which
Let
X → discrete random variable
RX → possible values of X, given by range space of X.
Xi → the individual outcome in RX.
The collection of pairs (xi, P(xi)) i.e. a list of probabilities associated with each of its possible
values is called probability distribution of X. P(xi) is called probability mass function (pmf) of X.
Example:
Consider the experiment of tossing a single die, defining X as the number of spots on up the face
of die after a toss.
Solution:
N=total number of observations = 21
The discrete probability distribution is given by
xi 1 2 3 4 5 6
P(xi) 1/21 2/21 3/21 4/21 5/21 6/21
Continuous Random Variable takes any values within a continuous range or an interval. The
example is tabulated in the table below.
Random Variable Values Type
Continuous.
The set of possible
Measure the length of an measurements can
object; X = its length in Any positive real take on any positive
centimetres. number value.
For a continuous random variable X, the probability that X lies in the interval [a, b] is given by,
The function f(x) is called Probability Density Function (pdf) of random variable X.
The pdf must satisfy the following conditions:
Random Numbers:
A random number is a number generated by a process, whose outcome is unpredictable, and which
cannot be subsequentially reliably reproduced. Random numbers are the basic building blocks for
all simulation algorithms.
Pseudo-Random Numbers:
Pseudo means false but here pseudo implies that the random numbers are generated by using some
known arithmetic operations. Since the arithmetic operation is known and the sequence of random
numbers can be repeatedly obtained, the numbers cannot be called truly random. However, the
pseudo-random numbers generated by many computer routines very closely fulfil the requirements
of the desired randomness.
If the method of random number generation, i.e. the random number generator is defective, the
generated pseudo-random number may have the following departures from ideal randomness:
1. The generated random numbers may not be uniformly distributed.
2. The generated random numbers may not be continuous.
3. The mean of the generated numbers may be too high or too low.
4. The variance may be too high or too low.
In computer simulation where a very large number of random numbers is generally required, can
be obtained by the following method.
1. Random numbers maybe drawn from the random number tables stored in a
memory of the computer. The process is neither practical nor economical. It
is a very slow process and the number occupied considerable space of
computer memory. Above all, in the real system many time more random
number than available in the table.
The most widely used techniques for generating random numbers are:
The most widely used technique for generating random numbers, initially proposed by Lehmer
[1951]. This method produces a sequence of integers, X1, X2 … between 0 and m-1 by following
a recursive relationship:
The initial value X0 is called seed. The selection of the values for a, c, m, and X0 drastically
affects the statistical properties and the cycle length.
a. If c ≠ 0 in the above equation, then it is called as Mixed Congruential method.
b. If c = 0 the form is known as the Multiplicative Congruential method.
Example:
Use linear congruential method to generate sequence of random numbers with X0 = 27, a =
17, c = 43, and m = 100.
Solution:
Random numbers (Ri)
The random integers (Xi) generated will be between the range 0 - 99
Equations → Xi+1 = (a Xi + c) mod m, Ri = Xi / m , i=1,2,…..
X1 = (17 * 27 + 43) mod 100 = 2, R1 = 2 / 100 = 0.02
X2 = (17 * 2 + 43) mod 100 = 77, R2 = 77 / 100 = 0.77
X3 = (17 * 77 + 43) mod 100 = 52, R3 = 52/ 100 = 0.52
a. Maximum Density:
Maximum Density means values assumed by Ri, i = 1, 2… leave no large gaps on the interval [0,
1].
b. Maximum Period:
To achieve Maximum density and avoid cycling, the generator should have the largest possible
period. Most digital computers use a binary representation of numbers. Speed and efficiency is
aided by a modulus m, to be (or close to) a power of 2. The maximal period is achieved by proper
choice of a, c, m and X0.
Solution:
c=0 (multiplicative congruential method), m = 26= 64 and a=13 → (a=5+8*1=13) so ‘a’ is in the
form 5+8k with k=1.
Therefore the maximal period p= m / 4= 64 / 4=16 for odd seeds i.e. for X0=1 and 3
Equation → Xi+1 = (aXi + c) mod m
When X0 = 1, i = 1, X2 = (13 * 1 + 0) mod 64 = 13 mod 64 = 13
When X0 = 1, i = 2, X3 = (13 * 13 + 0) mod 64 = 169 mod 64 = 41
When X0 = 1, i = 3, X4 = (13 * 41 + 0) mod 64 = 533 mod 64 = 21
When X0 = 1, i = 16, X17 = (13 * 5 + 0) mod 64 = 65 mod 64 = 1
……………………………………
……………………………………
As computing power increases, the complexity of the system to simulate also increases. So a longer
period generator with good statistical properties is needed. One successful approach is to combine
two or more multiplicative congruential generators.
Theorem:
If Wi,1, Wi,2 ,...,Wi,k are any independent, discrete-valued random variables and Wi,1 is uniformly
distributed on integers 0 to m1 -2, then
To see how this the result can be used to form combined generators,
Let Xi, 1, Xi, 2 … Xi, k be ith output from k different multiplicative congruential generators, where the
jth generator has prime modulus mj and multiplier aj is chosen so that the period is mj -1. Then the
jth generator is producing Xi,j that are approximately uniformly distributed on 1 to mj -1 and Wi, j =
Xi, j -1 is approximately uniformly distributed on 0 to mj -2.
Example:
For 32-bit computers, L’Ecuyer [1988] suggests combining k = 2 generators with m 1 =
2,147,483,563, a1 = 40,014, m2 = 2,147,483,399 and a2 = 40,692. This leads to the following
algorithm:
Step 3:
Xi+1 = (Xi+1, 1 – Xi+1, 2) mod 2,147,483,562
Step 4: Return
Step 5:
Set i = i+1, go back to step 2.
The two main properties of random numbers are uniformity and independence.
The null hypothesis H0, reads that the numbers are distributed uniformly on the interval [0, 1].
Rejecting the null hypothesis means that the numbers are not uniformly distributed.
This null hypothesis, H0, reads that the numbers are independent. Rejecting the null hypothesis
means that the numbers are not independent. This does not imply that further testing of the
generator for independence is unnecessary.
2. Runs Test: Tests the runs up and down or the runs above and below the
mean by comparing the actual values to expected values. The statistic for
comparison is the chi-square test.
4. Gap Test: Counts the number of digits that appear between repetitions of a
particular digit and then uses the Kolmogorov-Smirnov test to compare with
the expected size of gaps.
5. Poker Test: Treats the numbers grouped together as a poker hand. Then
the hands obtained are compared to what is expected using the chi-square
test.
Frequency Tests:
The fundamental test performed to validate a new generator is the test for uniformity. The two
different methods of testing are:
1. Kolmogorov-Smirnov Test:
Step 1: Rank the data from smallest to largest. Let R(i) denote the ith smallest observation, so
that
R (1) ≤ R (2) ≤ ….. ≤ R (N)
Step 2: Compute
D+ = max {(i / N) - R
(i)} 1 ≤ i ≤ N
D- = max {R (i) – [(i – 1)/ N]}
1≤i≤N
Step 3: Compute
D= max (D+, D-)
Step 4: Determine the critical value Dα, from the table A.8 for the specified significance
level α and the given sample size N.
Example:
Suppose 5 generated numbers are 0.44, 0.81, 0.14, 0.05, and 0.93. It is desired to perform a test
for uniformity using the Kolmogorov-Smirnov test with a level of significance α = 0.05.
The calculations in the above table are depicted in the figure below, where empirical cdf SN(x) is
compared to uniform cdf F(x). It is seen that D+ is the largest deviation of SN(x) above F(x) and
D- is the largest deviation of SN(x) below F(x).
2. Chi-Square Test:
Example:
Use a chi-square test with α=0.05 to test whether the data shown below are uniformly distributed.
Note:
a. In general, for any value chooses ‘n’ such that Ei ≥ 5.
b. Kolmogorov-Smirnov test is more powerful than the chi-square test
because it can be applied to small sample sizes, whereas chi-square requires
large sample, say N ≥ 50.
Run - The succession of similar events preceded and followed by a different event is called as
run.
Run-length - Number of events that occur in the run.
It has 7 runs, first run of length one, second run of length three, third run of length 3, and fourth
run with one, fifth run with one, sixth run with three and seventh run with one. There are three up
runs and four down runs. If N is several numbers in sequence, then maximum numbers of runs are
N-1 and a minimum number of runs is one. If ‘a’ is the total number of runs in a random sequence,
Mean is given by
For N > 20, the distribution of ‘a’ is reasonably approximated by a normal distribution, N(μa, σa2).
This approximation is used to test the independence of numbers from a generator. The test statistic
is obtained by subtracting the mean from the observed number of runs ‘a’ and dividing by standard
deviation, i.e. Test statistic is given by,
The null hypothesis is accepted when –Zα/2 ≤ Z0 ≤ Zα/2, where α is the level of significance. The
critical values and rejection region is shown in the figure below.
Solution:
The sequence of runs up and down is as follows:
+ + + - + - + - - - + + - +
- - + - + - - + - - + - + +
- - + + - + - - + + -
No. of runs → a = 26
N = 40
μa = {2(40) - 1} / 3 = 26.33
σa2= {16(40) - 29} / 90 = 6.79
Z0 = (26 - 26.33) / √ (6.79) = -0.13
Critical value → Zα/2→ Z0.025 = 1.96 (from z - table)
Zα/2 ≤ Z0 ≤ Zα/2 → -1.96 ≤ -0.13 ≤ 1.96
Therefore independence of the numbers cannot be rejected, we accept the null hypothesis.
Runs are described with above/below the mean value. A ‘+’ sign is used to indicate above mean
and ‘-‘ sign for below the mean.
For either n1 or n2 greater than 20, b is approximately normally distributed. The test statistic is
obtained by subtracting the mean from several runs ‘b’ and dividing by the standard deviation i.e.
The null hypothesis is accepted when –Zα/2 ≤ Z0 ≤ Zα/2, where α is the level of significance.
Example:
Based on runs above and below mean, determine whether the following sequence of 40 numbers
is such that the hypothesis of independence can be rejected or accepted where α = 0.05.
Solution:
Mean= 0.495
Solution:
N = 60
Calculate Oi
Run Length, i 1 2 3 4
Observed Runs, Oi 26 9 5 0
Solution
N = 60
Mean = (0.99+0.00)/2 = 0.495
n1 = 28
n2 = 32
N = n1 + n2 = 60
Calculate Oi
Run Length, i 1 2 3 ≥4
Observed Runs, Oi 17 8 1 5
The uniformity test of random numbers is only a necessary test for randomness, not a sufficient
one. A sequence of numbers may be perfectly uniform and still not random. For example the
sequence 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.1, 0.2, 0.3, …, … would give a perfectly
uniform distribution with chi-square value perfectly as zero. But the sequence can be no means be
regarded as random. The numbers are not independent as the occurrence of one number say 0.3
decides the next, which is to be 0.4, etc. This defect is called serial autocorrelation of an adjacent
pair of numbers.
The chi-square test for serial autocorrelation makes use of a 10 * 10 matrix. The 10 class describe
in the uniformity test are represented both along the rows and columns. If the classes are to be
represented on a bar chart, 100 bars, one for each cell of a matrix will be required. To reduce the
number of groups instead of 10 random numbers are divided into a smaller number of a class as
3 or 4. Three class will be as:
a. Less than or equal to 0.33
b. Less than or equal to 0.67
c. Less than or equal to 1.0
With three classes in a row and three classes in a column, there will be 9 cells.
Features:
Specialized features usually differentiate from a general programming language. These features
are intended to free the analyst from recreating software tools and procedures used by virtually all
modelling application. Not only the development of these features be time- consuming and
difficult, but without them, the consistency of a model could vary and additional debugging,
validation and verification would be required. Most simulation languages should have the
following features:
The simulation must be flexible enough to adapt to change the configuration. The domain of
application should be wide and the model should be equally valid over the whole domain.
2. Ease of Modelling:
It should be easy to develop the simulation model, easy to debug the program and validate the
model. The software should have an in-built interactive debugger, error detector and online health.
The speed of execution is always a very important requirement of any simulation model. It is
especially an essential feature in case of simulation of a large and complex system.
The simulation language should be compatible with various computer system like microcomputer,
engineering workstation minicomputers and mainframe computers.
5. Statistical Capabilities:
A simulation software should contain multiple stream random number generators and as many
standards probability distributions as possible. It should have blocks for designing the statistics like
the simulation run, warming up period and the number and the length of replication.
The animation capability of the simulation package is one of the main reasons for the popularity
of simulation language. The animation is carried out in two modes i.e. concurrent mode and
playback mode.
The output of the simulation the model should be well documented and illustrated. The user should
be able to get the information of its interest in the easily understandable form.
To represent the state of the system in the model, a set of numbers is used that is used in the discrete-
time system. A number, state descriptor is used to represent some aspect of the system state. Some
state descriptors range over values that have physical significance and some represent conditions.
The effect of the state descriptors is to change the value as the simulation proceeds. We 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 modelled as
being simultaneous so that not all changes of state descriptors occurring simultaneously
necessarily belong to a single event.
The term simultaneous refers to the occurrence of the changes in the system, and not to when the
changes are made in the model in, which, of necessity, the changes must be made sequentially. A
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. How events are selected for execution (when there are simultaneous events)
is an important aspect of programming simulations.
For writing discrete system simulation programs, several programming languages have been
produced. These programs embody a language with which to describe the system and a
programming system that will establish a system image and execute a simulation algorithm. Each
language is based upon a set of concepts used for describing the system. The term
GPSS Programs:
The General-Purpose Simulation System language has been developed over many years,
principally by the IBM Corporation. It has been implemented on several different manufacturers'
machines and there are variations in the different implementations. GPSS V is more powerful and
has more language statements and facilities than GPSS/360.The GPSS V is implemented by IBM
Corporation.
General Description:
The system to be simulated in GPSS is described as a block diagram in which the blocks represent
the activities and lines joining the blocks indicate the sequence in which the activities can be
executed. Where there is a choice of activities, more than one line leaves a block and the condition
for the choice is stated at the block.
To base a programming language on this descriptive method, each block must be given a precise
meaning. The approach taken in GPSS is to define a set of 48 specific block types, each of which
represents a characteristic action of the systems. Only the specified block types are allowed while
drawing the block diagram of the system. Each block type is given a name that is descriptive of the
block action and is represented by a particular symbol. Each block type has several data fields.
Moving through the system being simulated are entities that depend upon the nature of the system.
In a communication system, the entities of concern are messages, which are moving. Meanwhile,
in a road transportation system, the entities that are moving are the motor vehicles. A data
processing system is concerned with records. In the simulation, these
Transactions are created at one or more GENERATE blocks and are removed from the simulation
at TERMINATE blocks. 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.
A GPSS block diagram can consist of many blocks up to some limit prescribed by the program
(usually set to 1000). An identification number called a location is given to each block, and the
movement of transactions is usually from one block to the block with the next highest location.
The locations are assigned automatically by an assembly program within GPSS so that, when a
problem is coded, the blocks are listed in sequential order. Blocks that need to be identified in the
programming of problems are given a symbolic name. The assembly program will associate the
name with the appropriate location. Symbolic names of blocks and other entities of the program
must be from three to five non-blank characters of which the first three must be letters.
Action times:
Clock Time is represented by tan integral number, with the interval of real-time corresponding to
a unit of time chosen by the program user. The unit of time is not specifically stated but is implied
by giving all the time in terms of the same unit. One block type called ADVANCE is concerned
with representing the expenditure of time. The program computes an interval of time called action
time for each transaction as it enters an ADVANCE block and the transaction remains at the block
for this interval of a simulated time before attempting to proceed. The only other block type that
employs action time is the GENERATE block, which creates transactions. The action time at the
GENERATE block controls the interval between successive arrivals of transactions.
The action time may be a fixed interval or a random variable, and it can be made to depend upon
conditions in the system in various ways. Action time is defined by giving a mean and modifier as
the A and B fields for the block. If the modifier is zero, the action time is a constant equal to the mean.
If the modifier is a positive number (<=mean), the action time is an integer random variable chosen
from the range (mean ± modifier), with equal probabilities given to each number in the range.
The GENERATE block normally begins creating transactions from zero time and continues to
generate them throughout the simulation. The C field, however, can be used to specify an an-offset
time as the time when the first transaction will arrive. If the D field is used, it specifies a limit to
the total number of transactions that will come from the block. Transactions have a priority level
and they carry items of data called parameters. The E field determines the priority of the transactions
at the time of creation. If it is not used, the priority is of the lowest level.
Parameters can exist in four formats. They can be signed integers of the full word, halfword, or
byte size, or they can be signed floating-point numbers. If no specific assignment of parameter
type is made, the program creates transactions with 12 halfword parameters. The C, D and E fields,
also, will not be needed.
The Succession of Events:
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 logically be performed. Where there is more than one transaction due to move, the program
processes transactions in the order of their priority class, and on a first-come, first-served basis
within a priority class.
Once the program has begun moving a transaction it continues to move the transaction through the
block diagram until one of the several circumstances arises.
The transaction may enter an ADVANCE block with a non-zero action time, in which case, the
program will turn its attention to other transactions in the system and return to that transaction
when the action time has been expended.
The conditions in the systems may be such that the action the transaction is attempting to execute
by entering a block cannot be performed at the current time. The transaction is said to be blocked
and it remains at the block it last entered. The program will automatically detect when the blocking
condition has been removed and will start to move the transaction again at that time.
When the program has moved one transaction as far as it can go, it turns its attention to any other
transactions due to move at the same time instant. If all such movements are complete, the program
advances the clock to the time of the next most imminent event and repeats the process of executing
events.
Choice of Paths:
The TRANSFER block allows some location other than the next sequential location to be selected.
The choice is normally made between two blocks referred to as next blocks A and
B. The method used for choosing is indicated by a selection factor in the field A of the TRANSFER
block. It can be set to indicate one of the nine choices. Next blocks A and B are placed in fields B
and C, respectively. If no choice is to be made, the selection factor is left blank. An unconditional
transfer is then made to next block A.
A random choice can be made by setting the selection factor, S, to a three-digit decimal fraction.
The probability of going to next block A is then 1-S, and to the next block B it is S. a conditional
mode, indicated by setting field A to BOTH, allows a transaction to select an alternate path
depending upon existing conditions. The transaction goes to next block A if this move is possible,
and to the next block B if it is not. If both moves are impossible the transaction waits for the first
to become possible, giving preference to A in the event of simultaneity.
Let us consider a scenario representing a machine tool in a manufacturing shop which is turning
out parts at the rate of every 5 minutes. The parts are then examined by the inspector who takes 4 3
minutes for each part and rejects about 10% of the parts. We can represent each part by one
transaction, and the time unit selected for the problem will be 1 minute. A block diagram
representing the system is given below:
In the block diagram, the block location is placed at the top of the block, the action time is indicated
in the centre in the form T = a, b where a is the mean MD b is the modifier and the selection factor
is placed at the bottom of the block.
A GENERATE block is used to represent the output of the machine by creating one transaction
every five units of time. An ADVANCE block with a mean of 4 and modifier of 3 is used to
represent an inspection. The time spent on inspection will, therefore, be any one of the values 1,2,
3, 4, 5, 6 or 7, with equal probability given to each value. Upon completion of the inspection,
transactions go to a TRANSFER block with a selection factor of 0.1, so that 90% of the parts go
to the next location called ACC, to represent accepted parts and l0% go to another location called
REJ to represent rejects. Both locations reached from the TRANSFER block are TERMINATE
blocks.
The problem can be coded. Column 1 is only used for a comment card. A field from columns 2 to
6 contains the location of the block where it must be specified. The GPSS program will
automatically assign sequential location numbers as it reads the statements, so it is not usually
necessary for the user to assign locations. The TRANSFER block, however, will need
The second section of the coding, from columns 8 to 18, contains the block type name, which must
begin in column 8. Beginning in column 19, a series of fields may be present, each separated by
commas and having no embedded blanks. Anything following the first blank is treated as a
comment. The meaning of the fields depends upon the block type.
The program also accepts input in a free format, in which the location field, if used, begins in
column 1; but none of the other fields has a fixed starting position. Instead a single blank mark the
transition from the location field to the operation field and from the operation held to the operands.
If no location is specified, an initial blank is used.
For the TRANSFER block, the first field is the selection factor, and the B and C fields are exits 1
and2, respectively. In this case, exit 1 is the next sequential block, and it would be permissible to
omit the name ACC in both the TRANSFER field B and the location field of the first TERMINATE
block. It should also be noted that when a TRANSFER block is used in an unconditional mode, so
that field A is not specified, a comma must still be included to indicate the field.
The program runs until a certain the count is reached as a result of transactions terminating. Field
A of the TERMINATE block carries a number indicating by how much the termination count
should be incremented when a transaction terminates at that block. The number must be positive
and it can be zero, but there must be at least one TERMINATE block that has a non-zero field A.
in this case, both TERMINATE blocks have 1; so the terminating counter will add up the total
number of transactions that terminate, in other words, the total number of both good and bad parts
inspected.
A control statement called START indicates the end of the problem definition and contains, in
field A, the value the terminating counter is to reach to end the simulation. In this case, the START
Statement is set to stop the simulation at a count of 1,000. Upon reading a START statement, the
program begins executing the simulation.
When the simulation is completed, the program automatically prints an output report, in a
prearranged format, unless it has been instructed otherwise.
Associated with the system being simulated are many permanent entities, such as items of
equipment, which operate on the transactions. Two types of permanent entities are defined in GPSS
to represent system equipment.
A facility is defined as an entity that can be engaged by a single transaction at a time. Storage is
defined as an entity that can be occupied by many transactions at a time, up to some predetermined
limit. A transaction controlling a facility, however, can be interrupted or preempted by another
transaction. Also, both facilities and storages can be made unavailable, as would occur if the
equipment they represent breaks down, and can be made available again, as occurs when a repair
has been made.
There can be many instances of each type of entity to a limit set by the program (usually 300),
Individual entities are identified by number, a separate number sequence being used for each type.
The number 0 for these and all other GPSS entities is illegal.
Block types SEIZE, RELEASE, ENTER and LEAVE are concerned with using facilities and
storages. Field A in each case indicates which facility or storage is intended, and the choice is
usually marked in the flag attached to the symbols of the blocks. The SEIZE block allows a
transaction to engage a facility if it is available. The RELEASE block allows a transaction to
disengage the facility. An ENTER block allows a transaction to occupy a pace in storage if it is
available, and the LEAVE block allows it to give up space. If the fields B of the ENTER and
LEAVE blocks are blank, the storage contents are changed by 1. If there is a number (>=1), then
the contents change by that value. Any number of blocks may be placed between the points at
which a facility is seized and released to simulate the actions that would be taken while the
transaction has control of a facility. Similar arrangements apply for making use of storages.
Assuming that 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. A SEIZE block and a RELEASE
block needs to be added to simulate the engaging and disengaging of the inspector.
The case of a single inspector can be modelled by using storage with capacity 1 instead of the
facility. An important logical difference between the two possible representations is that, for a
facility, only the transaction that seized the facility can release it, whereas, for storage, entering
and leaving can be separate actions carried out independently by different transactions.
2. SIMSCRIPT III:
This language is a direct descendant of the original SIMSCRIPT language produced at Rand
Corporation in 1960’s. SIMSCRIPT III has constructs that allow a modular to approach a problem
from either a process or an event-oriented world view. It offers unique features which are:
a. Object Oriented Programming
b. Modularity
c. SIMSCRIPT III development studio
d. Object Oriented SIMSCRIPT III graphics
e. Database Connectivity (SDBC)
In general, SIMSCRIPT III is a free form of language with English like a statement. This syntax
allows the code in the system to become self-documenting. Model components can be
SIMSCRIPT Program:
SIMSCRIPT is a very widely used language for simulating the discrete system. The language can
be considered as more than just a simulation language since it can be applied to general
programming problems. The description of the language given is organized in five levels.
1. Beginning with simple teaching, level to introduce the concept of
programming.
2. The description add level corresponding to a specific programming language.
3. A general-purpose language.
4. A list processing language, needed for creating the data structure of a
simulation model.
5. The simulation-oriented function needed to control the simulation and
gathering statistics.
The system to be simulated is considered to consist of entities having attributes that interact with
activities. The interaction causes events that change the state of the system. In the system,
SIMSCRIPT uses the term entities and attributes. To make the program efficiency it must
distinguish between temporary and permanent entities and attributes.
The temporary entities represent those entities are created and destroyed during the execution of a
simulation while permanent entities represent that entities remain during the run.
A special emphasis is placed on how temporary entities form sets. The user can define sets and
facilities are provided for entering and removing entities into and from sets.
Activities are considered as extending overtime with their beginning and being marked as events
occurring instantaneously. Each type of event is described by an event routine, each of which is
given a name and a program as a separate closed routine.
An exogenous event requires the reading of data supplied by the user. Among the data is time at
which, the event occurs. There can be many data sets representing a different set of external events.
Events routines are needed to execute the changes that result when an external event becomes due
for execution. Part of the automation initialization procedure of SIMSCRIPT is to prepare the first
exogenous event for each data set.
In practice, external event, such as arrivals are often generated using the bootstrap method. Given
the statistical distribution of the inter-arrival time, an indigenous event routine continuously creates
one arrival from its predecessor. An exogenous event routine is essential only when specific data
are needed.
Since the event routines are closed routines, some means must be provided for control between
them. The transfer is affected by the use of event notice which is created when it is determined that
an event is scheduled. At all time, an event notice exists for every indigenous event scheduled to
occur either at current clock time or in the future event.
Each event notice records the time 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 identify which
one is involved.
The event notice is filed in chronological order. When all events that can be executed at a particular
time have been processed, the clock is updated to the time of the next event notice and control is
passed to the event routine identified by the notice. Their actions are automatic and do not need to
be programmed and event notice do not usually go to more than one activity.
In the case of the exogenous event, a series of exogenous event statement are created one for each
event. All exogenous event statements are sorted to chronological order and they are read by the
programs when the time for the event is due to occur.
Introduction:
The goal in analyzing output data from running a simulation model is to make a valid
statistical inference about the initial and long-term average behaviour of the system based
on the sample average from N replicate simulation runs.
Output Analysis is the analysis of data generated by a simulation run to predict system
performance or compare the performance of two or more system designs. In stochastic
simulations, multiple runs are always necessary. The output of a single run can be viewed as
a sample of size 1.
Output analysis is needed because output data from a simulation exhibits random variability
when random number generators are used. 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:
a. The estimate of the mean and variance of random variables.
b. The number of observations required to achieve a desired precision of
these estimates.
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 analyse 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 analyse.
Estimation Method:
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 ‘σ2’. These random
variables are independently and identically distributed (i.e. IID variables).
Let, xi=iid random variables. (i = 1, 2…, n), then according to central limit theorem and
applying transformation, approximate normal variance,
Let us illustrate the problems that arise in measuring statistic from a simulation run with the
example of a single server system.
The 2nd 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 means 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 be minimum. This is shown in the figure below.
Repeating the experiment with different random numbers for the same sample size ‘n’ gives
a set of an independent determination of sample mean x ̅(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.
Here, the value of x ̅ is an estimate for mean waiting time and the value of s^2 can be used to
establish the confidence of intervals.
In the first approach, it is necessary to know the steady-state distinction for the system and
we then select the initial state distinction. In the study of simulation, particularly the existing
system, there may be information available on the expected condition which makes it
feasible to select a better initial condition and thus eliminating the initial bias.
The second approach that is used to remove the initial bias is the most common approach.
In this method, the initial section of the run which has a high bias (simulation) result is
eliminated. First, the run is started from an idle state and stopped after a certain period of
time (the time at which the bias is satisfactory). The entities existing in the system at that are
left as they are and this point is the point of a restart for other repeating simulation runs.
Then the run is restarted with statistics being gathered from the point of the restart. These
approaches have the following difficulties: