Upload
nanasaheb-patil
View
218
Download
0
Embed Size (px)
Citation preview
7/26/2019 ALl Lab Writeup SM 2015 2016
1/50
KJSCE/IT/BE/SEMVIII/SM/2015-16
(Autonomous College Affiliated to University of Mumbai)
Experiment No. 1
Title: Random Number Generator
7/26/2019 ALl Lab Writeup SM 2015 2016
2/50
KJSCE/IT/BE/SEMVIII/SM/2015-16
(Autonomous College Affiliated to University of Mumbai)
Batch: Roll No.: Experiment No.:1
Aim: To study and implement a PseudoRandom Number Generator (PRNG) using Linear
Congruential Method
Resources needed: Turbo C / Java
Theory
Problem Definition:Write a Program for generating random numbers using Linear Congruential method such that
i) Period of the numbers generated is >=100
ii) Density of the numbers generated is maximum (average gap between random
numbers is < 0.1).
Concepts:
Random Numbers: Random numbers are a necessary basic ingredient in simulation of
almost all discrete systems. Most computer languages have a subroutine, object or function
that will generate a random number. A simulation language generates random numbers that
are used to generate event times and other random variables.
Properties of random Numbers:A sequence of random number R1, R2 must have two important statistical properties,uniformity and independence.
Uniformity :
If the interval (0, 1) is divided inton
classes or subintervals of equal length , the expectednumber of observations in each interval is N/n, where N is total number of observations.
Independence:
The probability of observing a value in a particular interval is independent of the previous
drawn value.
Problems faced in generating random numbers:1. The generated number may not be uniformly distributed.2. The number may be discrete valued instead of continuous values.
3. The mean of the numbers may be too high or low
4. The variance of the number may be too high or low.
5. The numbers may not be independente.g. a. Autocorrelation between numbers
b. Numbers successively higher or lower than adjacent numbers.
Criteria for random no. generator:
1. The routine should be fast.2. The routine should be portable.
3. The routine should have a sufficient long cycle. The cycle length or period represents
the length of random number sequence before previous numbers begin to repeat
themselves in an earlier order. A special case of cycling is degenerating. A routine
degenerates when some number appears repeatedly which is unacceptable.
4. The random number should be replicable.
5. Most important, the generated random numbers should closely approximate to theideal statistical properties of uniformity and independence.
7/26/2019 ALl Lab Writeup SM 2015 2016
3/50
KJSCE/IT/BE/SEMVIII/SM/2015-16
(Autonomous College Affiliated to University of Mumbai)
Procedure:
Linear Congruential Method:The Linear Congruential method produces a sequence of integers X1, X2,between 0 and
m-1 according to the following recursive relationship.X i+1= (a X i + c) mod m , i = 0, 1, 2
The initial value X0 is called the seed, a is constant multiplier, c is the increment and m is themodulus. Maximal period can be achieved by a, c, m, X0 satisfying one of the followingconditions
1. For m, a power of 2 (m = 2b) and c0 period p = 2b is achieved provided c is relatively
prime to m and a = 1+4k , k = 0,1,2,
2. For m = 2b and c = 0 , period p = 2b-2 is achieved provided X0 is odd and multiplier a= 3+8k or a = 5+8k , k = 0,1,2,
3. For m a prime number and c = 0, period p = m-1 is achieved provided a has the
property that the smallest integer is such that a k-1 is divisible by m is k = m-1.
Results: (Program printout with output)
Questions:1. List down a few real life applications using random numbers as input.
2. List the methods for generating random numbers.
7/26/2019 ALl Lab Writeup SM 2015 2016
4/50
KJSCE/IT/BE/SEMVIII/SM/2015-16
(Autonomous College Affiliated to University of Mumbai)
Outcomes:
Conclusion:The random number generator using Linear Congruential method fairly satisfies the
properties of random number.
The set of data that provide adequate periodicity and density are as follows:
m = a = x0 = c =
7/26/2019 ALl Lab Writeup SM 2015 2016
5/50
KJSCE/IT/BE/SEMVIII/SM/2015-16
(Autonomous College Affiliated to University of Mumbai)
The Periodicity and Density obtained are as follows:Periodicity =
Density =
Grade: AA / AB / BB / BC / CC / CD /DD
Signature of faculty in-charge with date
References:
Books/ Journals/ Websites:1. "Linear Congruential Generators"by Joe Bolte,Wolfram Demonstrations Project.
2. Severance, Frank (2001). System Modeling and Simulation. John Wiley & Sons, Ltd. p.86.ISBN 0-471-49694-4.
3. The GNU C library's rand() in stdlib.h uses a simple (single state) linear congruential
generator only in case that the state is declared as 8 bytes. If the state is larger (an array), the
generator becomes an additive feedback generator and the period increases. See thesimplified
code that reproduces the random sequence from this library.
4. "A collection of selected pseudorandom number generators with linear structures, K.
Entacher, 1997". Retrieved 16 June 2012.
5. "How Visual Basic Generates Pseudo-Random Numbers for the RND Function".
Microsoft Support. Microsoft. Retrieved 17 June 2011.
6. In spite of documentation onMSDN, RtlUniform uses LCG, and not Lehmer's algorithm,
implementations before Windows Vista are flawed, because the result of multiplication iscut to 32 bits, before modulo is applied
7. GNU Scientific Library: Other random number generators
8. Novice Forth library
http://demonstrations.wolfram.com/LinearCongruentialGenerators/http://demonstrations.wolfram.com/LinearCongruentialGenerators/http://en.wikipedia.org/wiki/Wolfram_Demonstrations_Projecthttp://en.wikipedia.org/wiki/Wolfram_Demonstrations_Projecthttp://en.wikipedia.org/wiki/Wolfram_Demonstrations_Projecthttp://en.wikipedia.org/wiki/International_Standard_Book_Numberhttp://en.wikipedia.org/wiki/International_Standard_Book_Numberhttp://en.wikipedia.org/wiki/International_Standard_Book_Numberhttp://en.wikipedia.org/wiki/Stdlib.hhttp://en.wikipedia.org/wiki/Stdlib.hhttp://www.mscs.dal.ca/~selinger/random/http://www.mscs.dal.ca/~selinger/random/http://www.mscs.dal.ca/~selinger/random/http://www.mscs.dal.ca/~selinger/random/http://citeseer.ist.psu.edu/viewdoc/download?doi=10.1.1.53.3686&rep=rep1&type=pdfhttp://citeseer.ist.psu.edu/viewdoc/download?doi=10.1.1.53.3686&rep=rep1&type=pdfhttp://citeseer.ist.psu.edu/viewdoc/download?doi=10.1.1.53.3686&rep=rep1&type=pdfhttp://citeseer.ist.psu.edu/viewdoc/download?doi=10.1.1.53.3686&rep=rep1&type=pdfhttp://citeseer.ist.psu.edu/viewdoc/download?doi=10.1.1.53.3686&rep=rep1&type=pdfhttp://support.microsoft.com/kb/231847http://support.microsoft.com/kb/231847http://msdn.microsoft.com/en-us/library/bb432429%28VS.85%29.aspxhttp://msdn.microsoft.com/en-us/library/bb432429%28VS.85%29.aspxhttp://msdn.microsoft.com/en-us/library/bb432429%28VS.85%29.aspxhttp://en.wikipedia.org/wiki/Windows_Vistahttp://en.wikipedia.org/wiki/Windows_Vistahttp://www.gnu.org/software/gsl/manual/html_node/Other-random-number-generators.htmlhttp://www.gnu.org/software/gsl/manual/html_node/Other-random-number-generators.htmlhttp://www.forth.org/novice.htmlhttp://www.forth.org/novice.htmlhttp://www.forth.org/novice.htmlhttp://www.gnu.org/software/gsl/manual/html_node/Other-random-number-generators.htmlhttp://en.wikipedia.org/wiki/Windows_Vistahttp://msdn.microsoft.com/en-us/library/bb432429%28VS.85%29.aspxhttp://support.microsoft.com/kb/231847http://citeseer.ist.psu.edu/viewdoc/download?doi=10.1.1.53.3686&rep=rep1&type=pdfhttp://citeseer.ist.psu.edu/viewdoc/download?doi=10.1.1.53.3686&rep=rep1&type=pdfhttp://www.mscs.dal.ca/~selinger/random/http://www.mscs.dal.ca/~selinger/random/http://en.wikipedia.org/wiki/Stdlib.hhttp://en.wikipedia.org/wiki/International_Standard_Book_Numberhttp://en.wikipedia.org/wiki/Wolfram_Demonstrations_Projecthttp://demonstrations.wolfram.com/LinearCongruentialGenerators/7/26/2019 ALl Lab Writeup SM 2015 2016
6/50
KJSCE/IT/BE/SEMVIII/SM/2015-16
(Autonomous College Affiliated to University of Mumbai)
Experiment No. : 2
Title: Case Study 1
(Technical Paper)
7/26/2019 ALl Lab Writeup SM 2015 2016
7/50
KJSCE/IT/BE/SEMVIII/SM/2015-16
(Autonomous College Affiliated to University of Mumbai)
Experiment No. : 3
Title: Single Server system(The Grocery store problem)
7/26/2019 ALl Lab Writeup SM 2015 2016
8/50
KJSCE/IT/BE/SEMVIII/SM/2015-16
(Autonomous College Affiliated to University of Mumbai)
Batch: Roll No.: Experiment No.:3
Aim: To simulate Single Channel Queuing System
Resources needed: Microsoft Excel / Open Office
Problem Statement:A small grocery store has only one checkout counter. Customer arrives at this check outcounter at random from 1 to 8 minutes. The service time varies from 1 to 6 minutes. The
problem is to analyze the system by simulating the arrival & service of 20 customers.
In order to evaluate the system performance the evaluation is done by varying the arrival time
& service time probability distribution.
a) Let the arrival distribution be uniformly distributed between 1 to 10 minutes.
b) Let service time distribution be changedServiceTime(minutes)
1 2 3 4 5 6
Probability 0.05 0.1 0.2 0.3 0.25 0.1
c) Perform simulation for 20 more customers & compare result.
Concepts:The key elements of queuing system are customers & servers. The term customer can refer to
people, machines, and trucks. The server might refer to receptionist, person etc.
A queing system is described by its calling population, the nature of the arrivals, the service
mechanism, the system capacity and the queing discipline.
1. Calling population: The population of potential customer is referred to as calling
population. In systems with large population the calling population is usually assumed to be
infinity. E.g. population of potential customer of a bank. The actual population may be finite.
The main difference between finite & infinite population is based on the definition of the
arrival rate.
2. System Capacity: The system capacity has no limit meaning that any no. of units comes
and waits in the queue. In many queuing system there is a limit to the no. of customers that
may be waiting.
3. Nature of Arrivals: Arrivals for service occur at a time in random fashion and once they
join the waiting line, they are served.
4. Service Mechanism: The units are served in order of their arrival by a single server or a
channel.
5. Queuing Discipline: It refers to the logical ordering of customers that will be chosen for
service when a server becomes busy.
6. State Of System: It is the no. of units in the system & status of server (busy / idle).
7/26/2019 ALl Lab Writeup SM 2015 2016
9/50
KJSCE/IT/BE/SEMVIII/SM/2015-16
(Autonomous College Affiliated to University of Mumbai)
7. Events: It is a set of circumstances that causes an instantaneous change in the state ofsystem
Possible events in a single server system:
The Entry of a unit in the system.
Departure of unit from system on completion of service.
8. Simulation Clock: It is used to track simulation time.
Conceptual Model:The grocery store with one checkout counter is simulated by using a Semi automaticapproach by using simulation table to record successive system snapshots as time advances.
The simulation requires mainly a service time distribution and an interarrival time
distribution of customers.
Characteristics of Grocery Store checkout counter System:I) Calling Population: Infinite.II) System capacity: Infinite.
III) Nature of Arrival: Random arrival uniformly distributed.
IV) Service Mechanism: At a time only one customer is served; service time is random,
probability distribution is given.
V) Queuing Discipline: FIFO.
System State:I) Waiting time in queue.II) Status of Able and Baker (Busy / Idle)
III) Time customer spends in the system.
Entities:
The entities in single channel queue are queue & server.
Events:a) Arrival Event
b) Departure Event
Activities:a) Interarrival time.
b) Service time.
Delay:
Waiting time in the queue.
Use of Random Nos.:
- For generating interarrival time- For generating service time- RAND () function of Excel can be used to generate random nos. in simulation.
Real life Examples:
1. Customers queuing in the Telephone Bill Payment System
Customers form single channel queue.Customer is chosen in FIFO manner.
7/26/2019 ALl Lab Writeup SM 2015 2016
10/50
KJSCE/IT/BE/SEMVIII/SM/2015-16
(Autonomous College Affiliated to University of Mumbai)
Performance measures:
1. Average Waiting Time = (Total time customers wait in queue) / (Total no. ofCustomers)
2. Probability. Of Customers waiting =(No. of Customers who waits) / (Total no. ofCustomers)
3.Probability. Of Idle Server = (Total Idle Time Of Server) / (Total runtime of simulation)
4.Average Time between Arrival = (Total Time between arrivals) / (No. of arrivals)
5.Average Waiting Time of Those Who Wait = (Total Time Customer waits in system) /
(Total no. of Customers)
6.Average Time Customers Spends In System = (Total Time Customer spends in system) /
(Total no. of Customers).
Activity Diagram:
1) Flowchart Arrival event:
Arrival Event
NO YES
Server
Busy?
Unit Enters
service
Unit Enters
queue
2) Flowchart Departure event:
Departure Event
NO YES
Another unit
waiting?
Begin server Idle
Time
Remove waiting
unit from queue
7/26/2019 ALl Lab Writeup SM 2015 2016
11/50
KJSCE/IT/BE/SEMVIII/SM/2015-16
(Autonomous College Affiliated to University of Mumbai)
Results: (Program printout as per the format)
Program:(Problem solved using simulation table and the given inputs with MS-Excel.)
Output:(In printed form i.e. Simulation table along with the performance measures and histogram
showing number of customers against waiting time)
Questions:1) What is simulation? List the different types of simulation.
2) List the queue disciplines used in simulation?
7/26/2019 ALl Lab Writeup SM 2015 2016
12/50
KJSCE/IT/BE/SEMVIII/SM/2015-16
(Autonomous College Affiliated to University of Mumbai)
Outcomes:
Conclusion:
Grade: AA / AB / BB / BC / CC / CD /DD
Signature of faculty in-charge with date
References:
Books/ Journals/ Websites:
1. Jerry Banks, John Carson, Barry Nelson, and David M. Nicol; Discrete Event SystemSimulation, Fifth Edition, Pearson Education.
2. Jerry Banks, John Carson, Barry Nelson, and David M. Nicol; Discrete Event SystemSimulation, Third Edition, Pearson Education.
3. Real Queuing Examples:http://www2.uwindsor.ca/hlynka/qreal.html This site containsexcerpts from news articlesthat deal with aspects of waiting lines.
4. ClearQ :http://clearq.com/ This company produces take-a-number systems for
servicefacilities (e.g., delis), but also providesperformance information about the waitingline.
5. Qmatic:http://us.q-matic.com/index.htmlThiscompany produces informational displaysandother products to keep customers informedabout waiting times.
6. Queuing Presentation by Richard Larson, givenat the Institute for Operations Researchand the Management.
7. ciences:http://caes.mit.edu/people/larson/MontrealINFORMS1/sld001.htm.8. Queuing Tutor :http://www.dcs.ed.ac.uk/home/jeh/Simjava/queueing/mm1_q/mm1_q.html
This site has twoanimated displays of waiting lines. The user canchange arrival and service
rates to see howperformance is affected.
9. Myron Hlynkas Queuing Page:http:www2.uwindsor.ca/hlynka/queue.html This web site
contains information about waiting linesas well as links to other interesting sites.10. Queuing ToolPak:http://www.bus.ualberta.ca/aingolfsson/qtp/11.The Queuing ToolPak is an Excel add-in that allowsyou to easily compute performance
measures fora number of different waiting line models
http://www2.uwindsor.ca/http://clearq.com/http://us.q-matic.com/index.htmlhttp://caes.mit.edu/people/larson/MontrealINFORMS1/sld001.htmhttp://www.dcs.ed.ac.uk/home/jeh/Simjava/queueihttp://www.bus.ualberta.ca/aingolfsson/qtp/http://www.bus.ualberta.ca/aingolfsson/qtp/http://www.dcs.ed.ac.uk/home/jeh/Simjava/queueihttp://caes.mit.edu/people/larson/MontrealINFORMS1/sld001.htmhttp://us.q-matic.com/index.htmlhttp://clearq.com/http://www2.uwindsor.ca/7/26/2019 ALl Lab Writeup SM 2015 2016
13/50
KJSCE/IT/BE/SEMVIII/SM/2015-16
(Autonomous College Affiliated to University of Mumbai)
Experiment No. : 4
Title: Multi-Serve system (The Able-Baker car hop
problem)
7/26/2019 ALl Lab Writeup SM 2015 2016
14/50
KJSCE/IT/BE/SEMVIII/SM/2015-16
(Autonomous College Affiliated to University of Mumbai)
Batch: Roll No.: Experiment No.:4
Aim: To simulate Multi-Serve system (The Able-Baker carhop problem) using Spreadsheet
Resources needed: Microsoft Excel / Open Office
Theory
Problem Statement:Consider a drive in restaurant where carhops take order and bring food to the cars.
Cars arrive in manner as shown:
Time betweenArrival(minutes)
1 2 3 4
Probability 0.25 0.4 0.2 0.15
There are 2 carhops Able & Baker. Able is better to do the job and works a bit faster than
Baker.
Their service distribution is as follows:
Service time Distribution of Able:
ServiceTime(minutes)
2 3 4 5
Probability 0.3 0.28 0.25 0.17
Service time Distribution of Baker:Servicetime(minutes)
3 4 5 6
Probability 0.35 0.25 0.2 0.2
Able gets the customer if both carhops are idle. The problem is to find how well the current
arrangement is working. Simulate the problem for 1 hour.
Conceptual Model:
- Discrete event model of system used for multichannel queuing. e.g. Able & Baker
problem.- A simulation table is used to record the system snapshots as time proceeds.
- The simulation requires mainly an activity table representing a service timedistribution of Able & Baker & interarrival time of customers.
- Activity duration is specified by a modeller.
Characteristics of System:1. Calling Population: Infinite.2. System capacity: Infinite.
3. Nature of Arrival: Random, probability distribution is given.
4. Service Mechanism: At a time maximum two customers can be served one by Able and
7/26/2019 ALl Lab Writeup SM 2015 2016
15/50
KJSCE/IT/BE/SEMVIII/SM/2015-16
(Autonomous College Affiliated to University of Mumbai)
the other by Baker. If Able & Baker both are busy, the customer has to wait. If bothservers are free, priority goes to Able. Service time for both is random; probability
distribution is given.
5. Queuing Discipline: FIFO.
System State:
1. Status of Able (indicating Able being idle or busy at a given instant).
2. Status of Baker (indicating Baker being idle or busy at a given instant).
3. Time customer spends in the queue
4. Time customer spends in the system
Entities:
Neither the customers nor the server needs to be explicitly represented except in terms
of state variable unless customer averages are desired.
Events:
- Arrival Event- Service Completion by Able- Service completion by Baker.
Delay:A customer waits in queue until Able or Baker becomes free.
Use of Random Numbers:
- To generate random numbers in simulation packages, RANDBETWEEN() of Excelcan be used.- In Able & Baker problem random numbers are used for arranging interarrival times
and service times required for customers.
Real life example:
- Scenarios in shopping centre where two cash counter are available.o Here n number of customers pay the bill.o Customer is chosen in FIFO manner.
Performance measures:
1. Average Waiting Time = (Total time customers wait in queue) / (Total no. of
Customers)
2. Probability Of Customers waiting = (No. of Customers who waits) / (Total no. of
Customers)
3. Probability Of Idle Server = (Total Idle Time Of Server) / (Total runtime of simulation)
4. Average Service Time = (Total Service Time) / (Total no. of Customers)
7/26/2019 ALl Lab Writeup SM 2015 2016
16/50
KJSCE/IT/BE/SEMVIII/SM/2015-16
(Autonomous College Affiliated to University of Mumbai)
5. Average Time between Arrival = (Total Time between arrivals) / (No. of arrivals)
6. Average Waiting Time Of Those Who Wait = (Total Time Customer waits in system) /
(Total no. of Customers)
7. Average Time Customers Spends In System = (Total Time Customer spends in system) /(Total no. of Customers)
Procedure / Approach /Algorithm / Activity Diagram:Semiautomatic approach by using simulation table.
1) Arrival Event:Arrival Event
Able
Busy?
Server
Busy?
Enter service
from Able
Unit Entersservice
Unit Entersqueue
Results: (Program printout as per the format)
Program:(Problem solved using simulation table and the given inputs with MS-Excel)
Output:(In printed form i.e. Simulation tables along with the performance measures and histogram
showing number of customers against waiting time)
Questions:1. What are the steps carried out for System Simulation using Simulation Table
7/26/2019 ALl Lab Writeup SM 2015 2016
17/50
KJSCE/IT/BE/SEMVIII/SM/2015-16
(Autonomous College Affiliated to University of Mumbai)
2. What is the difference between primary event and secondary event? Give oneexample for each event.
7/26/2019 ALl Lab Writeup SM 2015 2016
18/50
KJSCE/IT/BE/SEMVIII/SM/2015-16
(Autonomous College Affiliated to University of Mumbai)
Outcomes:
Conclusion:( Mention the subjective inference on the basis of the performance measures youhave analyzed )
7/26/2019 ALl Lab Writeup SM 2015 2016
19/50
KJSCE/IT/BE/SEMVIII/SM/2015-16
(Autonomous College Affiliated to University of Mumbai)
Grade: AA / AB / BB / BC / CC / CD /DD
Signature of faculty in-charge with date
References:
Books/ Journals/ Websites:
1. Jerry Banks, John Carson, Barry Nelson, and David M. Nicol; Discrete Event SystemSimulation, Fifth Edition, Pearson Education.
2. Jerry Banks, John Carson, Barry Nelson, and David M. Nicol; Discrete Event SystemSimulation, Third Edition, Pearson Education.
3. Real Queuing Examples:http://www2.uwindsor.ca/hlynka/qreal.html This site containsexcerpts from news articlesthat deal with aspects of waiting lines.
4. ClearQ :http://clearq.com/ This company produces take-a-number systems forservicefacilities (e.g., delis), but also providesperformance information about the waiting
line.
5. Qmatic:http://us.q-matic.com/index.htmlThiscompany produces informational displaysandother products to keep customers informedabout waiting times.
6. Queuing Presentation by Richard Larson, givenat the Institute for Operations Researchand the Management.
7. ciences:http://caes.mit.edu/people/larson/MontrealINFORMS1/sld001.htm.8. Queuing Tutor :http://www.dcs.ed.ac.uk/home/jeh/Simjava/queueing/mm1_q/mm1_q.html
This site has twoanimated displays of waiting lines. The user canchange arrival and service
rates to see howperformance is affected.
9. Myron Hlynkas Queuing Page:http:www2.uwindsor.ca/hlynka/queue.html This web sitecontains information about waiting linesas well as links to other interesting sites.
10. Queuing ToolPak:http://www.bus.ualberta.ca/aingolfsson/qtp/11.The Queuing ToolPak is an Excel add-in that allowsyou to easily compute performance
measures fora number of different waiting line models
http://www2.uwindsor.ca/http://clearq.com/http://us.q-matic.com/index.htmlhttp://caes.mit.edu/people/larson/MontrealINFORMS1/sld001.htmhttp://www.dcs.ed.ac.uk/home/jeh/Simjava/queueihttp://www.bus.ualberta.ca/aingolfsson/qtp/http://www.bus.ualberta.ca/aingolfsson/qtp/http://www.dcs.ed.ac.uk/home/jeh/Simjava/queueihttp://caes.mit.edu/people/larson/MontrealINFORMS1/sld001.htmhttp://us.q-matic.com/index.htmlhttp://clearq.com/http://www2.uwindsor.ca/7/26/2019 ALl Lab Writeup SM 2015 2016
20/50
KJSCE/IT/BE/SEMVIII/SM/2015-16
(Autonomous College Affiliated to University of Mumbai)
Experiment No. : 5
Title: Single Server system (One-operator Barbershop
problem) using a general purpose language
7/26/2019 ALl Lab Writeup SM 2015 2016
21/50
KJSCE/IT/BE/SEMVIII/SM/2015-16
(Autonomous College Affiliated to University of Mumbai)
Batch: Roll No.: Experiment No.:5
Aim: To simulate a Single Server system (One-operator Barbershop problem) using a general
purpose language
Resources needed: C / C++ / java
Theory
Problem Statement:Implement a single-server queuing system for which the interarrival times A1,A2.areindependent and identically distributed (IID) random variables. A customer who arrives and
finds the server idle enters service immediately, and service times S1,S2.of the successive
customers are IID random variables that are independent of the interarrival time. A customer
who arrives and finds the server busy joins the end of the single queue. Upon completing
service for a customer, the server chooses a customer from the queue (if any) in a first-in,
first-out (FIFO) manner.
The simulation will begin in the empty-and-idlestate. The simulation should stop when thenth customer enters service.
Concepts:
Software that is used to develop simulation models can be divided into three categories.
First,there are general purpose languages,such as C,C++. Second,there are simulation
programming languages,examples being GPSS,SIMSCRIPT. Third, there are number of
simulation packages such as ARENA.There are several reasons for choosing a general purpose language, rather than more
powerful simulation software, for introducing computer simulation at this point:
By learning to simulate in a general-purpose language, one must pay attention to
every detail.There will be a greater understanding of how simulations actually operate
and thus less chance of conceptual errors if a switch is later made to high-level
simulation package.
Despite the fact that there is now very good and powerful simulation software
available, it is sometimes necessary to write at least parts of complex simulations in a
general-purpose language if the specific, detailed logic of complex systems is to be
represented faithfully. General-purpose languages are widely available, and entire simulations are sometimes
still written in this way.
Characteristics of Queuing System:
The key elements of queuing system are customers & servers. The term customer can refer to
people, machines, and trucks. The server might refer to receptionist, person etc.
1. Calling population: The population of potential customer is referred to as calling
population. In systems with large population the calling population is usually assumed to be
infinity. E.g. population of potential customer of a bank.
7/26/2019 ALl Lab Writeup SM 2015 2016
22/50
KJSCE/IT/BE/SEMVIII/SM/2015-16
(Autonomous College Affiliated to University of Mumbai)
The actual population may be finite. The main difference between finite & infinite populationis based on the definition of the arrival rate.
2. System Capacity: The system capacity has no limit meaning that any no. of units comes
and waits in the queue. In many queuing system there is a limit to the no. of customers that
may be waiting.
3. Nature of Arrivals: Arrivals for service occur at a time in random fashion and once they
join the waiting line, they are served.
4. Service Mechanism: The units are served in order of their arrival by a single server or a
channel.
5. Queuing Discipline: It refers to the logical ordering of customers that will be chosen for
service when a server becomes busy.
6. State Of System: It is the no. of units in the system & status of server (busy / idle).
7. Events: It is a set of circumstances that causes an instantaneous change in the state of
system
Possible events in a single server system:
The Entry of a unit in the system.
Departure of unit from system on completion of service.
8. Simulation Clock: It is used to track simulation time.
Conceptual Model:The Oneoperator barbershop is simulated by using a program written in a general-purposelanguage to record successive system snapshots as time advances. The simulation requires
mainly a service time distribution and an interarrival time distribution of customers.
Characteristics of Grocery Store checkout counter System:1) Calling Population: Infinite.2) System capacity: Infinite.
3) Nature of Arrival: Random arrival exponentially distributed with mean 1 minute
4) Service Mechanism: At a time only one customer is served; service time is random,
exponentially distributed with mean 0.5 minute
5) Queuing Discipline: FIFO.
System State:1) Waiting time in queue.2) Status of operator (Busy / Idle)
3) Time customer spends in the system.
Entities:The entities in single channel queue are queue & server.
7/26/2019 ALl Lab Writeup SM 2015 2016
23/50
KJSCE/IT/BE/SEMVIII/SM/2015-16
(Autonomous College Affiliated to University of Mumbai)
Events:1) Arrival Event2) Departure Event
Activities:
1. Interarrival time.2. Service time.
Delay:Waiting time in the queue.
Stopping event:
1000th customer enters service
Use of Random Nos.:
- For generating interarrival time- For generating service time
Real life Examples:
1. Customers queuing in the Telephone Bill Payment System
Customers form single channel queue.
Customer is chosen in FIFO manner.
Performance measures:
1. Average delay in queue =(Total time customers wait in queue) / (Total no. of
Customers)
2. Probability. Of Customers waiting =(No. of Customers who waits) / (Total no. of
Customers)
3. Server utilization = (Total busy Time Of Server) / (Total runtime of simulation)
4. Average Time between Arrival = (Total Time between arrivals) / (No. of arrivals)
5. Average Waiting Time of Those Who Wait = (Total Time Customer waits in
system) / (Total no. of Customers)
6. Average Time Customers Spends In System = (Total Time Customer spends in
system) / (Total no. of Customers)
Time simulation ends
7/26/2019 ALl Lab Writeup SM 2015 2016
24/50
KJSCE/IT/BE/SEMVIII/SM/2015-16
(Autonomous College Affiliated to University of Mumbai)
Activity Diagram:
Flowchart Arrival event:
Arrival event
Schedule the next
arrival event
Is the
server
busy?
Add 1 to the
number in queue
Set delay=0
For this customer and
gather statistics
Is the
queue
full?
Add 1 to the number of
customers delayed
Make the srver busy
Store time of arrival
of this customer
Schedule a departure
event for this customer
Return
7/26/2019 ALl Lab Writeup SM 2015 2016
25/50
KJSCE/IT/BE/SEMVIII/SM/2015-16
(Autonomous College Affiliated to University of Mumbai)
Flowchart Departure event:
Departure
event
Is queue
empty?
Make the server
idle
Substract 1 from the
number in queue
Eliminate departure
event from the
consideration
Compute delay of
customer entering service
and gather statistics
Add 1 to the number of
customers delayed
Schedule a departureevent for this customer
Move each customer in
queue (if any)up one place
Return
7/26/2019 ALl Lab Writeup SM 2015 2016
26/50
KJSCE/IT/BE/SEMVIII/SM/2015-16
(Autonomous College Affiliated to University of Mumbai)
Results: (Program printout with output as per the format)
Questions:
1. Name a few special purpose simulation languages and simulation packages?
2. Name any two features that are relevant when selecting simulating simulation
software.
7/26/2019 ALl Lab Writeup SM 2015 2016
27/50
KJSCE/IT/BE/SEMVIII/SM/2015-16
(Autonomous College Affiliated to University of Mumbai)
Outcomes:
Conclusion:
Grade: AA / AB / BB / BC / CC / CD /DD
Signature of faculty in-charge with date
References:
Books/ Journals/ Websites:
1. Jerry Banks, John Carson, Barry Nelson, and David M. Nicol; Discrete Event SystemSimulation, Fifth Edition, Pearson Education.
2. Jerry Banks, John Carson, Barry Nelson, and David M. Nicol; Discrete Event SystemSimulation, Third Edition, Pearson Education.
3. Real Queuing Examples:http://www2.uwindsor.ca/hlynka/qreal.html This site containsexcerpts from news articlesthat deal with aspects of waiting lines.
4. ClearQ :http://clearq.com/ This company produces take-a-number systems forservicefacilities (e.g., delis), but also providesperformance information about the waiting
line.
5. Qmatic:http://us.q-matic.com/index.htmlThiscompany produces informational displaysandother products to keep customers informedabout waiting times.
6. Queuing Presentation by Richard Larson, givenat the Institute for Operations Researchand the Management.
7. ciences:http://caes.mit.edu/people/larson/MontrealINFORMS1/sld001.htm.8. Queuing Tutor :http://www.dcs.ed.ac.uk/home/jeh/Simjava/queueing/mm1_q/mm1_q.html
This site has twoanimated displays of waiting lines. The user canchange arrival and service
rates to see howperformance is affected.
9. Myron Hlynkas Queuing Page:http:www2.uwindsor.ca/hlynka/queue.html This web sitecontains information about waiting linesas well as links to other interesting sites.
10. Queuing ToolPak:http://www.bus.ualberta.ca/aingolfsson/qtp/11.The Queuing ToolPak is an Excel add-in that allowsyou to easily compute performance
measures fora number of different waiting line models
http://www2.uwindsor.ca/http://clearq.com/http://us.q-matic.com/index.htmlhttp://caes.mit.edu/people/larson/MontrealINFORMS1/sld001.htmhttp://www.dcs.ed.ac.uk/home/jeh/Simjava/queueihttp://www.bus.ualberta.ca/aingolfsson/qtp/http://www.bus.ualberta.ca/aingolfsson/qtp/http://www.dcs.ed.ac.uk/home/jeh/Simjava/queueihttp://caes.mit.edu/people/larson/MontrealINFORMS1/sld001.htmhttp://us.q-matic.com/index.htmlhttp://clearq.com/http://www2.uwindsor.ca/7/26/2019 ALl Lab Writeup SM 2015 2016
28/50
KJSCE/IT/BE/SEMVIII/SM/2015-1
(Autonomous College Affiliated to University of Mumbai)
Experiment No.: 6
Title: Implementation of Uniformity test
7/26/2019 ALl Lab Writeup SM 2015 2016
29/50
KJSCE/IT/BE/SEMVIII/SM/2015-1
(Autonomous College Affiliated to University of Mumbai)
Batch: Roll No.: Experiment No.: 6
Aim: To implement Kolmogorov -Smirnov test or Chi-square test to perform uniformity test
of generated random numbers.
Resources needed: Turbo C / Java
Theory
Problem Statement:Write function in C / C++ / java or macros in MS-excel to implement Kolmogorov-Smirnovtest or Chi-square test.
Concepts:
Random Numbers generated using a known process or algorithm is called Pseudo random
Number.The random numbers generates must possess the property of :
1. Uniformity
2. Independence
Uniformity :
If the interval (0, 1) is divided into nclasses or subintervals of equal length , the expected
number of observations in each interval is N/n, where N is total number of observations.
Independence:
The probability of observing a value in a particular interval is independent of the previous
drawn value.
Each random number R must be an independent sample drawn from a continuous uniformdistribution between 0 & 1
i.e.p.d.f. is given byf(x) = 1 0 x 1
0 otherwise
The expected value of each Ri is given by
E(R) = 1
1 0
0x dx = [x2/2 ] = 1/2And variance is given by
1V(R) = 0x2 dx = [x3/3 ] = 1/31/4 = 1/12
Tests for Random numbers
1) Uniformity Test
A basic test that is to be performed to validate a new generator is the test of uniformity. Two
different testing methods are available, they are
a. Kolmogorov- Smirnov Test
b. Chi-square Test
7/26/2019 ALl Lab Writeup SM 2015 2016
30/50
KJSCE/IT/BE/SEMVIII/SM/2015-1
(Autonomous College Affiliated to University of Mumbai)
Both of these measure the degree of agreement between distance of sample of generatedrandom numbers and the theoretical uniform distributions.
1) Kolmogorov-Smirnov Test: This test compares the continuous cdf F(x) of the uniform
distribution to the empirical cdf SN(x) of sample of N distribution
By definition,F(x) = x 0 x 1
If the sample from random no. generated is R1, R2, ,RN then the empirical cdf SN(x) is
defined as
SN(x) =
No. of R1, R2, ,RN which are x
N
As N becomes larger SN(x) should become better approximation to F(x) provided the null
hypothesis is true. The Kolmogorov-Smirnov distance test is best on largest absolute
deviation between F(x) & SN(x) over range of random variable.
2) Chi-square Test: The chi-square test uses sample statistic
2
O i E i
(0)2 =
=1E i
Where, Oi = Observed frequency in ith classEi = Expected frequency in ith class
n = is the no. of classes
Procedure:(Write the algorithm for the test to be implemented and follow the steps given below)Steps:
Implement either Kolmogorov-Smirnov Test or Chi-square Test using C / C++ / java
or macros in MS-excel
Generate 5 sample sets (Each set consisting of 100 random numbers) of Pseudorandom numbers using Linear Congruential Method.
Execute the test using all the five sample sets of random numbers as input and using
=0.05.
Draw conclusions on the acceptance or rejection of the null hypothesis of
independence.
Results: (Program printout with output)
7/26/2019 ALl Lab Writeup SM 2015 2016
31/50
KJSCE/IT/BE/SEMVIII/SM/2015-1
(Autonomous College Affiliated to University of Mumbai)
Questions:
3. List down the pros and cons of the Kolmogorov - Smirnov test and Chi- Square test.
Outcomes:
Conclusion:
Grade: AA / AB / BB / BC / CC / CD /DD
Signature of faculty in-charge with date
7/26/2019 ALl Lab Writeup SM 2015 2016
32/50
KJSCE/IT/BE/SEMVIII/SM/2015-1
(Autonomous College Affiliated to University of Mumbai)
References:
Books/ Journals/ Websites:
1. "Linear Congruential Generators"by Joe Bolte,Wolfram Demonstrations Project.2. Severance, Frank (2001). System Modeling and Simulation. John Wiley & Sons, Ltd.
p. 86.ISBN 0-471-49694-4.
3. The GNU C library's rand() instdlib.h uses a simple (single state) linear congruential
generator only in case that the state is declared as 8 bytes. If the state is larger (an
array), the generator becomes an additive feedback generator and the period increases.
See thesimplified code that reproduces the random sequence from this library.
4. "A collection of selected pseudorandom number generators with linear structures, K.
Entacher, 1997". Retrieved 16 June 2012.
5. "How Visual Basic Generates Pseudo-Random Numbers for the RND Function".
Microsoft Support. Microsoft. Retrieved 17 June 2011.
6. In spite of documentation on MSDN, RtlUniform uses LCG, and not Lehmer's
algorithm, implementations beforeWindows Vista are flawed, because the result of
multiplication is cut to 32 bits, before modulo is applied
7. GNU Scientific Library: Other random number generators
8. Novice Forth library9. Matsumoto, Makoto, and Takuji Nishimura (1998) ACM Transactions on Modeling
and Computer Simulation
10. S.K. Park and K.W. Miller (1988)."Random Number Generators: Good Ones Are
Hard To Find". Communications of the ACM31 (10): 11921201.
doi:10.1145/63039.63042.
11.D. E. Knuth. The Art of Computer Programming, Volume 2: SeminumericalAlgorithms, Third Edition. Addison-Wesley, 1997.ISBN 0-201-89684-2. Section
3.2.1: The Linear Congruential Method, pp. 1026.
12. P. L'Ecuyer (1999)."Tables of Linear Congruential Generators of Different Sizes and
Good Lattice Structure".Mathematics of Computation68 (225): 249260.
doi:10.1090/S0025-5718-99-00996-5.
13. Press, WH; Teukolsky, SA; Vetterling, WT; Flannery, BP (2007),"Section 7.1.1.
Some History",Numerical Recipes: The Art of Scientific Computing (3rd ed.), New
York: Cambridge University Press,ISBN 978-0-521-88068-8
14. Gentle, James E., (2003).Random Number Generation and Monte Carlo Methods, 2nd
edition, Springer,ISBN 0-387-00178-6.
15. Joan Boyar (1989)."Inferring sequences produced by pseudo-random numbergenerators".Journal of the ACM36 (1): 129141.doi:10.1145/58562.59305. (in this
paper, efficient algorithms are given for inferring sequences produced by certain
pseudo-random number generators).
http://demonstrations.wolfram.com/LinearCongruentialGenerators/http://demonstrations.wolfram.com/LinearCongruentialGenerators/http://demonstrations.wolfram.com/LinearCongruentialGenerators/http://en.wikipedia.org/wiki/Wolfram_Demonstrations_Projecthttp://en.wikipedia.org/wiki/Wolfram_Demonstrations_Projecthttp://en.wikipedia.org/wiki/Wolfram_Demonstrations_Projecthttp://en.wikipedia.org/wiki/International_Standard_Book_Numberhttp://en.wikipedia.org/wiki/International_Standard_Book_Numberhttp://en.wikipedia.org/wiki/International_Standard_Book_Numberhttp://en.wikipedia.org/wiki/Stdlib.hhttp://en.wikipedia.org/wiki/Stdlib.hhttp://en.wikipedia.org/wiki/Stdlib.hhttp://www.mscs.dal.ca/~selinger/random/http://www.mscs.dal.ca/~selinger/random/http://www.mscs.dal.ca/~selinger/random/http://citeseer.ist.psu.edu/viewdoc/download?doi=10.1.1.53.3686&rep=rep1&type=pdfhttp://citeseer.ist.psu.edu/viewdoc/download?doi=10.1.1.53.3686&rep=rep1&type=pdfhttp://citeseer.ist.psu.edu/viewdoc/download?doi=10.1.1.53.3686&rep=rep1&type=pdfhttp://citeseer.ist.psu.edu/viewdoc/download?doi=10.1.1.53.3686&rep=rep1&type=pdfhttp://citeseer.ist.psu.edu/viewdoc/download?doi=10.1.1.53.3686&rep=rep1&type=pdfhttp://support.microsoft.com/kb/231847http://support.microsoft.com/kb/231847http://msdn.microsoft.com/en-us/library/bb432429%28VS.85%29.aspxhttp://msdn.microsoft.com/en-us/library/bb432429%28VS.85%29.aspxhttp://en.wikipedia.org/wiki/Windows_Vistahttp://en.wikipedia.org/wiki/Windows_Vistahttp://en.wikipedia.org/wiki/Windows_Vistahttp://www.gnu.org/software/gsl/manual/html_node/Other-random-number-generators.htmlhttp://www.gnu.org/software/gsl/manual/html_node/Other-random-number-generators.htmlhttp://www.gnu.org/software/gsl/manual/html_node/Other-random-number-generators.htmlhttp://www.forth.org/novice.htmlhttp://www.forth.org/novice.htmlhttp://portal.acm.org/citation.cfm?id=63042http://portal.acm.org/citation.cfm?id=63042http://portal.acm.org/citation.cfm?id=63042http://portal.acm.org/citation.cfm?id=63042http://portal.acm.org/citation.cfm?id=63042http://portal.acm.org/citation.cfm?id=63042http://en.wikipedia.org/wiki/Digital_object_identifierhttp://en.wikipedia.org/wiki/Digital_object_identifierhttp://en.wikipedia.org/wiki/Digital_object_identifierhttp://en.wikipedia.org/wiki/Digital_object_identifierhttp://en.wikipedia.org/wiki/Donald_Knuthhttp://en.wikipedia.org/wiki/Donald_Knuthhttp://en.wikipedia.org/wiki/Donald_Knuthhttp://en.wikipedia.org/wiki/Special:BookSources/0201896842http://en.wikipedia.org/wiki/Special:BookSources/0201896842http://en.wikipedia.org/wiki/Special:BookSources/0201896842http://citeseer.ist.psu.edu/132363.htmlhttp://citeseer.ist.psu.edu/132363.htmlhttp://citeseer.ist.psu.edu/132363.htmlhttp://citeseer.ist.psu.edu/132363.htmlhttp://citeseer.ist.psu.edu/132363.htmlhttp://citeseer.ist.psu.edu/132363.htmlhttp://en.wikipedia.org/wiki/Digital_object_identifierhttp://en.wikipedia.org/wiki/Digital_object_identifierhttp://en.wikipedia.org/wiki/Digital_object_identifierhttp://en.wikipedia.org/wiki/Digital_object_identifierhttp://apps.nrbook.com/empanel/index.html#pg=343http://apps.nrbook.com/empanel/index.html#pg=343http://apps.nrbook.com/empanel/index.html#pg=343http://apps.nrbook.com/empanel/index.html#pg=343http://apps.nrbook.com/empanel/index.html#pg=343http://en.wikipedia.org/wiki/International_Standard_Book_Numberhttp://en.wikipedia.org/wiki/International_Standard_Book_Numberhttp://en.wikipedia.org/wiki/International_Standard_Book_Numberhttp://en.wikipedia.org/wiki/Special:BookSources/0387001786http://en.wikipedia.org/wiki/Special:BookSources/0387001786http://en.wikipedia.org/wiki/Special:BookSources/0387001786http://portal.acm.org/citation.cfm?id=59305&dl=ACM&coll=portalhttp://portal.acm.org/citation.cfm?id=59305&dl=ACM&coll=portalhttp://portal.acm.org/citation.cfm?id=59305&dl=ACM&coll=portalhttp://portal.acm.org/citation.cfm?id=59305&dl=ACM&coll=portalhttp://portal.acm.org/citation.cfm?id=59305&dl=ACM&coll=portalhttp://portal.acm.org/citation.cfm?id=59305&dl=ACM&coll=portalhttp://en.wikipedia.org/wiki/Digital_object_identifierhttp://en.wikipedia.org/wiki/Digital_object_identifierhttp://en.wikipedia.org/wiki/Digital_object_identifierhttp://en.wikipedia.org/wiki/Digital_object_identifierhttp://en.wikipedia.org/wiki/Digital_object_identifierhttp://en.wikipedia.org/wiki/Digital_object_identifierhttp://en.wikipedia.org/wiki/Digital_object_identifierhttp://portal.acm.org/citation.cfm?id=59305&dl=ACM&coll=portalhttp://portal.acm.org/citation.cfm?id=59305&dl=ACM&coll=portalhttp://en.wikipedia.org/wiki/Special:BookSources/0387001786http://en.wikipedia.org/wiki/International_Standard_Book_Numberhttp://apps.nrbook.com/empanel/index.html#pg=343http://apps.nrbook.com/empanel/index.html#pg=343http://en.wikipedia.org/wiki/Digital_object_identifierhttp://en.wikipedia.org/wiki/Digital_object_identifierhttp://citeseer.ist.psu.edu/132363.htmlhttp://citeseer.ist.psu.edu/132363.htmlhttp://en.wikipedia.org/wiki/Special:BookSources/0201896842http://en.wikipedia.org/wiki/Donald_Knuthhttp://en.wikipedia.org/wiki/Digital_object_identifierhttp://en.wikipedia.org/wiki/Digital_object_identifierhttp://portal.acm.org/citation.cfm?id=63042http://portal.acm.org/citation.cfm?id=63042http://www.forth.org/novice.htmlhttp://www.gnu.org/software/gsl/manual/html_node/Other-random-number-generators.htmlhttp://en.wikipedia.org/wiki/Windows_Vistahttp://msdn.microsoft.com/en-us/library/bb432429%28VS.85%29.aspxhttp://support.microsoft.com/kb/231847http://citeseer.ist.psu.edu/viewdoc/download?doi=10.1.1.53.3686&rep=rep1&type=pdfhttp://citeseer.ist.psu.edu/viewdoc/download?doi=10.1.1.53.3686&rep=rep1&type=pdfhttp://www.mscs.dal.ca/~selinger/random/http://en.wikipedia.org/wiki/Stdlib.hhttp://en.wikipedia.org/wiki/International_Standard_Book_Numberhttp://en.wikipedia.org/wiki/Wolfram_Demonstrations_Projecthttp://demonstrations.wolfram.com/LinearCongruentialGenerators/7/26/2019 ALl Lab Writeup SM 2015 2016
33/50
KJSCE/IT/BE/SEMVIII/SM/2015-1
(Autonomous College Affiliated to University of Mumbai)
Experiment No.: 7
Title: Implementation of Frequency test
7/26/2019 ALl Lab Writeup SM 2015 2016
34/50
KJSCE/IT/BE/SEMVIII/SM/2015-1
(Autonomous College Affiliated to University of Mumbai)
Batch: Roll No.: Experiment No.:7
Aim: To implement Autocorrelation test to perform frequency test for the generated
random numbers.
Resources needed: Turbo C / Java
Theory
Problem Statement:Write function in C / C++ / java or macros in MS-excel to implement Autocorrelation test .
Concepts:
Random Numbers generated using a known process or algorithm is called Pseudo random
Number. The random numbers generates must possess the property of :
3. Uniformity
4. Independence
Uniformity :
If the interval (0, 1) is divided into nclasses or subintervals of equal length , the expected
number of observations in each interval is N/n, where N is total number of observations.
Independence:
The probability of observing a value in a particular interval is independent of the previous
drawn value.Each random number R must be an independent sample drawn from a continuous uniform
distribution between 0 & 1
i.e.p.d.f. is given by
f(x) = 1 0 x 1
1 otherwise
The expected value of each Ri is given by
E(R) = 1
1 0
0x dx = [x2/2 ] = 1/2
And variance is given by1
V(R) = 0x2 dx = [x3/3 ] = 1/31/4 = 1/12
Tests for Independence:
These tests are done to check the independence of sequence of random numbers.
1)Runs Test
This test analyses an orderly grouping of numbers in a sequence to test the hypothesis of
independence
7/26/2019 ALl Lab Writeup SM 2015 2016
35/50
KJSCE/IT/BE/SEMVIII/SM/2015-1
(Autonomous College Affiliated to University of Mumbai)
The Runs test used are:i) Runs Up and Down
ii) Runs above and below the mean
iii) Runs test for testing length of runs
2) Auto correlation Test: The test for auto correlation is concerned with dependencebetween numbers in a sequence. The test computes auto correlation between every m
numbers starting with the ith number. Thus autocorrelation limit between following numbers
would be of interest.
Ri, Ri+m, Ri+2m, Ri+(M+1)mwhereM is the largest integer such that i+(M+1)m N where N is total number of values in
the sequence.Since the nonzero autocorrelation implies a lack of independence, the following test is
appropriate:
H 0 :
H1 :
im 0,
im 0,
if numbers are independen t
if numbers are dependent
For large values of M, the distribution of the estimator of im, denoted
normal,if the valuesRi, Ri+m, Ri+2m, Ri+(M+1)m are uncorrelated.
The test statistics is
im is approximately
Z0
im
im
with a mean of 0 and variance of 1,under the assumption of independence , for large M.If -Z/2 Z0 Z/2 , H0 is rejected for the significance level .
3)Gap Test: The gap test is used to determine the significance of the interval between
reoccurrence of the same digit. A gap of length x occurs between reoccurrence of same digit.
4)Poker Test: The poker test for independence is based on frequency with which certain
digits are repeated in a series of numbers in each case a pair of like digits appear in the
numbers that were generated. In 3 digit sample of numbers there are three possibilities which
are as follows:
i) The individual numbers can all be different
ii) The individual numbers can all be same
iii) There can be one pair of like digits.
Procedure:(Write the algorithm for the Autocorrelation test and follow the steps given below)
Steps:
Implement Autocorrelation test using C / C++ / java or macros in MS-excel.
Generate 5 sample sets (Each set consisting of 100 random numbers) of random
numbers using random number generator developed in the first experiment.
Execute the test using all the five sample sets of random number as input and using
=0.05.
Draw conclusions on the acceptance or rejection of the null hypothesis of
independence.
7/26/2019 ALl Lab Writeup SM 2015 2016
36/50
KJSCE/IT/BE/SEMVIII/SM/2015-1
(Autonomous College Affiliated to University of Mumbai)
Results: (Program printout with output)
Questions:
1. Define the hypothesis for
a) Testing of Uniformity
b) Testing of Independence
Outcomes:
Conclusion:
7/26/2019 ALl Lab Writeup SM 2015 2016
37/50
KJSCE/IT/BE/SEMVIII/SM/2015-1
(Autonomous College Affiliated to University of Mumbai)
Grade: AA / AB / BB / BC / CC / CD /DD
Signature of faculty in-charge with date
References:
Books/ Journals/ Websites:
1. Linear Congruential Generators"by Joe Bolte,Wolfram Demonstrations Project.
2. Severance, Frank (2001). System Modeling and Simulation. John Wiley & Sons, Ltd.
p. 86.ISBN 0-471-49694-4.
3. The GNU C library's rand() instdlib.h uses a simple (single state) linear congruential
generator only in case that the state is declared as 8 bytes. If the state is larger (an
array), the generator becomes an additive feedback generator and the period increases.
See thesimplified code that reproduces the random sequence from this library.
4. "A collection of selected pseudorandom number generators with linear structures, K.
Entacher, 1997". Retrieved 16 June 2012.
5. "How Visual Basic Generates Pseudo-Random Numbers for the RND Function".
Microsoft Support. Microsoft. Retrieved 17 June 2011.
6. In spite of documentation onMSDN, RtlUniform uses LCG, and not Lehmer's
algorithm, implementations beforeWindows Vista are flawed, because the result ofmultiplication is cut to 32 bits, before modulo is applied
7. GNU Scientific Library: Other random number generators
8. Novice Forth library
9. Matsumoto, Makoto, and Takuji Nishimura (1998) ACM Transactions on Modeling
and Computer Simulation
10. S.K. Park and K.W. Miller (1988)."Random Number Generators: Good Ones Are
Hard To Find". Communications of the ACM31 (10): 11921201.
doi:10.1145/63039.63042.
11.D. E. Knuth. The Art of Computer Programming, Volume 2: Seminumerical
Algorithms, Third Edition. Addison-Wesley, 1997.ISBN 0-201-89684-2. Section
3.2.1: The Linear Congruential Method, pp. 1026.12. P. L'Ecuyer (1999)."Tables of Linear Congruential Generators of Different Sizes and
Good Lattice Structure".Mathematics of Computation68 (225): 249260.
doi:10.1090/S0025-5718-99-00996-5.
13. Press, WH; Teukolsky, SA; Vetterling, WT; Flannery, BP (2007),"Section 7.1.1.
Some History",Numerical Recipes: The Art of Scientific Computing (3rd ed.), New
York: Cambridge University Press,ISBN 978-0-521-88068-8
14. Gentle, James E., (2003).Random Number Generation and Monte Carlo Methods,
2nd edition, Springer,ISBN 0-387-00178-6.
15. Joan Boyar (1989)."Inferring sequences produced by pseudo-random number
generators".Journal of the ACM36 (1): 129141.doi:10.1145/58562.59305. (in this
paper, efficient algorithms are given for inferring sequences produced by certainpseudo-random number generators).
http://demonstrations.wolfram.com/LinearCongruentialGenerators/http://demonstrations.wolfram.com/LinearCongruentialGenerators/http://en.wikipedia.org/wiki/Wolfram_Demonstrations_Projecthttp://en.wikipedia.org/wiki/Wolfram_Demonstrations_Projecthttp://en.wikipedia.org/wiki/Wolfram_Demonstrations_Projecthttp://en.wikipedia.org/wiki/International_Standard_Book_Numberhttp://en.wikipedia.org/wiki/International_Standard_Book_Numberhttp://en.wikipedia.org/wiki/International_Standard_Book_Numberhttp://en.wikipedia.org/wiki/Stdlib.hhttp://en.wikipedia.org/wiki/Stdlib.hhttp://en.wikipedia.org/wiki/Stdlib.hhttp://www.mscs.dal.ca/~selinger/random/http://www.mscs.dal.ca/~selinger/random/http://www.mscs.dal.ca/~selinger/random/http://citeseer.ist.psu.edu/viewdoc/download?doi=10.1.1.53.3686&rep=rep1&type=pdfhttp://citeseer.ist.psu.edu/viewdoc/download?doi=10.1.1.53.3686&rep=rep1&type=pdfhttp://citeseer.ist.psu.edu/viewdoc/download?doi=10.1.1.53.3686&rep=rep1&type=pdfhttp://citeseer.ist.psu.edu/viewdoc/download?doi=10.1.1.53.3686&rep=rep1&type=pdfhttp://support.microsoft.com/kb/231847http://support.microsoft.com/kb/231847http://msdn.microsoft.com/en-us/library/bb432429%28VS.85%29.aspxhttp://msdn.microsoft.com/en-us/library/bb432429%28VS.85%29.aspxhttp://msdn.microsoft.com/en-us/library/bb432429%28VS.85%29.aspxhttp://en.wikipedia.org/wiki/Windows_Vistahttp://en.wikipedia.org/wiki/Windows_Vistahttp://en.wikipedia.org/wiki/Windows_Vistahttp://www.gnu.org/software/gsl/manual/html_node/Other-random-number-generators.htmlhttp://www.gnu.org/software/gsl/manual/html_node/Other-random-number-generators.htmlhttp://www.forth.org/novice.htmlhttp://www.forth.org/novice.htmlhttp://portal.acm.org/citation.cfm?id=63042http://portal.acm.org/citation.cfm?id=63042http://portal.acm.org/citation.cfm?id=63042http://portal.acm.org/citation.cfm?id=63042http://portal.acm.org/citation.cfm?id=63042http://portal.acm.org/citation.cfm?id=63042http://en.wikipedia.org/wiki/Digital_object_identifierhttp://en.wikipedia.org/wiki/Digital_object_identifierhttp://en.wikipedia.org/wiki/Digital_object_identifierhttp://en.wikipedia.org/wiki/Digital_object_identifierhttp://en.wikipedia.org/wiki/Donald_Knuthhttp://en.wikipedia.org/wiki/Donald_Knuthhttp://en.wikipedia.org/wiki/Donald_Knuthhttp://en.wikipedia.org/wiki/Donald_Knuthhttp://en.wikipedia.org/wiki/Special:BookSources/0201896842http://en.wikipedia.org/wiki/Special:BookSources/0201896842http://en.wikipedia.org/wiki/Special:BookSources/0201896842http://citeseer.ist.psu.edu/132363.htmlhttp://citeseer.ist.psu.edu/132363.htmlhttp://citeseer.ist.psu.edu/132363.htmlhttp://citeseer.ist.psu.edu/132363.htmlhttp://citeseer.ist.psu.edu/132363.htmlhttp://citeseer.ist.psu.edu/132363.htmlhttp://en.wikipedia.org/wiki/Digital_object_identifierhttp://en.wikipedia.org/wiki/Digital_object_identifierhttp://en.wikipedia.org/wiki/Digital_object_identifierhttp://en.wikipedia.org/wiki/Digital_object_identifierhttp://apps.nrbook.com/empanel/index.html#pg=343http://apps.nrbook.com/empanel/index.html#pg=343http://apps.nrbook.com/empanel/index.html#pg=343http://apps.nrbook.com/empanel/index.html#pg=343http://apps.nrbook.com/empanel/index.html#pg=343http://apps.nrbook.com/empanel/index.html#pg=343http://en.wikipedia.org/wiki/International_Standard_Book_Numberhttp://en.wikipedia.org/wiki/International_Standard_Book_Numberhttp://en.wikipedia.org/wiki/International_Standard_Book_Numberhttp://en.wikipedia.org/wiki/Special:BookSources/0387001786http://en.wikipedia.org/wiki/Special:BookSources/0387001786http://en.wikipedia.org/wiki/Special:BookSources/0387001786http://portal.acm.org/citation.cfm?id=59305&dl=ACM&coll=portalhttp://portal.acm.org/citation.cfm?id=59305&dl=ACM&coll=portalhttp://portal.acm.org/citation.cfm?id=59305&dl=ACM&coll=portalhttp://portal.acm.org/citation.cfm?id=59305&dl=ACM&coll=portalhttp://portal.acm.org/citation.cfm?id=59305&dl=ACM&coll=portalhttp://portal.acm.org/citation.cfm?id=59305&dl=ACM&coll=portalhttp://en.wikipedia.org/wiki/Digital_object_identifierhttp://en.wikipedia.org/wiki/Digital_object_identifierhttp://en.wikipedia.org/wiki/Digital_object_identifierhttp://en.wikipedia.org/wiki/Digital_object_identifierhttp://en.wikipedia.org/wiki/Digital_object_identifierhttp://en.wikipedia.org/wiki/Digital_object_identifierhttp://en.wikipedia.org/wiki/Digital_object_identifierhttp://portal.acm.org/citation.cfm?id=59305&dl=ACM&coll=portalhttp://portal.acm.org/citation.cfm?id=59305&dl=ACM&coll=portalhttp://en.wikipedia.org/wiki/Special:BookSources/0387001786http://en.wikipedia.org/wiki/International_Standard_Book_Numberhttp://apps.nrbook.com/empanel/index.html#pg=343http://apps.nrbook.com/empanel/index.html#pg=343http://en.wikipedia.org/wiki/Digital_object_identifierhttp://en.wikipedia.org/wiki/Digital_object_identifierhttp://citeseer.ist.psu.edu/132363.htmlhttp://citeseer.ist.psu.edu/132363.htmlhttp://en.wikipedia.org/wiki/Special:BookSources/0201896842http://en.wikipedia.org/wiki/Donald_Knuthhttp://en.wikipedia.org/wiki/Digital_object_identifierhttp://en.wikipedia.org/wiki/Digital_object_identifierhttp://portal.acm.org/citation.cfm?id=63042http://portal.acm.org/citation.cfm?id=63042http://www.forth.org/novice.htmlhttp://www.gnu.org/software/gsl/manual/html_node/Other-random-number-generators.htmlhttp://en.wikipedia.org/wiki/Windows_Vistahttp://msdn.microsoft.com/en-us/library/bb432429%28VS.85%29.aspxhttp://support.microsoft.com/kb/231847http://citeseer.ist.psu.edu/viewdoc/download?doi=10.1.1.53.3686&rep=rep1&type=pdfhttp://citeseer.ist.psu.edu/viewdoc/download?doi=10.1.1.53.3686&rep=rep1&type=pdfhttp://www.mscs.dal.ca/~selinger/random/http://en.wikipedia.org/wiki/Stdlib.hhttp://en.wikipedia.org/wiki/International_Standard_Book_Numberhttp://en.wikipedia.org/wiki/Wolfram_Demonstrations_Projecthttp://demonstrations.wolfram.com/LinearCongruentialGenerators/7/26/2019 ALl Lab Writeup SM 2015 2016
38/50
KJSCE/IT/BE/SEMVIII/SM/2015-1
(Autonomous College Affiliated to University of Mumbai)
Experiment No. 8
Title: Simulation of Cafeteria
7/26/2019 ALl Lab Writeup SM 2015 2016
39/50
7/26/2019 ALl Lab Writeup SM 2015 2016
40/50
KJSCE/IT/BE/SEMVIII/SM/2015-1
(Autonomous College Affiliated to University of Mumbai)
Procedure:(Write the algorithm for the Autocorrelation test and follow the steps given below)
Steps:Starting a model and setting simulation parameters
The following steps are typical when starting any discrete event model.
Open a new model worksheet Give the command Run > Simulation Setup. In the Setup tab enter the simulation
parameters:
o Global time units: seconds
If they arent already open, open the Item, Plotter, and Value libraries Place an Executive block (Item library) on the top left corner of the model worksheet
Open dialog of the Executive block ; control tab; select options;
o Stop Simulation: when count connector value>= ; enter 100.
The Executive block does event scheduling and manages discrete event simulations. It must
be present in every discrete event model.
Start small
In building any simulation model, it is easiest to start with a simple subset of the process andadd detail until you arrive at a completed model that approximates the system thats being
modelled. This allows you to test at various stages while making the model building process
more manageable.
The following table lists the blocks that will be added to the worksheet and their use in the
model.
Except for the Plotter block from the Plotter library and random number block from value
library, the blocks in the table are from the Item library.
Name (Label) Block Function
Create block (customers) Generates items or values, either randomly or on
schedule. If used to generate items, it pushes them into
the simulation and should be followed by a queue-type
block.
Purpose in Cafeteria Model
Generates customers that arrive as per Poisson process
Set (Item > Properties) Attaches user-assigned properties (attribute, priority,
and quantity) to items passing through.
7/26/2019 ALl Lab Writeup SM 2015 2016
41/50
KJSCE/IT/BE/SEMVIII/SM/2015-16
(Autonomous College Affiliated to University of Mumbai)
Purpose in Cafeteria Model
Set property as preference (sandwich or meal) and further dessert or no dessert
Queue block(Entry Line) Acts as a sorted queue or as a resource pool queue. As a
sorted queue, holds items in FIFO or LIFO order, orsorts items based on their attribute or priority.
Purpose in Cafeteria Model
Holds the customers and, when the server is available, releases one by one in first-in, first-out
order.
Select I tem I n (Item > Routing) Selects an input and outputs its item.
Purpose in Cafeteria Model
For merging two inputs (customers coming from sandwich counter and meal counter
towards) and output one (one cashier).
Select I tem Out (Item > Routing) Sends each item it gets to a selected O/P
Purpose in Cafeteria Model
Apply the routing rule 40% go to sandwich counter, others go to meal counter and the dessert
routing rule 10% have dessert and others dont have.
Activity block(Server) Processes one or more items simultaneously. Processing
time is a constant or is based on a distribution or an
itemsattribute.
Purpose in cafeteria Model
Serves the customers as per the service distribution i.e. exponentially distributed
Random Number block Generates random numbers
Purpose in cafeteria Model
Outputs values to a Set block as per the look up table
Exit (Exit) Removes items from the simulation and counts them as
they leave.
Purpose in Cafeteria Model
Exits the customers from the model.
7/26/2019 ALl Lab Writeup SM 2015 2016
42/50
KJSCE/IT/BE/SEMVIII/SM/2015-16
(Autonomous College Affiliated to University of Mumbai)
Plotter, Discrete Event
Purpose in Cafeteria Model
Reports the length of the waiting line and how many jobs has been processed.
Starting at the right of the Executive block, place the blocks on the model worksheet
in a line from left to right, based on their order in the table.
Label the blocks as the system entities.
Enter the dialog parameters and settings for each block
Make the connections
Run the simulation
Verify the results
Animate the model
Results: (Program printout with output)Program: (Printed model developed in Extend Sim)
Output: (Printed results i.e. the plotter data)
Questions:
1. List down the benefits of using a special purpose package such as Extend Sim to
implement and run the simulation problem
7/26/2019 ALl Lab Writeup SM 2015 2016
43/50
KJSCE/IT/BE/SEMVIII/SM/2015-16
(Autonomous College Affiliated to University of Mumbai)
Outcomes:
Conclusion:
Grade: AA / AB / BB / BC / CC / CD /DD
Signature of faculty in-charge with date
References References:
Books/ Journals/ Websites:
1. Jerry Banks, John Carson, Barry Nelson, and David M. Nicol; Discrete Event SystemSimulation, Fifth Edition, Pearson Education.
2. Jerry Banks, John Carson, Barry Nelson, and David M. Nicol; Discrete Event SystemSimulation, Third Edition, Pearson Education.
3. ExtendSim 8 Manual (Departmental Library)
7/26/2019 ALl Lab Writeup SM 2015 2016
44/50
KJSCE/IT/BE/SEMVIII/SM/2015-16
(Autonomous College Affiliated to University of Mumbai)
Experiment No.: 9
Title: Simulation of Manufacturing System
Page No:
7/26/2019 ALl Lab Writeup SM 2015 2016
45/50
KJSCE/IT/BE/SEMVIII/SM/2015-16
(Autonomous College Affiliated to University of Mumbai)
Batch: Roll No.: Experiment No.: 9
Aim: To Implement the model for Manufacturing System using Extend Sim and estimate
system performance
Resources needed: Extend Sim 7
Theory
Problem Statement:In a manufacturing unit three types of items (numbered as 1, 2, or 3 depending on the typeof item it will be) arrive on an assembly line exponentially with a mean 1.Out of these 25%
are type 1; 50% are type 2 and 25 % are type 3 respectively. At one step of the assembly
process, there are four machines. Two of the machines can work on all three types, but oneof the machines is old and can work on types 1 and 2, and the fourth machine can only
work on type 3. All the machines process one item at a time and take constant time of one
unit to process each item. Plot the utilization of each machine.
Model the problem as a queuing system.
Animate the model in 2D.
Run the simulation till 480 min I,e 8 hours.
Plot and verify the following results Length of the queue against the number of jobs exited from the system.
Concepts:
A basic discrete event modelThe most common discrete event model involves the handling of one or more waiting linesor queues, such as those found in supermarkets or factories.
Conceptual Model assumptions:
The Job Shop model represents a business operation where Jobs can be processed.
The assumptions for the model are:
Themodel runs for a simulated time of 8 hours (480 minutes)
Arrival of the items is exponentially distributed with a mean of 1.
Processing times for jobs are constant (I unit each)
Theblocks come from the Item, Value, and Plotter libraries
7/26/2019 ALl Lab Writeup SM 2015 2016
46/50
KJSCE/IT/BE/SEMVIII/SM/2015-16
(Autonomous College Affiliated to University of Mumbai)
Procedure:
Starting a model and setting simulation parameters
The following steps are typical when starting any discrete event model.
Open a new model worksheet
Give the command Run > Simulation Setup. In the Setup tab enter the simulationparameters:
o End time: 480o Global time units: minutes
If they arent already open, open the Item, Plotter, and Value libraries Place an Executive block (Item library) on the top left corner of the model
worksheet
The Executive block does event scheduling and manages discrete event simulations. It must
be present in every discrete event model.
Start small
In building any simulation model, it is easiest to start with a simple subset of the process
and add detail until you arrive at a completed model that approximates the system thats
being modelled. This allows you to test at various stages while making the model building
process more manageable.
The following table lists the blocks that will be added to the worksheet and their use in the
model.
Except for the Plotter block from the Plotter library and random number block from value
library, the blocks in the table are from the Item library.
Name (Label) Block Function
Create block (items) Generates items or values, either randomly or on
schedule. If used to generate items, it pushes them
into the simulation and should be followed by a
queue-type block.
Purpose in Manufacturing Model
Generates items that arrive exponentially with mean 1
Set (Item > Properties) Attaches user-assigned properties (attribute, priority,
and quantity) to items passing through.
Purpose in Manufacturing Model
Set property as Type (1, 2, 3)
Queue block (Buffer) Acts as a sorted queue or as a resource pool Queue.
As a sorted queue, holds items in FIFO or LIFO order,
or sorts items based on their attribute or priority.
7/26/2019 ALl Lab Writeup SM 2015 2016
47/50
KJSCE/IT/BE/SEMVIII/SM/2015-16
(Autonomous College Affiliated to University of Mumbai)
Purpose in Manufacturing Model
Holds the items based on the type when the machine is available, and releases them one by
one in first-in, first-out order.
Select I tem I n (Item > Routing) Selects an input and outputs its item.
Purpose in Manufacturing Model
For merging the inputs (items coming from the buffers) and output one (to a particular
machine).
Select I tem Out (Item > Routing) Sends each item it gets to a selected O/P
Purpose in Manufacturing Model
Apply the routing rule (items to be routed to the specified buffer)
Activity block (Machine) Processes one or more items simultaneously.
Processing time is a constant or is based on a
distribution or an itemsattribute.
Purpose in Manufacturing Model
Processes the items as per the service time i.e. constant
Random Number block Generates random numbers
Purpose in Manufacturing Model
Outputs values to a Set block as per the look up table
Exit (Exit) Removes items from the simulation and counts them
as they leave.
Purpose in Manufacturing Model
Exit the items after being processed from the system.
Starting at the right of the Executive block, place the blocks on the model worksheetin a line from left to right, based on their order in the table.
Label the blocks as the system entities.
Enter the dialog parameters and settings for each block
Make the connections
Run the simulation
7/26/2019 ALl Lab Writeup SM 2015 2016
48/50
KJSCE/IT/BE/SEMVIII/SM/2015-16
(Autonomous College Affiliated to University of Mumbai)
Verify the results
Animate the model
Results: (Program printout with output)Program: (Printed model developed in Extend Sim )Output: (Printed results i.e. the plotter data)
Questions:
1. Give the significance of Validation and verification in simulation?
Page No:
7/26/2019 ALl Lab Writeup SM 2015 2016
49/50
KJSCE/IT/BE/SEMVIII/SM/2015-16
(Autonomous College Affiliated to University of Mumbai)
Outcomes:
Conclusion:
Grade: AA / AB / BB / BC / CC / CD /DD
Signature of faculty in-charge with date
References References:
Books/ Journals/ Websites:
1. Jerry Banks, John Carson, Barry Nelson, and David M. Nicol; Discrete Event SystemSimulation, Fifth Edition, Pearson Education.
2. Jerry Banks, John Carson, Barry Nelson, and David M. Nicol; Discrete Event SystemSimulation, Third Edition, Pearson Education.
3. ExtendSim 8 Manual (Departmental Library)
7/26/2019 ALl Lab Writeup SM 2015 2016
50/50
KJSCE/IT/BE/SEMVIII/SM/2015-16
Experiment No.: 10
Title: Case Study 2
Processor and Memory simulation using virtual lab.