Simulation and Modelling 2076 (new)

Tribhuwan University
Institute of Science and Technology
2076 (new)
Bachelor Level / Fifth Semester / Science
Computer Science and Information Technology ( CSC317 )
( Simulation and Modelling )
Full Marks: 60
Pass Marks: 24
Time: 3 hours
Candidates are required to give their answers in their own words as far as practicable.
The figures in the margin indicate full marks.

Section A

Attempt any two questions.(2x10=20)

1. Define queuing system. Explain different queuing disciplines. Also explain different performance measures for evaluation of queuing system.

10 marks view

The line where the entities or customer wait is generally known as queue. The combination of all entities in system being served and being waiting for service will be called as queueing system.


Queue discipline refers to the rule that a server uses to choose the next customer from the queue when the server completes the service of the current customer. Common queue disciplines include first-in-first-out (FIFO); last-in-first-out (LIFO); service in random order (SIRO); shortest processing time first (SPT); and service according to priority (PR).

  • First in first out :This principle states that customers are served one at a time and that the customer that has been waiting the longest is served first.
  • Last in first out : This principle also serves customers one at a time, however the customer with the shortest waiting time will be served first. 
  • Service in random order: A customer is picked up randomly from the waiting queue for service.
  • Shortest job first: The next job to be served is the one with the smallest size (shortest service time).
  • Priority: Customers with high priority are served first. 

The performance of a queuing system can be evaluated in terms of a number of response parameters, however the following four are generally employed.

  • Average number of customer in the queue or in the system
  • Average waiting time of the customer in the queue or in the system
  • System utilization (Server utilization)
  • The cost of waiting time and idle time

1. If  Ta and Ts be the inter arrival time and the mean service time then

  • Arrival rate λ=1/Ta 
  • Service rate μ=1/Ts
  • Average number of customer in the systemλ/(μ - λ)
  • Average number of customer in the queue = λ2/μ(μ - λ)
  • Average waiting time in the system = 1/(μ - λ)
  • Average waiting time in the queue = λ/μ(μ - λ)

2. The ratio of the mean service time to the mean inter arrival time is called traffic intensityi.e.  u=Ts/Ta

3. Server utilization: It consists of only the arrival that gets served. It is denoted by and defined as

        ρ= λTs= λ/ μ (server utilization for single server).

        ρ= λTs= λ/ nμ (server utilization for n server). 

4. Probability of finding service counter free is (1 – ρ) i.e there are zero customers in the service facility.

2. Differentiate between chi-square test and KS test for uniformity. Use KS test to check for the uniformity for the input set of random numbers given below.0.54, 0.73, 0.98, 0.11,0.68,0.45. Assume level of significance to be Dα = 0.05=> 0.565.

10 marks view

The Chi Square test is used to test whether the distribution of nominal variables is same or not as well as for other distribution matches and on the other hand the Kolmogorov Smirnov (K-S) test is only used to test to the goodness of fit for a continuous data.

Kolmogorov Smirnov (K-S) test compares the continuous cdf, F(X), of the uniform distribution to the empirical cdf, SN(x), of the sample of N observations. By definition,

    F(x) = x, 0 <= x <= 1

If the sample from the random-number generator is R1, R2,......,RN, then the empirical cdf, SN(X), is defined by

    SN(X) = (Number of R1, R2,......,RN which are <= x)/N

As N becomes larger, SN(X) should become a better approximation to F(X), provided that the null hypothesis is true. The Kolmogorov-Smirnov test is based on the largest absolute deviation or difference between F(x) and SN(X) over the range of the random variable. I.e. it is based on the statistic

    D = max | F(x) - SN(x)|


The chi-square test uses the sample statistic

Where Oi is the observed number in the ith class, Ei is the expected number in the ith class, and n is the number of classes. For the uniform distribution, Ei ist the expected number in each class is given by: Ei = N/n, N is the total number of observation.


Now,

