Professional Documents
Culture Documents
Textbook Computer Simulation A Foundational Approach Using Python 1St Edition Yahya Esmail Osais Ebook All Chapter PDF
Textbook Computer Simulation A Foundational Approach Using Python 1St Edition Yahya Esmail Osais Ebook All Chapter PDF
https://textbookfull.com/product/essential-algorithms-a-
practical-approach-to-computer-algorithms-using-python-and-c-
second-edition-rod-stephens/
https://textbookfull.com/product/python-programming-using-
problem-solving-approach-thareja-reema/
https://textbookfull.com/product/computer-vision-using-deep-
learning-neural-network-architectures-with-python-and-keras-1st-
edition-vaibhav-verdhan/
https://textbookfull.com/product/building-energy-simulation-a-
workbook-using-designbuilder-1st-edition-vishal-garg/
Practical Programming An Introduction to Computer
Science Using Python 3 6 3rd Edition Paul Gries
https://textbookfull.com/product/practical-programming-an-
introduction-to-computer-science-using-python-3-6-3rd-edition-
paul-gries/
https://textbookfull.com/product/molecular-physical-chemistry-a-
computer-based-approach-using-mathematica-and-gaussian-1st-
edition-jose-j-c-teixeira-dias-auth/
https://textbookfull.com/product/a-step-by-step-approach-to-the-
modeling-of-chemical-engineering-processes-using-excel-for-
simulation-1st-edition-liliane-maria-ferrareso-lona-auth/
https://textbookfull.com/product/building-energy-simulation-a-
workbook-using-designbuilder-2nd-edition-vishal-garg/
https://textbookfull.com/product/summer-of-simulation-50-years-
of-seminal-computer-simulation-research-john-sokolowski/
Computer Simulation
A Foundational Approach Using Python
CHAPMAN & HALL/CRC
COMPUTER and INFORMATION SCIENCE SERIES
Series Editor: Sartaj Sahni
PUBLISHED TITLES
Yahya E. Osais
CRC Press
Taylor & Francis Group
6000 Broken Sound Parkway NW, Suite 300
Boca Raton, FL 33487-2742
© 2018 by Taylor & Francis Group, LLC
CRC Press is an imprint of Taylor & Francis Group, an Informa business
This book contains information obtained from authentic and highly regarded sources. Reasonable
efforts have been made to publish reliable data and information, but the author and publisher cannot
assume responsibility for the validity of all materials or the consequences of their use. The authors and
publishers have attempted to trace the copyright holders of all material reproduced in this publication
and apologize to copyright holders if permission to publish in this form has not been obtained. If any
copyright material has not been acknowledged please write and let us know so we may rectify in any
future reprint.
Except as permitted under U.S. Copyright Law, no part of this book may be reprinted, reproduced,
transmitted, or utilized in any form by any electronic, mechanical, or other means, now known or
hereafter invented, including photocopying, microfilming, and recording, or in any information
storage or retrieval system, without written permission from the publishers.
For permission to photocopy or use material electronically from this work, please access
www.copyright.com (http://www.copyright.com/) or contact the Copyright Clearance Center, Inc.
(CCC), 222 Rosewood Drive, Danvers, MA 01923, 978-750-8400. CCC is a not-for-profit organization
that provides licenses and registration for a variety of users. For organizations that have been granted
a photocopy license by the CCC, a separate system of payment has been arranged.
Trademark Notice: Product or corporate names may be trademarks or registered trademarks, and
are used only for identification and explanation without intent to infringe.
Visit the Taylor & Francis Web site at
http://www.taylorandfrancis.com
and the CRC Press Web site at
http://www.crcpress.com
To my wife, Asmahan,
and my daughters, Renad, Retal, and Remas.
Contents
List of Programs xv
Preface xxxi
Symbols xxxvii
Chapter 1 Introduction 3
1.1 THE PILLARS OF SCIENCE AND ENGINEERING 3
1.2 STUDYING THE QUEUEING PHENOMENON 4
1.3 WHAT IS SIMULATION? 5
1.4 LIFECYCLE OF A SIMULATION STUDY 6
1.5 ADVANTAGES AND LIMITATIONS OF SIMULATION 9
1.6 OVERVIEW OF THE BOOK 10
1.7 SUMMARY 11
ix
x Contents
2.2.2 Attributes 15
2.2.3 State Variables 16
2.2.4 Events 17
2.2.5 Activities 17
2.3 THE SINGLE-SERVER QUEUEING SYSTEM 18
2.4 STATE DIAGRAMS 22
2.5 ACTUAL TIME VERSUS SIMULATED TIME 23
2.6 SUMMARY 24
2.7 EXERCISES 24
Bibliography 271
Index 273
List of Programs
xv
xvi Contents
12.2 Computing unreliability for the graph in Figure 12.2 using crude
Monte Carlo simulation. 213
12.3 Computing unreliability for the graph in Figure 12.2 using strat-
ified sampling. 214
12.4 Computing unreliability for the graph in Figure 12.2 using an-
tithetic sampling. 215
12.5 Computing unreliability for the graph in Figure 12.2 using dag-
ger sampling. The number of samples is significantly less. 216
12.6 Python implementation of the event graph in Figure 12.4 220
12.7 Python implementation of the event graph of the simple stop-
and-wait ARQ protocol in Figure 12.8. 228
A.1.1 Starting a new Python interactive session. 235
A.1.2 Running a Python program from the command line. 236
A.1.3 A Python source file. It can also be referred to as a Python script. 236
A.2.1 Input and output functions. 237
A.3.1 Binary operations on integer numbers. 238
A.3.2 Handling unsigned binary numbers. 239
A.4.1 Lists and some of their operations. 239
A.5.1 Transposing a matrix using the zip function. Matrix is first un-
packed using the start (*) operator. 240
A.6.1 Importing the random module and calling some of the functions
inside it. 241
A.7.1 Implementing the event list using the queue module. 242
A.7.2 Implementing the event list using the hqueue module. 243
A.7.3 Implementing the event list by sorting a list. 243
A.8.1 The name of the function can be stored in a list and then used
to call the function. 244
A.8.2 The name of the function can be passed as an argument to
another function. 244
A.9.1 A tuple can be used as a record that represents an item in the
event list. 245
A.10.1 Code for generating Figure 4.12(b). 245
A.10.2 Code for generating Figure 10.6(a). 247
A.10.3 Code for generating Figure 10.6(b). 248
B.1 Event. 251
B.2 Simulation Entity. 252
B.3 Event list and scheduler. 252
B.4 Example 1. 254
xviii Contents
2.1 A mental image of the system and its behavior must be devel-
oped before a conceptual model can be constructed. 14
2.2 Different mental images can be developed for the same system.
They include different levels of details. Complexity increases as
you add more details. 14
2.3 A continuous state variable takes values from a continuous set
(e.g., [0, 5] in (a)). A discrete state variable, on the other hand,
takes values from a discrete set (e.g., {0, 1, 2, 3, 4, 5} in (b)). 16
2.4 Events are used to move dynamic entities through a system.
A packet is moved from a source to a destination through two
routers using eight events. 17
2.5 An activity is delimited by two events and lasts for a random
duration of time. 18
2.6 A queueing phenomenon emerges whenever there is a shared
resource and multiple users. 19
2.7 Conceptual model of the queueing situation in Figure 2.6. 20
2.8 A sample path of the state variable Q which represents the
number of persons in the single-server queueing system. Note
the difference in the time between every two consecutive arrival
events. 20
2.9 Four activities occur inside the single-server queueing system:
(a) Generation, (b) Waiting, (c) Service, and (d) Delay. The
length of each activity is a random variable of time. 21
xix
xx LIST OF FIGURES
2.10 A simple electrical circuit and its state diagram. Only the switch
and lamp are modeled. Events are generated by the switch to
change the state of the lamp. 22
2.11 State diagrams of the state variables associated with the queue
and server in the single-server queueing system in Figure 2.7. A
portion of the state space of the system is shown in (c). 23
4.1 Sample space for the random experiment of throwing two dice.
The outcome of the experiment is a random variable X ∈
{2, 3, ..., 12}. 40
4.2 The PMF of a discrete random variable representing the out-
come of the random experiment of throwing two dice. 41
4.3 The cumulative distribution function of a discrete random vari-
able representing the outcome of the random experiment of
throwing two dice. 42
4.4 Probability density function of a continuous random variable. 43
4.5 Elements of a histogram. Bins can be of different widths. Length
of a bar could represent frequency or relative frequency. 45
4.6 Histogram for an exponential data set. This figure is generated
using Listing 4.1. 46
4.7 The situation of observing four successes in a sequence of seven
Bernoulli trials can be modeled as a binomial random variable. 48
4.8 The PMF of the Poisson random variable for λ = 10. Notice
that P (x) approaches zero as x increases. 49
4.9 Probability distribution functions for the uniform random vari-
able where a = 3 and b = 10. 50
4.10 Probability distribution functions of the exponential random
variable where µ = 1.5. 53
LIST OF FIGURES xxi
7.8 Event graph for the single-server queueing system with reneging. 116
7.9 Event graph for the single-server queueing system with balking. 116
7.10 A template for synthesizing simulation programs from event
graphs. 121
7.11 Two parallel single-server queueing systems with one shared
traffic source. 122
7.12 A simple network setup where a user communicates with a server
in a data center over a communication channel created inside a
network. Propagation delay (Pd ) and rate (R) are two important
characteristics of a channel. 122
7.1 Event table for the event graph in Figure 7.4. 118
12.1 Sample space of the system in Figure 12.2 along with the status
of the network for each possible system state. 211
12.2 Restructuring the sample space of the system in Figure 12.2
along with the probability of each stratum. The first row indi-
cates the number of UP links. 212
12.3 State variables of the event graph in Figure 12.4. 219
xxvii
Another random document with
no related content on Scribd:
opportunity to come before the Commission and suggest
objections or amendments to the bills. The Commission has
likewise adopted as part of its regular procedure the
submission of all proposed bills to the Military Governor for
his consideration and comment before enactment. We think that
the holding of public sessions furnishes instructive lessons
to the people, as it certainly secures to the Commission a
means of avoiding mistakes. … The Commission has now passed
forty-seven laws of more or less importance. … A municipal
code has been prepared and forwarded to you for the
consideration of one or two critical matters, and has not yet
been adopted, pending your consideration of it. A tariff bill
… has been prepared. … A judicial and civil procedure bill is
nearly completed. The same thing is true of a bill for
provincial government organization. A new internal tax law
must then be considered. The wealth of this country has
largely been in agricultural lands, and they have been
entirely exempt. This enabled the large landowners to escape
any other taxation than the urbana, a tax which was imposed
upon the rental value of city buildings only, and the cedula
tax, which did not in any case exceed $37.50 (Mexican) a
person. We think that a land tax is to be preferred, but of
this there will be found more detailed discussion below. …
H. Welsh,
The Other Man's Country,
chapter 1 (Philadelphia: J. B. Lippincott Company).
{397}
Bryan J. Clinch
(American Catholic Quarterly Review,
volume 24, page 15).
"By the revolutions of 1896 and 1898 against Spain, all the
Dominicans, Augustinians, Recolletos, and Franciscans acting
as parish priests were driven from their parishes to take
refuge in Manila. Forty were killed and 403 were imprisoned,
and were not all released until by the advance of the American
troops it became impossible for the insurgents to retain them.
Of the 1,124 who were in the islands in 1896, only 472 remain.
The remainder were either killed or died, returned to Spain,
or went to China or South America. There were also in the
islands engaged in missions and missionary parishes, 42
Jesuits, 16 Capuchins, and six Benedictines, and while many of
these left their missions because of disturbed conditions they
do not seem to have been assaulted or imprisoned for any
length of time. In addition to the members of the monastic
orders, there were 150 native secular clergymen in charge of
small parishes who were not disturbed. There were also many
native priests in the larger parishes who assisted the friar
curates and they have remained, and they have been and are
acting as parish priests. The burning political question,
discussion of which strongly agitates the people of the
Philippines, is whether the members of the four great orders
of St. Dominic, St. Augustine, St. Francis, and the Recolletos
shall return to the parishes from which they were driven by
the revolution. Colloquially the term 'friars' includes the
members of these four orders. The Jesuits, Capuchins,
Benedictines, and the Paulists, of whom there are a few
teachers here, have done only mission work or teaching, and
have not aroused the hostility existing against the four large
orders to which we are now about to refer. …
"We have set forth the facts upon this important issue because
we do not think they ought to be or can be ignored. We
earnestly hope that those who control the policy of the
Catholic Church in these islands with the same sagacity and
prevision which characterize all its important policies, will
see that it would be most unfortunate for the Philippine
Islands, for the Catholic Church and for the American
Government to attempt to send back the friars, and that some
other solution of the difficulties should be found. … The
friars have large property interests in these islands which
the United States Government is bound by treaty obligations
and by the law of its being to protect. It is natural and
proper that the friars should feel a desire to remain where so
much of their treasure is. … It would avoid some very
troublesome agrarian disturbances between the friars and their
quondam tenants if the Insular Government could buy these
large haciendas of the friars, and sell them out in small
holdings to the present tenants, who, forgiven for the rent
due during the two years of war, would recognize the title of
the Government without demur, and gladly accept an
opportunity, by payment of the price in small instalments, to
become absolute owners of that which they and their ancestors
have so long cultivated. With the many other calls upon the
insular treasury a large financial operation like this could
probably not be conducted to a successful issue without the
aid of the United States Government, either by a direct loan
or by a guaranty of bonds to be issued for the purpose. The
bonds or loans could be met gradually from the revenues of the
islands, while the proceeds of the land, which would sell
readily, could be used to constitute a school fund. This
object, if declared, would make the plan most popular, because
the desire for education by the Filipinos of all tribes is
very strong, and gives encouraging promise of the future
mental development of a now uneducated and ignorant people.
The provincials of the orders were understood in their
evidence to intimate a willingness on the part of the orders
to sell their agricultural holdings if a satisfactory price
should be paid. What such a price would be we are unable
without further investigation to state. If an agreement could
not be reached it is probable, though upon this we express no
definite opinion, that there would be ground in the
circumstances for a resort to condemnation proceedings."
{400}