Computational Science and Numerical Methods-1
Computational Science and Numerical Methods-1
Oguike
Course Contents
1. Operation Research
2. Numerical Computation
3. Graphical Computation
4. Modelling and Simulation
5. High Performance Computation
• Mathematical: Though most models are mathematical models, however, some models are
not mathematical model. This criterion identifies two different types of models, which are:
1. Mathematical Models:
These are models that are not mathematical in nature, they can be inform of diagrams or
tables.
• Optimization: This criterion distinguishes models, which are used to solve optimization
problems, from models that are used to solve non optimization problems. Using this
criterion, the following are the different types of model.
1. Optimization Models:
These are models, which are used to solve optimization or operation research problems.
They are called optimization models because they aim at determining the best or optimum
way of doing things.
2. Non-Optimization Models:
Non optimization models do not aim at determining the best or optimum way of doing
things, rather, they are just predictive in nature.
• Probabilistic: In order to take care of errors that could occur in the development of the
models, this criterion help to distinguish between models that are probabilistic in nature or
not. The following models can be distinguished using this criterion.
1. Probabilistic/Stochastic Model:
These are models that are developed using the statistical concept of probability. The reason
for this type of model is because of the error associated in the development of the
mathematical model.
Non probabilistic/Non Stochastic Model are model that are developed without the use of
the statistical concept of probability theory,
1. Linear Model:
All the mathematical models in this types of model are in linear form. The maximum power
of the variables is 1.
All the mathematical models in this type of models are not in linear form, which means that
the maximum power of the variables is more than 1.
These are the type of model, which contains ordinary differential equations/expressions.
These are the type of model, which contains partial differential equations/expressions.
2. Optimization/OR Models
Department of Computer Science/Mathematics, GOUNI, Enugu. Staff No: 00721 Page 3
November 07, 2022 [COMPUTATIONAL SCIENCE AND NUMERICAL METHODS] O. E. Oguike
2.0 Introduction
Optimization models or sometimes called operation research models are models that are use to
solve optimization or operation research problems. There are different types of
optimization/operation research models that solve different optimization/operation research
problem, they include the following:
Maximize Z = 3x + 5y
Subject to: 2x– 6y <= 21
4x+ 7y <= 4 (1)
x >= 0
y >= 0
The following example will illustrate how to represent a real life description of a problem as a linear
programming model:
Example 1:
An Industrial Chemist produces both interior and exterior paints from two raw materials, M1 and
M2, The following table provides the basic data of the problem:
A marketing survey restricts the maximum daily demand of interior paints to 2 tons. Additionally,
the daily demand for Interior paints cannot exceed that of Exterior paints by more than 1 ton. The
Industrial Chemist wants to determine the optimum product mix of Interior and Exterior paints that
maximizes the total daily profit.
The first thing to do is to model the problem as a linear programming problem. The following steps
will be followed in order to represent the problem as a linear programming problem:
From the description, the desired quantities are the number of Exterior and Interior paints
that the Industrial Chemist will produce in order to maximize profit. Therefore, let x be the
number of Exterior paint, and let y be the number of Interior paint to produce in order to
maximize profit.
In order to model the objective function, you need to simply translate the detail description
into a mathematical expression. However, where a tabular representation is provided, you
need to use the table to formulate the objective function.
In the example that is before you, the problem has been presented in tabular form, therefore,
to form the objective function, your aim will be to maximize profit. Since you have assigned
x to the number of Exterior paint to produce and y to be the number of Interior paint to
produce, from the table, you can obtain the total profit from both Exterior and Interior paint
as 5x + 4y, therefore, the objective function will be:
Maximize Z = 5x + 4y
The tabular representation will be very useful in doing this and any other description of the
problem. From the tabular representation, you can obtain the total tons of raw material M1
and M2 as 6x + 4y, since this must be less than or equal to the daily availability of 24, you
can write the first constraint as follows:
6x + 4y <= 24
Similarly, for the second raw material, M2 as shown in the table, you can write the second
constraint as:
x + 2y <= 6
Furthermore, from the description of the problem, “A marketing survey restricts the
maximum daily demand of Interior paint to 2 tons”, this can be expressed mathematically
as: y <= 2. “Additionally, the daily demand for Interior paint cannot exceed that of Exterior
paint by one than 1 ton.” This can be expressed mathematically as follows:
y <= x + 1
Combining the objective function and all the constraints, the following are the various
constraints:
Maximize Z = 5x + 4y
Subject to: 6x + 4y <= 24
x + 2y <= 6
y <= 2
-x + y <= 1
x >= 0
y >= 0
After the modelling the linear programming model, the next thing is to determine the optimal
solution to the linear programming. The optimal solution to the linear programming problem in (1),
is to find the values of x and y, which will maximize the objective linear function, such that the four
set of constraints are satisfied. There are different methods, which can be used to determine the
optimal solution to linear programming problem, one of the methods is the Simplex
method/Simplex algorithm.
Maximize Z = 5x + 4y
Subject to: 6x + 4y + a + 0 + 0 + 0= 24
x + 2y + 0 + b + 0 + 0= 6
-x + y + 0 + 0 + c + 0 = 1
0 + y+0 +0+0+ d=2
x y a b c d Solution
1 6 4 1 0 0 0 24
2 1 2 0 1 0 0 6
3 -1 1 0 0 1 0 1
4 0 1 0 0 0 1 2
Z -5 -4 0 0 0 0 0
X Y A B C D Solution
1 6 4 1 0 0 0 24
2 1 2 0 1 0 0 6
3 -1 1 0 0 1 0 1
4 0 1 0 0 0 1 2
Z -5 -4 0 0 0 0 0
x y A B C D Solution Alpha
1 6 4 1 0 0 0 24 4
2 1 2 0 1 0 0 6 6
3 -1 1 0 0 1 0 1 -1
4 0 1 0 0 0 1 2 inf
Z 5 -4 0 0 0 0 0
In order to form one of the rows of the new tableau, simply divide each element of the pivot
row by the pivot element, to form the corresponding row for the new tableau. Using the
Industrial Chemist linear programming problem, the table below shows the first row of the new
tableau.
x y A B C D Solution Alpha
1 1 4/6 1/6 0 0 0 4
2 0 4/3 -1/6 1 0 0 2
3 0 5/3 0 0 1 0 5
4 0 1 0 0 0 1 2
Z 0 -4/6 5/6 0 0 0 20
8. Repeat steps 3, 4, 5, 6 and 7 until all columns of the basic variables have been selected as
pivot column.
x y A B C D Solution
1 1 0 ¼ -1/2 0 0 3
2 0 1 -1/8 ¾ 0 0 3/2
3 0 0 9/24 -5/4 1 0 5/2
4 0 0 1/8 -3/4 0 0 ½
Z 0 0 3/4 1/2 0 1 21
From the final tableau, you can easily read the values of x and y and the optimal value, z. To do
this, trace the solution value for the row where the basic variables are 1. When yo do this, the basic
variables values will be, x = 3 and y = 3/5, and the optimal value of z = 21. This solution is the
same as the result obtained from the simulation model in Python.
Maximize Z = 5x + 4y
Subject to: 6x + 4y <= 24
x + 2y <= 6
y <= 2
-x + y <= 1
x >= 0
y >= 0
Since this is a maximization problem, in order to use linprog to write the simulation model, the
objective function has to be changed from maximization to minimization, by changing the signs as
follows:
Minimize Z = -5x - 4y
Subject to: 6x + 4y <= 24
x + 2y <= 6
y <= 2
-x + y <= 1
x >= 0
y >= 0
This can be represented in Python as follows, after importing linprog:
obj = [-5,-4]
lhs = [[6,4],[1,2],[0,1],[-1,1]]
rhs = [24,6,2,1]
bnd = [(0,float('inf')), (0,float('inf'))]
optimization = linprog(c=obj,A_ub=lhs, b_ub=rhs, bounds = bnd, method = 'simplex')
optimization
After the simulation, the output of the simulation model is shown below as:
fun: -21.0
message: 'Optimization terminated successfully.'
nit: 2
slack: array([0. , 0. , 0.5, 2.5])
status: 0
success: True
x: array([3. , 1.5])
From the output of the simulation model, it shows that the values of x and y are 3 and 1,5, respecti
vely.
Exercise/Assignment
The following table shows the hourly output of two plants A and B that produce two products X
and Y with the cost per hour.
Hint:
1. Model the problem as a linear programming problem.
2. Use simplex method to manually determine the optimal hour that plants A and B will operate
in order to minimize cost.
3. Write a Python simulation model for the linear programming problem.
4. Compare the Python simulation with the manual computation.
2 E D
1 F Solution Space
A B
4 6
After the plotting of the various constraints, the following points, A, B, C, D, E and F will be
substituted in the objective function, the point that maximizes the objective function will be the
optimal solution to the linear programming model. At point A, which is (0, 0), the value of the
objective function is z = 5*0 + 4*0 = 0. At point B, which is (4, 0), the value of the objective
function is z = 5*4 + 4*0 = 20. At point C, which is (3, 1.5), the value of the objective function is
z = 5*3 + 4*1.5 = 21. At point D, which is (2.3, 2), the value of the objective function is z = 5*2.3
+ 4*2 = 19.5. At point E, which is (1.6, 2), the value of the objective function is z = 5*1.6 + 4*2 =
16. At point F, which is (0, 1), the value of the objective function is 5*0 + 4*1 = 4, Comparing all
the values of the objective function z, it is very clear that the point that maximizes the objection
function is point C, which is (3, 1.5), with the value of z = 21. Therefore, the optimal solution the
linear programming model is x = 3 and y = 1.5, this is the same as the solution obtained using the
simulation model and the manual computation of the simplex method.
X
j =1
1j
X
j =1
2j
X
j =1
3j
X
j =1
4j
Total 4 4 4 4 3
X i1
i =1
X i2
i =1
X i3
i =1
X
i =1 j =1
ij
The process of representing a real life situation in a transportation model is called modelling or
formulating a transportation problem.
Subject to:
3
X11 + X12 + X13 = X
j =1
1j
3
X21 + X22 + X23 = X
j =1
2j
3
X31 + X32 + X33 = X
j =1
3j
3
X41 + X42 + X43 = X
j =1
4j
4
X11 + X21 + X31 + X41 = X i =1
i1
4
X12 + X22 + X32 + X42 = X i =1
i2
4
X13 + X23 + X33 + X43 = X i =1
i3
4
X14 + X24 + X34 + X44 = X i =1
i4
Example:
MG Auto has three plants in Los Angeles, Detroit and New Orleans and two major distribution
centres in Denver and Miami. The capacities of the three plants during the next quarter are 1000,
1500 and 1200 cars. The quarterly demand at the two distribution centres are 2300 and 1400. The
mileage chart between the plants and the distribution centres are given in the table below.
Denver Miami
Los Angeles 1000 2690
Detroit 1250 1350
New Orleans 1275 850
The trucking company in charge of transporting the cars charges 8 cent per mile per car. Model the
problem as a transportation model and linear programming model. Use the use the Vogel
approximation numerical method to determine the starting basic variables and the starting non basic
variables.
In order to model the problem as a transportation model, you will need to determine the cost to
transport one car from each of the sources to each of the destinations. From the description, the cost
per car per mile is 8 cent, and the table above has provided the mileage chart, therefore, you can
easily compute the cost per car from each of the sources to each of the destinations. Similarly, the
description of the system has provided you with information with respect to the total demand and
total supply, therefore, the transportation model follows below:
X11 X12
Detroit $100.00 $108.00 1500
X21 X22
New Orleans $102.00 $68.00 1200
X32
X31
Total Demand 2300 1400 3700
The transportation model can be transformed into linear programming model as follows:
Next, you determine the starting basic variables using the table below:
X
1000
Detroit $100.00 $108.00 1500 8 8
1300 200
New Orleans $102.00 $68.00 1200 34 34
X
1200
Demand 2300 1400 3700
Column Penalty 20 40
2 40
From the above table, the starting basic variables are the variables for the allocated cells, which
are: X11, X21, X22 and X32, while the starting non basic variables are the variables for the cells that
were not allocated, which are: X12, X31
2. Use simplex optimality test to determine the entering variable. If it satisfies the
optimality test, stop, otherwise proceed to step 3.
2.1 Determine the multipliers for each row and column. The multipliers, U i and Vj must
satisfy the condition, Ui+Vj = Cij, for each of the basic variable, Xij. You begin by
assigning 0 to the Ui multiplier.
2.2 Determine the value of the expression, Ui+Vj-Cij, for each non basic variable.
2.3 For all the values calculated in 2.2, determine the value with the highest positive value,
that will become the entering variable. If non exists, then the simplex optimality test has
been satisfied, which means that there is no entering variable, as a result, there will be
no leaving variable. However, suppose there is an entering variable, then you proceed
to the next step, step 3.
Illustrating with the MG Auto example, you will have the following table, which is shown below:
U1 = 0 X -127.2
1000
Detroit $100.00 $108.00 1500 8 8
U2 = 20
1300 200
New Orleans $102.00 $68.00 1200 34 34
U3 = -20 X -42
1200
Demand 2300 1400 3700
Column Penalty 20 40
2 40
From the above table, none of the computer value, , Ui+Vj-Cij has a positive value, therefore, the
simplex optimality test has been satisfied. The optimal values of the basic variables are: X11 = 1000,
X21 = 1300, X22 = 200, X32 = 1200, while the values for the non basic variables are: X 12 = 0 and
X31 = 0
However, suppose the optimality test does not hold at the end of the steps in step 2, you proceed to
the steps in step 3.
Exercise:
Three refineries, with daily capacities of 6, 5 and 8 million gallons, respectively, supply three
distribution areas with daily demands of 4, 8 and 7 million gallons, respectively. Gasoline is
transported to the three distribution areas through a network of pipeline. The transportation cost is
10 cents/1000 gallons per pipeline mile. The table that follows gives the mileage between the
refineries and the distribution areas. Refinery 1 is not connected to distribution area 3.
1. Model the problem as a transportation model.
2. Remodel the transportation model as a linear programming model.
3. Use VOGEL approximation numerical method to determine the optimal amount of crude
oil to be distributed from the various refineries to the three distribution areas.
and the distance from the pivot node to the node c that you are labeling; b, is
the current pivot node, and c is the current node that you are labeling.
5. Insert each of the nodes that you have labeled in 4 into the temporary set, Ct. If
the node is already in the temporary set, determine the one with the minimum
value of, a, the one with the minimum value of, a, will be in the temporary set
while the other will be ignored.
6. Pick a node in the temporarily labeled set that has the minimum value of, a,
7 Insert the label into the permanent set and remove it from the temporary set.
This node will become the current pivot node.
8. Repeat steps 3, 4, 5, 6 and 7 until the set of temporarily labeled set becomes
empty
The set of permanently labeled set can be used to determine the shortest route between the source
node and any other node in the network. The following example will illustrate further.
Example:
Consider the network diagram below, use the Dijkstra’s Algorithm to determine the shortest route
from node 1 to node 8.
4
3 6
1 2
2 3
8
1 2 5 6 5
1
7
1 2 3 6
5 8 7
2 4
Solution:
Using the Dijkstra’s Algorithm, we proceed as follows:
1. Initialize Ct = Empty
2 Intialize Cp = { [0, -]1 }
3 Neighbors of the pivot node, 1 are nodes 2, 3
4 Label the neighbors as follows: [1,1]2, [2,1]3
5 Insert the labeled nodes into temporary set; Ct = { [1,1]2, [2,1]3 }
6 Pick pivot node with minimum distance from temporary set as [1,1]2
7 Insert it into Cp and delete it from Ct; Cp = { [0,-]1, [[1,1]2 } and Ct =
{ [2,1]3 }
Second Iteration:
3. Neighbors of the pivot node, 2 are 3, 4, 5
4. Label the neighbors as follows: [2,2]3, [6,2]4, [3,2]5
5 Insert labeled nodes into temporary set; Ct = { [2,1]3, [6,2]4, [3,2]5 }. Since
node 3 is already in the temporary set with the same distance as the new
label as the one we intend to insert, we pick one arbitrarily and ignore the
other.
6 New pivot is node 3
7 Cp = { [0,-]1, [[1,1]2, [2,1]3 } and Ct = { [6,2]4, [3,2]5 }
Third Iteration:
3 Neighbors of the pivot node 3 are 4, 5 and 6
4 Label the neighbors as follows [4,3]4, [3,3]5, [6,3]6
5. Insert labeled nodes into temporary set; Ct = { [4,3]4, [3,2]5, [6,3]6 }
6 New pivot is node 5
7 Cp = { [0,-]1, [[1,1]2, [2,1]3, [3,2]5 } and Ct = { [4,3]4, [6,3]6 }
Fourth Iteration:
3 Neighbors of the pivot node 5 are 6, 7
4 Label the neighbors as follows [6,5]6, [10,5]7
5 Insert labeled nodes into temporary set, Ct = {[4,3]4, [6,3]6, [10,5]7 }
6 New pivot is node 4
7 Cp = { [0,-]1, [[1,1]2, [2,1]3, [3,2]5, [4,3]4,} and Ct = { [6,3]6, [10,5]7 }
Fifth Iteration:
3 Neighbors of the pivot node 4 are 6, 7
4 Label the neighbors as follows [[10,4]6, [12,4]7
5 Insert labeled nodes into temporary set, Ct = { [6,3]6, [10,5]7 }
6 New pivot node is node 6
7 Cp = { [0,-]1, [[1,1]2, [2,1]3, [3,2]5, [4,3]4, [6,3]6 } and Ct = { [10,5]7 }
Sixth Iteration
3 Neighbors of pivot node 6 are 7, 8
4 Label the neighbors as follows [11,6]7, [8,6]8
5 Insert labeled nodes into temporary set, Ct = { [10,5]7 }
6 New pivot node is node 8
7 Cp = { [0,-]1, [[1,1]2, [2,1]3, [3,2]5, [4,3]4, [6,3]6, [8,6]8 } and Ct = { [10,5]7 }
Seventh Iteration:
3. Neighbors of node 8 is empty
4 Nothing to label
5 Nothing to insert into temporary set, Ct
6 New pivot node is node 7
7 Cp = { [0,-]1, [[1,1]2, [2,1]3, [3,2]5, [4,3]4, [6,3]6, [8,6]8, [10,5]7 } and Ct = { }
Since Ct is now empty, the iteration stops, and we have the set Cp, the set of permanent set as: Cp
= { [0,-]1, [[1,1]2, [2,1]3, [3,2]5, [4,3]4, [6,3]6, [8,6]8, [10,5]7 }
From this set we can easily read the shortest route from node 1 and any other node in the network:
From node 1 to 8, you go through node 6
From node 1 to 6, you go through node 3
From node 1 to 3, you go through node 1
This shortest route can be represented, using this diagram below.
3
6
1 8
Example:
Consider the network diagram below, and use the Dijkstra’s algorithm to determine the shortest
route from node 1 to node 4.
2
2 5
5 3 1
5
1 4
1 1
6
7
3 3
4
3 7
12
Solution:
Using the Dijkstra’s Algorithm, we proceed as follows:
1. Initialize Ct = Empty
2 Intialize Cp = { [0, -]1 }
3 Neighbors of the pivot node, 1 are nodes 2, 3
4 Label the neighbors as follows: [5,1]2, [3,1]3
5 Insert the labeled nodes into temporary set; Ct = { [5,1]2, [3,1]3 }
6 Pick pivot node with minimum distance from temporary set as [3,1]3
7 Insert it into Cp and delete it from Ct; Cp = { [0,-]1, [[3,1]3 } and Ct =
{ [5,1]2 }
Second Iteration:
3. Neighbors of the pivot node, 3 are 2, 4, and 7
4. Label the neighbors as follows: [4,3]2, [10,3]4, [15,3]7
5 Insert labeled nodes into temporary set; Ct = { [4,3]2, [10,3]4, [15,3]7 }.
6 New pivot is node 2
7 Cp = { [0,-]1, [[3,1]3, [4,3]2 } and Ct = { [10,3]4, [15,3]7 }
Third Iteration:
3. Neighbors of the pivot node, 2 are 4, and 5
4. Label the neighbors as follows: [6,2]5, [9,2]4
5 Insert labeled nodes into temporary set; Ct = { [9,2]4, [6,2]5, [15,3]7 }.
6 New pivot is node 5
7 Cp = { [0,-]1, [[3,1]3, [4,3]2, [6,2]5 } and Ct = { [9,2]4, [15,3]7 }
Fourth Iteration:
3. Neighbors of the pivot node, 5 are 4, and 6
4. Label the neighbors as follows: [9,5]4, [7,5]6
2 5
1 4
6
Exercise
Use Dijkstra’s algorithm to determine the shortest route between node 1 and node B in this
network diagram.
1
2 4
0
3
2 5 5
3 4
2 7
1 2 2
6
3 4
4
8
7 6
4
A
9 3
4
3. Queuing/Stochastic Models
3.0 Introduction
Queuing models are mathematical models, which can be used to describe a queuing system, i.e. a
system that has arrival of item or departure of item or both arrival and departure of items. The
queuing models that will be considered in this section are stochastic in nature, because they are
derived using the concept of probability theory. The queuing models are predictive models, rather
than optimization model because they are aim at predicting/determining a particular metric of a
queuing system, rather than optimizing the metric. In this section, the different queuing models,
which describe a particular queuing application, will be considered, and for each queuing model, it
will be simulated on the computer, with different simulation trials that will help to understand the
relationship between the variables of the queuing model. Graphical plots will also be used to
visually understand the relationship between the variables of the queuing models.
x e −
, x = 0 ,1,2,3,4,5,6,7,...
P( X = x) = x!
0 , otherwise
The above model, which determines the probability that x items arrive in a pure birth
queuing system depends on x and . Therefore, using this model to understand a pure birth
queuing system, the model will be simulated on the computer, at different experimental runs
of the simulation model/program, the values of x will be changing, while other variables
will remain constant, this will help to predict/determine the probability that x items arrive
at the pure birth queuing system per unit time. When the various probabilities are plotted
against x, the result of the simulation is shown below.
P(X)
0.08
0.06
0.04
0.02
0
0 20 40 60 80 100 120
-0.02
Similarly, for different experimental runs of the simulation model/program, as the value of
changes, while other variables remain constant, the result of the simulation, which is the
predicted probability of the number of items in the queuing system, when plotted against
the various value of , the results of the simulation is shown in the graph below.
P(X)
0.06
0.05
0.04
0.03
0.02 P(X)
0.01
0
0 50 100 150 200
-0.01
These results show that the model for the Poisson probability density function tends to
behave like normal distribution, when the arrival rate is large.
The pure death queuing system is a queuing system, where there is only departure, without
arrival. One of the problems that you can solve in a pure death queuing system is to
determine the probability that x items remains in a pure death queuing system. The model
that helps you to predict/determine the probability that x number of items remains in a pure
death queuing system is called Truncated Poisson probability density function. The model
for the trucketed Poisson probability density function is given as:
( t ) N − x e − t
, x = 0 ,1,2,3,4,5,6,7,...N
P( x) = ( N − x)!
0 , otherwise
This model depends on x, N and t , its behaviour is similar to the model for Poisson
probability density function.
3.3 Queuing Models for Single Server, Finite, Birth and Death Queuing System
In a birth and death queuing system, there is both arrival and departure. Some of the
problems that you can solve in this queuing system is to predict the following metrics: the
probability that x items are in the queuing system, i.e. the probability that the system is in
state x, the average number of items in the queuing system, the waiting time in the queuing
system, the average number of items in the queue, the waiting time in the queue, the
percentage of utilization of the server. Relevant models have been developed for each of the
above metrics of a birth and death queuing system. Each of the models will be considered.
3.3.1 Model for the Probability that x Items are in the Queuing System
The model that helps you to predict/determine the probability that x items is in a single
server, finite birth and death queuing system is given below:
x 1−
, x = 0,1,2,..., N , 1
N +1
1 −
1
P( x) = , x = 0,1,2,3,..., N , = 1
( N + 1 )
0 , elsewhere
In the above model, = , is the arrival rate, is the departure rate and N is the
maximum number of items that the finite queuing system can accommodate. It is very clear
that the above model depends on the following variables, N, and . In order to understand
the system, using the model, the relationship between the probability, P(x) and each of the
variables will be considered. Any programming language, like Java, Python or C++ can be
used to write the simulation model/program for the above model. After writing the
simulation model/program, for different experimental run of the simulation model/program,
by keeping the following variables constant at N = 40, = 10 and = 5, while varying x,
the number of items in the finite queuing system, the various probabilities can be
estimated/predicted. When plotted against x, you obtain the graph below.
P(X)
0.6
0.5
0.4
0.3
P(X)
0.2
0.1
0
0 10 20 30 40 50
The result of the simulation shows that as that as the number of items in the queuing system,
x increases, the probability remains very low, close to zero, however, after it reaches the
value of 30, any further increase leads to a steady rise in the probability. The implication is
that with the constant values of N = 40, = 10 and = 5, the probability that 30 or more
items will be in the queuing system is very high, while the probability that less than 30 items
will be in the queuing system will be very low.
However, if the maximum number of items that can be in the queuing system remains 40,
while = 10 and = 5, the probability that very few items will be in the queuing system
will be very high, while the probability that many items will be in the queuing system will
be very low. This can be seen in the graph below.
P(X)
0.14
0.12
0.1
0.08
0.06 P(X)
0.04
0.02
0
0 10 20 30 40 50
This means that the value of = , which is called utilization factor or queue intensity is
the game changer, the queuing system behaves differently when it is greater than 1, and
behaves in a different manner when it is less than 1.
Exercise:
Simulate the model by keeping the following variables constant at N = 40, = 10, x = 15,
vary from 2 to 100. Plot the result of the simulation, P(x) against . Interpret the result
of the simulation.
1 − ( N + 1) N + N ( N +1)
, 1
(1 − )(1 − N +1
)
N
Ls = , = 1
2
As usual, in the above model, = , is the arrival rate, is the departure rate and N is
the maximum number of items that the finite queuing system can accommodate. Therefore,
the average number of items in the queuing system depends on the following variables, N,
and . Simulating the model, using any software of your choice, and keeping the
following variables constant at N = 40, = 100 and varying between 2 and 308, plotting
the average number of items in the queuing system against departure rate, you obtain the
graph below.
The interpretation of the simulation result is that as the utilization factor remains very high, the
average number of items in the queuing system remains constant, at close to 40. However, as the
utilization factor approaches 1, the average number of items in the queuing system begins to fall
sharply. Furthermore, as the utilization factor, which is the game changer begins continues to
decrease to value that is close to 0, the average number of items in the queuing system continues to
decrease to value that is close to 0.
import java.util.Scanner;
class simulatesine
{
public static void main(String args[])
{
Scanner myinput = new Scanner(System.in);
double val = 0.0, numb = 0.0;
System.out.print("Enter the value of x and n :");
val = myinput.nextDouble();
numb = myinput.nextDouble();
System.out.print("The Value of Sine " + " x " + "is "+ sinevalue(val,
numb));
}
For different experimental runs of the simulation model/program, keeping x constant at 10, and
iterating n from 1 to 25, the various predicted values of Sin(x=10) can be obtained from the
simulation. When the result of the simulation, Sin(x=10) is plotted against n, the graph below shows
the relationship between the predicted value, Sin(x) and n.
Sin(X)
2000
1000
0 Sin(X)
0 5 10 15 20 25 30
-1000
-2000
The interpretation of the result of the simulation is that as the value of n iterates from 1, the value
of Sin(x=10) fluctuates by rising and falling, as the value of n continues to increase, the value of
Sin(x=10) remains stable at -0.5440, which is the actual value of Sin(10).
n = 0 n!
The above model for the euler function depends on the variables, x and n, therefore, for a particular
value of x, e x depends on n. In a similar manner, the model can be simulated on the computer using
recursive Java methods, as shown below.
import java.util.Scanner;
class simulateuler
{
public static void main(String args[])
{
Scanner myinput = new Scanner(System.in);
double val = 0.0, numb = 0.0;
System.out.print("Enter the value of x and n :");
val = myinput.nextDouble();
numb = myinput.nextDouble();
System.out.print("The Euler Value for " + " x " + "is "+ eulervalue(val, numb));
}
For different experimental runs of the simulation model/program, by keeping x constant at 1, and n
iterates from 1 to 30 at interval of 1, the result of the predicted value of e when plotted against n is
shown below.
e
3
2.5
1.5
e
1
0.5
0
0 5 10 15 20 25 30 35
The interpretation of the result of the simulation is that as the value of n iterates from 1 to 30, and
x remains constant at 1, the value of e increases from 2, afterwards the value of e stabilizes at the
value of 2.718 as n becomes very large.
Exercises
For each of the following Taylor series model for the corresponding function,
1. Write the Java based simulation model/program that can be used to simulate the model
on the computer.
2. Perform different experimental runs of the simulation model, by keeping x constant at a
constant value of 10, and n iterates from the beginning to 50, plot the predicted value of
the function against n.
(−1)n −1 x n
B. Ln(1 + x) =
n =1 n