Given sequence of number,

    0.54, 0.73, 0.98, 0.11,0.68 and 0.45

Arranging the given number in ascending order:

    0.11, 0.45, 0.54, 0.68, 0.73, 0.98

Here, N = 6

Calculation table for Kolmogorov-Smirnov test :

i



10.110.170.060.11
20.450.33-0.28
30.540.5-0.21
40.680.670.070.18
50.730.830.10.06
60.9810.020.15

Now, calculating

\\begin{displaymath}D^+ = {\\rm max}_{1 \\le i \\le N} \\left\\{ \\frac{i}{N} - R_{(i)}
\\right\\} \\end{displaymath} = 0.1

\\begin{displaymath}D^- = {\\rm max}_{1 \\le i \\le N} \\left\\{ R_{(i)} -
\\frac{i-1}{N} \\right\\} \\end{displaymath} = 0.28

$D = {\\rm max} (D^+, D^-)$ = 0.28

Given, Critical value $D_\\alpha$ = 0.565

Since the computed value, D = 0.28, is less than the tabulated critical value, $D_\\alpha$ = 0.565, the hypothesis of no difference between the distribution of the generated numbers and the uniform distribution is not rejected.

3. What do you understand by static mathematical model? Explain with example. Differentiate between stochastic and deterministic activities.

10 marks view

Static mathematical model is the mathematical model that represents the logical view of the system in equilibrium state. Such models are time-invariant. It is generally represented by the basic algebraic equations.

For example:  Supply and demand relationship model of a market 

Consider a market model assuming the linear behavior of supply and demand with price.

  • Demand for a product will be low when the price is high and will be high when the price is low.
  • Supply for a product will be high when the price is high and will be low when the price is low.
  • If conditions remain stable, the price will settle to the point at which demand equals supply.

The relations can be stated mathematically as:    

    Q = a – bP
    S = c + dP
    S = Q

where, S = supply, Q = demand and P = price

The linear market model is shown below:


Difference Between Stochastic and Deterministic Activities

  • Stochastic model / activity has one or more random variable as inputs. Random inputs leads to random outputs. E.g. Simulation of a bank involves random inter-arrival and service times.
  • Deterministic model / activity contains no random variables. They have a known set of inputs which will result in a unique set of outputs. E.g. Arrival of patients to the Dentist at the scheduled appointment time.

Section B

Attempt any eight questions.(8 x 5 = 40)

4. Discuss the  merits and demerits of system simulation.

5 marks view

Simulation is the imitation of the operation of a real-world process or system over time. Simulation involves the generation of an artificial history of the system, and the observation of that artificial history to draw inferences concerning the operating characteristics of the real system that is represented.

Merits of Simulation

  • New procedures or rules can be explored without hampering the ongoing real time system operations.
  • New designs can be tested without acquiring resources.
  • The hypotheses about certain phenomena can be tested for feasibility.
  • Insights can be obtained about the variable interaction and their credit for system performance.
  • It provides the better understanding of the operation of the system in easier way.
  • A simulation study can help in understanding how the system operates rather than how individuals think the system operates.
  • “what-if” questions can be answered. So it is useful in the design of new systems.

Demerits of Simulation

  • Building model requires specialization which is the art learned through experience.
  • In some cases, the results of the simulation may be so complex to interpret.
  • It may be time consuming and expensive.

5. Explain markov's chain with a suitable example.

5 marks view

If the future states of a process are independent of the past and depend only on the present , the process is called a Markov process. A discrete state Markov process is called a Markov chain. A Markov Chain is a random process with the property that the next state depends only on the current state.

Markov chains are used to analyze trends and predict the future. (Weather, stock market, genetics, product success, etc.

Formally,

A Markov chain is a sequence of random variables X1, X2, X3, ... with the Markov property, namely that, given the present state, the future and past states are independent.

The conditional probability above gives us the probability that a process in state in at time n moves to in+1 at time n + 1. We call this the transition probability for the Markov chain. If the transition probability does not depend on the time n, we have a stationary Markov chain, with transition probabilities

Now we can write down the whole Markov chain as a matrix P:

Example:

Weather Problem:

  • raining today  ⇒ 40 % rain tomorrow

                                ⇒ 60 % no rain tomorrow

  • not raining today  ⇒ 20 % rain tomorrow

                                      ⇒ 80 % no rain tomorrow

What will be probability if todays is not raining then not rain the day after tomorrow?

Markov chain diagram:

Transition matrix:

Thus, the probability of not rainy the day after tomorrow is 0.76.

6. Define arrival pattern. Explain non-stationary Poisson process.

5 marks view

Arrival defines the way customers enter the system. Mostly the arrivals are random with random intervals between two adjacent arrivals. Typically the arrival is described by a random distribution of intervals also called Arrival Pattern. Arrivals may occur at scheduled times or at random times. When at random times, the inter arrival times are usually characterized by a probability distribution and most important model for random arrival is the poisson process. In schedule arrival interarrival time of customers are constant.


The non-stationary Poisson process is a Poisson process for which the arrival rate varies with time. More specifically, it can be defined as follows:

The counting process N(t) is a non-stationary Poisson process if:

a) The process has independent increments.

b) 

    Where, λ(t) = the arrival rate at time t

                dt = differential sized interval

7. Differentiate between validation and calibration. How can we perform validation of model?

5 marks view

Validation is a process of comparing the model and its behavior to the real system and its behavior. Calibration is the iterative process of comparing the model with real system, revising the model if necessary, comparing again, until a model is accepted (validated).


Naylor and Finger proposed three step approach for validation of model. These steps are as follows:

1. Face validity

- A model should appear reasonable on its face to model users and to those who knows about the real system that is being simulated.
- A model should be designed with high degree of realism regarding system structure and behaviour through reliable data.
- The potential users should also be involved in the validation process to aid in identification of model deficiencies and optimizing those deficiencies to produce better model. This process is termed as structural walkthrough.
- Sensitivity analysis is also used for face validity of the model. It analyses the effect on output when there is change in input parameters. Sensitivity analysis is done through appropriate statistical techniques.

2.  Model Assumptions

Model assumptions fall into two categories: structural assumptions and data assumptions.

  • Structural assumptions involve questions of how the system operates and usually involve simplification and abstractions of reality.
  • Data assumptions should be based on the collection of reliable data and correct statistical analysis of the data. It deals with such questions as what kind of input data model is? What are the parameter values to the input data model?

3. Input-Output Transformations

- It involves validating whether the model can predict the future behaviour of the real system when the model input data match the real inputs and when a policy implemented in the model is implemented at some point in the system.
- In this validation phase, the model accepts values of the input parameters and transforms them into output measures of performance.
- The modeler uses the historical data reserved for validation purposes only.
- For the complete input-output validation, at least one set of input conditions should be collected from the system data so as to compare to model prediction.

8. Use mixed congruential method to generate a sequence of random numbers with X0 = 27, a = 17, m = 100 and c = 43. 

5 marks view

Given,

    X= 27

    α = 17,

    c= 43 &

    m=100

We have,

        Xi+1 = (α X+ c) mod m

        Mixed Congruential Method: c ≠ 0

        & R=Xi/m,

The sequence of random numbers are calculated as follows:

X= 27

R0 = 27/100 = 0.27

X1 = (α X0 + c) mod m = (17*27+43) mod 100 = 502 mod 100 = 2

R1 = 2/100 = 0.02

X2 = (α X1 + c) mod m = (17*2+43) mod 100 = 77 mod 100 = 77

R2 = 77/100 = 0.77

X3 = (α X2 + c) mod m = (17*77+43) mod 100 = 1352 mod 100 = 52

R3 = 52/100 = 0.52

X4(α X3 + c) mod m = (17*52+43) mod 100 = 927 mod 100 = 27

R4 = 27/100 = 0.27

Therefore,

The sequence of random integers are 27, 02, 77, 52, 27 & so on.

The sequence of random numbers are 0.27, 0.02, 0.77, 0.52, 0.27 & so on.

9. What do you understand by replication of runs. Why is it necessary?

5 marks view

Replication of run is used to obtain independent results by repeating the simulation. Repeating the experiment with different random numbers for the same sample size n gives a set of independent determinations of the sample mean  .The mean of the means and the mean of the variances are then used to estimate the confidence interval.

Suppose the experiment is repeated p times with independent random values of n sample sizes. Let xij be the ith observation in jth run and let the sample mean and the variance for the jth run is denoted by  and  respectively. Then for jth run, the estimates are

Combining the result of p independent measurement gives the following estimate for the mean and variance s2 of the populations as:


Replication of runs are necessary for running experiments based on scenarios with stochastic parameters. It is used to obtain independent results by repeating the simulation. If replications are not used, a single run of an experiment will not produce statistically significant results and will not allow for proper calculation of statistical data.

10. Explain generation of non uniform random number generation using inverse method.

5 marks view

Non-uniform random variate generation is concerned with the generation of random variables with certain distributions. Such random variables are often discrete, taking values in a countable set, or absolutely continuous, and thus described by a density. 

11. Parts are being made at the rate of one every 10 minutes. They are of two types, A and B. And are mixed randomly with about 10% being type B. A separate inspector is assigned to examine each part. Inspection of part A takes 6±2 minutes while B takes 10±2 minutes. Both inspector rejects 10% of parts they inspect. Draw GPSS block diagram to simulate the the above problem for 100 parts.

5 marks view

The block diagram for given problem using GPSS is given below:

Code for simulating the given problem using GPSS:

        GENERATE  10, 0

          TRANSFER  0.1  A   B

    A    ADVANCE  6, 2

    B    ADVANCE 10, 2

    A    TRANSFER  0.1  ACC   REJ

    B    TRANSFER  0.1  ACC   REJ

    A    ACC TERMINATE   1

           REJ TERMINATE   1

    B     ACC TERMINATE   1

            REJ TERMINATE   1

    START 100

12. Write short notes on (any two).( 2 x 2.5 = 5)

a) System and its environment.

b) Simulation run statistics.

5 marks view

a) System and its environment.

  • A system is defined as a collection of object join in some regular interaction or interdependency for achievement of a common goal. We can also define a system as organized set of inter-related idea or principles. All system have input, output and feedback and maintain a basic level of equilibrium.
  • system boundary is the line that separate the system and its environment.
  • The external components which interact with the system and produce necessary changes are said to constitute the system environment. In modeling systems, it is necessary to decide on the boundary between the system and its environment. This

b) Simulation run statistics

In the estimation method, it is assumed that the observations are mutually independent and the distribution from which they are draws is stationary. Unfortunately many statistics of interest in simulation do not meet these conditions. An example of such case is queuing system. Correlation is necessary to analyze such scenario.  In such cases, simulation run statistics method is used.

Example:                                                    

Consider a system with Kendall’s notation M/M/1/FIFO (i.e. a single server system in which the inter-arrival time is distributed exponentially ;and service time has an exponential and queue discipline is FIFO) and the objective is to measure the mean waiting time.

In simulation run approach, the mean waiting time is estimated by accumulating the waiting time of n successive entities and then it is divided by n. This measures the sample mean such that:

Whenever a waiting line forms, the waiting time of each entity on the line clearly depends upon the waiting time of its predecessors. Such series of data in which one value affect other values is said to be autocorrelated. The sample mean of autocorrelated data can be shown to approximate a normal distribution as the sample size increases.

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. The early arrivals then have a more than normal probability of obtaining service quickly, so a sample mean that includes the early arrivals will be biased.