Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A...

70
Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing System with simlib 4.5. Time-Shared Computer Model 4.6. Multiteller Bank with Jockeying 4.7. Job-Shop Model 1

description

In this chapter we first discuss list processing, which is an activity that takes place in most simulations. We then introduce simlib, which is a set of C support routines, which provides capabilities for some standard list-processing tasks as well as some other common simulation activities, such as: 1.Processing the event list 2.Accumulating statistics 3.Generating random numbers 4.Observations from a few distributions 5.Computing and writing out results. 3

Transcript of Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A...

Page 1: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

Chapter 4. Modeling Complex Systems

4.1. Introduction

4.2. List Processing in Simulation

4.3. A Simple Simulation Language: simlib

4.4. Single-Server Queuing System with simlib

4.5. Time-Shared Computer Model

4.6. Multiteller Bank with Jockeying

4.7. Job-Shop Model

4.8. Efficient Event-list Manipulation1

Page 2: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

4.1. Introduction

In Chapter 1 we discussed simulation modeling in

general, and showed how to model and program in the

C programming language two simple systems. Most

real-world systems, however, are quite complex, and

programming them without supporting software can be a

difficult and time-consuming task.

2

Page 3: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

In this chapter we first discuss list processing, which

is an activity that takes place in most simulations. We

then introduce simlib, which is a set of C support

routines, which provides capabilities for some standard

list-processing tasks as well as some other common

simulation activities, such as:

1.Processing the event list

2.Accumulating statistics

3.Generating random numbers

4.Observations from a few distributions

5.Computing and writing out results.3

Page 4: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

Our purpose in this chapter:

1.Illustrate how more complex systems can be modeled,

2.Show how list processing and the simlib routines can help

in their programming.

Our intention in using simlib is purely educational; it allows

one to more quickly understand how to model complex

systems and how commercial simulation-software

packages handle lists and other data.

4

Page 5: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

4.2. List Processing in Simulation

The simulation models discussed in Chapter 1 were

quite simple in that they contained either one or no lists of

records other than the event list. Furthermore, the records

in these lists consisted of a single attribute and were

always processed in a FIFO manner.

5

Page 6: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

However, most complex simulations require many

lists, each of which may contain a large number of

records, consisting in turn of possibly many attributes

each. Furthermore, it is often necessary to process these

lists in a manner other than FIFO. For example, it might

be necessary to remove the record in a list with the

smallest value of some attribute.

6

Page 7: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

We will store lists in a two-dimensional array, with

rows corresponding to records and columns

corresponding to attributes.

7

Page 8: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

4.2.1. Approaches to Storing Lists in a Computer In the sequential-allocation approach, which was used

in Chapter 1, the records in a list are put into physically

adjacent storage locations, one record after another.

In the linked-allocation approach, each record in a list

contains its usual attributes and, in addition, pointers (or

links) giving the logical relationship of the record to other

records in the list. Records in a list that follow each other

logically need not be stored in physically adjacent

locations.

8

Page 9: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

Advantages of linked allocation of lists for simulation

modeling: Adding, deleting, and moving records is much faster, which is

critical for event-list management.

For some models, computer memory requirements

can be reduced without increasing the chance of list

overflow.

It provides a general framework that allows one to

easily store and manipulate many lists simultaneously.

9

Page 10: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

4.2.2. Linked Storage Allocation Suppose that a list of records is to be stored in an

array, that the rows of the array correspond to the

records, and that the columns correspond to the

attributes that make up the records. A list of records is

called a doubly linked list if each record has associated

with it a predecessor link and a successor link. The

successor link (SL) (or forward pointer) for a particular

record gives the physical row number in the array of the

record that logically succeeds the specified record (equal

to zero if no such record).10

Page 11: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

The predecessor link (PL) (or backward pointer) for a

particular record gives the physical row number in the

array of the record that logically precedes the specified

record (equal to zero if no such record).

The physical row number in the array that contains the

first logical record in the list is identified by a head pointer

(HP) (equal to zero if list is empty). The physical row

number in the array that contains the last logical record in

the list is identified by a tail pointer (TP) (equal to zero if

list is empty).

11

Page 12: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

At any given time a list will probably occupy only a

subset of the rows of the array, and the “empty” rows

available for future use are linked together in a list of

available space (LAS) that is processed in a LIFO

manner. When a row is needed to store an additional

record, it is taken from the head of the LAS; and when a

row is no longer needed to store a record, the row is

returned to the head of the LAS.

12

Page 13: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

Since all operations are done at the head of the LAS,

it requires neither a TP (Tail Pointer) nor PLs

(Predecessor Link), and we call it a singly linked list.

At time 0 in a simulation, all rows in the array are

members of the LAS, the SL (Successor Link) of row i is

set to i + 1 (set to 0 for last row), all PLs are set to 0, and

the HP (Head Pointer) for the LAS is set to 1.

13

Page 14: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

Example 4.1: For the queueing simulation of Section

1.4, consider the list for the customers waiting in queue,

with each record in the list having the single attribute,

“time of arrival.” Suppose that at time 25 in the

simulation that there are three customers in queue, with

times of arrival 10, 15, and 25, and that these records

are stored in (physical) rows 2, 3, and 1 of an array with

5 rows and 1 column. Rows 4 and 5 are members of the

LAS. The situation is shown in Figure 4.1.

14

Page 15: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

15

0List

Head

15

25

10

Tail 0

Head

0

LAS

2

3

1

4

5

Physicalrow

Physicalrow

Figure 4.1. State of the lists at time 25, queueing simulation.

Page 16: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

Suppose that the next event in the simulation (after

time 25) is a customer arrival at time 40 and we would

like to add an appropriate record to the list. Since the

HP for the LAS is equal to 4, the record for the arriving

customer will be placed in physical row 4 of the array

and the HP for the LAS is now set to 5.

16

Page 17: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

Since the new record will be added to the tail of the list

and its TP is now equal to 1, the following operations are

done:

The SL for the record in row 1 is set to 4.

The PL for the new record is set to 1.

The SL for the new record is set to 0.

The TP for the list is set to 4.

The state of both lists after these changes have been

made is shown in Figure 4.2.17

Page 18: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

18

0List

Head

15

25

10

Tail 0

Head

0

LAS

2

3

1

5

Physicalrow

Physicalrow

Figure 4.2. State of the lists at time 40, queueing simulation.

404

Page 19: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

Suppose that the next event in the simulation (after time 40)

is the service completion at time 50 of the customer who was

being served (at least since time 25). We want to remove the

record of the customer at the head of the list so that this

customer can begin service. Since the HP for the list is equal

to 2 and the SL for row 2 is equal to 3, the following

calculations or operations are performed:

The time of arrival of the record in row 2 is used to

compute the delay of the customer who will enter service

(delay = 50 – 10).

19

Page 20: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

The HP for the list is set to 3.

The PL for the record in row 3 is set to 0.

Row 2, which is no longer needed, is placed at the

head of the LAS by setting its HP to 2 and the SL for row

2 to 5.

The state of both lists after these changes have been

made is shown in Figure 4.3.

Thus, removing a record from the head of the list

always requires setting only four links or pointers.

20

Page 21: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

21

0List

Head

15

25

10

Tail 0

Head

0

LAS

2

3

1

5

Physicalrow

Physicalrow

Figure 4.4. State of the lists at time 40, queueing simulation.

404

Page 22: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

22

0List

Head

25

40

15

Tail 0

Head

0

LAS

3

1

4

2

5

Physicalrow

Physicalrow

Figure 4.3. State of the lists at time 50, queueing simulation.

Page 23: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

Example 4.2: For the inventory simulation of

Section 1.5, the event list was stored in an array with

each of the four event types having a dedicated physical

location. If an event was not currently scheduled to

occur, its entry in the list was set to (represented by

1030). However, for simulation models written in

commercial simulation-software packages, the event

list is stored as a linked list ranked in increasing order on

event time, with events having an event time of simply

not included.

23

Page 24: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

Moreover, since the event list is kept ranked in

increasing order on event times (attribute 1), the next

event to occur will always be at the head of the list. We

need only remove this record to determine the next event

time (attribute 1) and its type (attribute 2).

Suppose that the event list for the inventory model is to

be stored in an array of 4 rows and 2 columns. Column

1 will be used for the attribute “event time” and column 2

for the attribute “event type” – 1, 2, 3, or 4.

24

Page 25: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

Suppose that at time 0 we know the following:

The first demand for the product (event type 2) will

occur at time 0.25.

The first inventory evaluation (event type 4) will

occur immediately at time 0.

The simulation will end (event type 3) at time 120.

There is no outstanding order scheduled to arrive

(event type 1).

The state of the event list and the LAS just after initialization at time

0 is shown in Figure 4.4.

25

Page 26: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

26

0 4

0.25 2

120 3

0

0Event List LAS

Head

Tail

Head

0

Physicalrow3

1

2

Physicalrow4

Figure 4.3. State of the lists just after initialization at time 0, inventory simulation.

Page 27: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

Note that event type 1 is not included in the event list,

and that event type 2 is in (physical) row 1 of the array

since it was the first event record to be placed in the event

list.

To determine the next (first) event to occur at time 0, the

following operations are performed:

The first record is removed from the event list.

The simulation clock is updated to the first attribute

of the record (i.e., 0).

The event type of the next event to occur is set to

the second attribute of this record (i.e., 4).27

Page 28: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

Row 3, which contained this record, is placed at

the head of the LAS.

Since the next event type is 4, an inventory-evaluation

event will occur next (at time 0). Suppose that an order

is placed at time 0 and that it will arrive from the supplier

at time 0.6. To place this order-arrival event in the event

list, the following operations are performed:

Place 0.6 and 1 in columns 1 and 2 of row 3 (the

head of the LAS).

28

Page 29: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

This new record is added to the event list by

logically preceding down the event list (using the

SLs) until the correct location is found. First ,

attribute 1 of the new record (0.6) is compared

with attribute 1 of the record in row 1 (0.25). Since

0.6 > 0.25, the new record should be further down

the list. Next, 0.6 is compared with attribute 1 of

the record in row 2 (120). (Note that the SL of the

record in row 1 is equal to 4.)

29

Page 30: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

Since 0.6 < 120, the new record is placed between

the records in physical rows 1 and 2 by adjusting

the SLs and PLs for the three records.

Another inventory-evaluation event is scheduled at

time 1 and placed in the event list.

The state of both lists after all processing has been done

at time 0 is shown in Figure 4.5.

Note that multiple lists (in addition to the LAS) can be

stored in the same physical array, potentially resulting in

significant savings in storage space.

30

Page 31: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

31

0 4

0.25 2

120 3

0

0Event List LAS

Head

Tail

Head

0

Physicalrow3

1

2

Physicalrow4

Figure 4.4. State of the lists just after initialization at time 0, inventory simulation.

Page 32: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

32

0.25 2

0.6 1

120 3

0

0Event List LAS

Head

Tail

Head

0

Physicalrow1

3

4 1 4

2

Figure 4.5. State of the lists after all processing has been done at time 0, inventory simulation.

Page 33: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

4.3. A Simple Simulation Language: simlib

simlib is a C-based simulation “language,” which is

designed to provide some insight into the operation

of commercial simulation software and to provide a

vehicle for understanding how to simulate systems more

complex than in Chapter 1.

simlib can do the following:

File a record in a list (first, last, or ranked on an

attribute)

Remove a record from a list (first or last)

33

Page 34: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

Process the event list

Compute discrete-time statistics on variables of

interest (e.g., average delay in queue)

Compute continuous-time statistics on variables

of interest (e.g., time-average number of items in

inventory)

Generate random values from the distributions

used in Chapters 1 and 2

Provide output statistics in a “standard” format

34

Page 35: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

The following are some of the characteristics of simlib: It is a collection of doubly linked lists residing in

dynamic memory, with space allocated as new

records are filed into the lists, and space freed as

records are removed from the lists.

There is a maximum of 25 lists.

Records in a list can have up to 10 attributes, with

all data stored as type float.

35

Page 36: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

List 25 is reserved for the event list, with attribute

1 being the event time and attribute 2 being the

event type. This list is kept sorted in increasing

order on event time, so that the top record refers to

the next event.

36

Page 37: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

4.5. Time-Shared Computer Model

A company has a computer with a single CPU and n

terminals, as shown in Figure 4.6. The operator of each

terminal “thinks” for an amount of time that is

exponentially distributed with mean 25 seconds, and

then sends to the CPU a job having a service time that

is exponentially distributed with mean 0.8 second.

37

Page 38: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

38

CPU

1

2

n

Queue

Unfinished jobs

Finished jobs

Terminals Computer

Figure 4.6. Time-shared computer model.

Page 39: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

Arriving jobs join a single queue for the CPU but are

served in a round-robin rather than FIFO manner. This

is, the CPU allocates to each job a maximum service

quantum of length q = 0.1 second. If the (remaining)

service time of a job, s seconds, is no more than q, the

CPU spends s seconds, plus a swap time of

second, processing the job, which then returns to its

terminal.

39

0.015

Page 40: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

However, if s > q, the CPU spends second

processing the job, which then joins the end of the

queue, and its remaining service time is decremented by

q second. This process is repeated until a job’s service

is eventually completed, at which point it returns to its

terminal, whose operator begins another think time.

40

q

Page 41: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

Let be the response time of the ith job to finish

service, which is defined as the time elapsing between

the instant the job leaves its terminal and the instant it is

finished being processed at the CPU. For each of the

cases n = 10, 20, …, 80, we use simlib to simulate the

computer system for 1000 job completions and compute

the average response time of a job, the time-average

number of jobs waiting in the queue, and the CPU

utilization.

41

iR

Page 42: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

Assume that all terminals are in the think state at time 0.

The company would like to know how many terminals it

can have on its system and still provide users with an

average response time of no more than 30 seconds.

The events for this model are:

42

Event description Event typeArrival of a job to the CPU from a terminal, at the end of a think time

1

End of a CPU run, when a job either completes its service requirement or has received the maximum processing quantum q

2

End of the simulation 3

Page 43: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

The following are the simlib lists and the attributes

for their records:

43

List Attribute 1 Attribute 21, queue Time of arrival of job to

computerRemaining service time

2, CPU Time of arrival of job to computer

Remaining service time after the present CPU pass (negative if the present CPU pass is the last one needed for this job)

25, event list Event time Event type

Page 44: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

The simlib program and explanatory flowcharts are

given in Figures 4.15 through 4.23 in the book. The

following numerical results were obtained from running

the simulation:

44

Number of terminals

Average response time (seconds)

Average number in queue

Utilization of CPU

10 1.324 0.156 0.35820 4.165 0.929 0.65830 5.505 4.453 0.91440 14.698 14.904 0.99850 24.593 23.871 0.99860 31.712 34.958 1.00070 44.310 44.666 0.99980 47.547 51.158 1.000

Page 45: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

As expected congestion in the computer gets worse as

the number of terminals increases. It appears that the

system could handle about 60 terminals without the

average response time getting much larger than 30

seconds. However, at this number the CPU would be

busy nearly all of the time. It should be kept in mind that

the results for each number of terminals are based on a

single run of the simulation (of somewhat arbitrary

length) and are thus of unknown precision.

45

Page 46: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

4.6. Multiteller Bank with Jockeying A bank with five tellers opens at 9 A.M. (no customers

present) and closes at 5 P.M., but operates until all

customers in the bank by 5 P.M. have been served.

Interarrival times of customers are IID exponential

random variables with mean 1 minute and service times are IID exponential random variables with mean 4.5

minutes.

Each teller has a separate queue. An arriving

customer joins the shortest queue (leftmost in case of

ties).

46

Page 47: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

Let ni be the total number of customers in front of teller i

(in service plus in queue) at a particular instant. If the

completion of a customer’s service at teller i causes nj >

ni + 1 for some other teller j, then the customer from the

tail of queue j jockeys to the tail of queue i (closest,

leftmost queue jockeys if several such customers). If

teller i is idle, the jockeying customer begins service at

teller i (see Figure 4.7).

47

Page 48: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

48

1 2 3 4 5

Figure 4.7. The customer being served by teller i = 3 completes service, causing the customer from the tail of queue j = 2 to jockey.

Page 49: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

The bank’s management is concerned with operating

costs, as well as the quality of service currently being

provided to customers, and is thinking of changing the

number of tellers. For each of the cases n = 4, 5, 6, and

7 tellers, we use simlib to simulate the bank and

compute the time-average total number of customers in

queue, the average delay in queue, and the maximum

delay in queue.

49

Page 50: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

The events for this model are as follows:

The following are the simlib lists:

50

Event description Event typeArrival of a customer to the bank 1Departure of a customer after completion of his/her service

2

Bank closes its doors at 5 P.M. 3

List Attribute 1 Attribute 2 Attribute 31 through n, queues

Time of arrival to queue

--- ---

n + 1 through 2n, tellers

--- --- ---

25, event list Event time Event type Teller number if event type = 2

Page 51: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

We need only a single sampst variable for this model:

The following are the random-number stream

assignments:

51

sampst variable number Meaning1 Delay in queue (or queues)

Stream Purpose1 Interarrival times2 Service times

The simlib program and explanatory flowcharts are given in Figures 4.27 through 4.35 in the book. The following numerical results were obtained from running the simulation:

Page 52: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

4 tellers

Average number in queue = 51.319

Delay in queue (minutes):

5 tellers

Average number in queue = 4.441

Delay in queue (minutes):

52

Average Number of values

Maximum Minimum

63.223 501 156.363 0.000

Average Number of values

Maximum Minimum

4.481 483 21.887 0.000

Page 53: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

6 tellers

Average number in queue = 0.718

Delay in queue (minutes):

7 tellers

Average number in queue = 0.179

Delay in queue (minutes):

53

Average Number of values

Maximum Minimum

0.764 467 16.510 0.000

Average Number of values

Maximum Minimum

0.176 493 6.971 0.000

Page 54: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

It is definitely not advisable for the bank to reduce the

number of tellers from five to four, since the average

delay in queue would then be approximately 1 hour.

Increasing the number of tellers from five to six will

provide a modest (the book says significant)

improvement in customer service. For example, the

average delay in queue would only be reduced from 4.48

minutes to 0.76 minute.

54

Page 55: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

Whether this is economically advisable would depend on

how management values this improvement in customer

service relative to the cost of an additional teller. Adding

a seventh teller definitely does not seem advisable.

55

Page 56: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

4.7. Job-Shop Model

A manufacturing system consists of five workstations,

and at present stations 1, 2, …, 5 consist of 3, 2, 4, 3,

and 1 identical machine(s), as shown in Figure 4.8. Jobs

arrive at the system with interarrival times that are IID

exponential random variables with mean 0.25 hour. Jobs

are of type 1, 2, and 3 with respective probabilities 0.3,

0.5, and 0.4.

56

Page 57: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

57

1 2

3

54

Type 1 job

Figure 4.8. Manufacturing system showing the route of type 1 jobs.

Page 58: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

Job types 1, 2, and 3 require 4, 3, and 5 tasks to be

done, and each task must be done at a specified station

and in a prescribed order. The routings for the

different job types are:

There is a single FIFO queue at each workstation.

58

Job type Workstations in routing1 3, 1, 2, 52 4, 1, 33 2, 5, 1, 4, 3

Page 59: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

The time to perform a task at a particular machine is an

independent 2-Erlang (Probability distribution) random

variable whose mean depends on the job type and the

station to which the machine belongs. (If X is a 2-Erlang

random variable with mean r, then X = Y1 + Y2, where Y1

and Y2 are independent exponential random variables

each with mean r / 4.

59

Page 60: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

The mean service times for each job type and each

task are:

We will simulate the system for 365 eight-hour days

(with no loss of continuity between days) and compute

the average total delay in queue for each job type and

the overall average job total delay.

60

Job type Mean service times for successive tasks (hours)

1 0.50, 0.60, 0.85, 0.502 1.10, 0.80, 0.753 1.20, 0.25, 0.70, 0.90, 1.00

Page 61: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

We use the true job-type probabilities 0.3, 0.2, and 0.5

as weights in computing the latter quantity. In addition,

we will compute the average number in queue, the

utilization, and average delay in queue for each station.

Suppose that all machines cost approximately the same

and that the company can purchase one new machine to

improve system efficiency. We will use the results of the

above simulation to decide what additional simulation

runs should be made.

61

Page 62: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

From these additional runs, we will use the overall

average job total delay to help decide what type of

machine the company should buy.

The events for this model are:

62

Event description Event typeArrival of a job to the system 1Departure of a job from a particular station 2End of the simulation 3

Page 63: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

We will use the following list structure:

63

List Attribute 1 Attribute 2 Attribute 3 Attribute 4

1 to 5, queues

Time of arrivalto station

Job type Task number ---

25, event list

Event time Event type Job type Task number

Page 64: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

We will use the following sampstat variables:

64

sampst variable number Meaning1 Delay in queue at station 12 Delay in queue at station 23 Delay in queue at station 34 Delay in queue at station 45 Delay in queue at station 56 Delay in queues for job type 17 Delay in queues for job type 28 Delay in queues for job type 3

Page 65: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

We will use the following timestat variables:

The random-number stream assignments are:

65

timestat variable number Meaning1 Number of machines busy in station 12 Number of machines busy in station 23 Number of machines busy in station 34 Number of machines busy in station 45 Number of machines busy in station 5

Stream Purpose1 Interarrival times2 Job types3 Service times

Page 66: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

The simlib program and explanatory flowcharts are given

in Figures 4.39 through 4.45 in the book.

The following are the results from running the

simulation:

Overall average job total delay = 10.870

66

Job type Average total delay in queue1 10.0222 9.4033 15.808

Page 67: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

Workstation Average number in queue

Average utilization

Average delay in queue

1 14.310 0.969 3.0552 11.404 0.978 5.6773 0.711 0.719 0.1774 17.098 0.961 6.1105 4.095 0.797 1.043

67

Weighted by job type, the average time spent by

jobs waiting in queues was almost 11 hours. This is

not the average time in the system, since it does not

include processing times at the stations.

Page 68: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

Looking at the statistics by station, it appears that the

bottlenecks are at stations 1, 2, and 4, with station 4

perhaps being the worst. Thus, we made three

additional runs, adding a machine to each of these

stations to see which type of new machine would

improve system performance the most. (Stations 3 and

5 appear to be relatively uncongested, so we did not

consider them for a new machine.)

68

Page 69: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

Using the overall average job total delay as the measure

of performance, the results from these additional

simulations are given in the following table. From simply

looking at these numbers, we see that a machine should

apparently be added to station 4 to obtain the greatest

reduction in overall average job total delay. As usual, this

conclusion is rather tentative, since we have only made a

single simulation run of each system variant and the

results are quite close.

69

Page 70: Chapter 4. Modeling Complex Systems 4.1. Introduction 4.2. List Processing in Simulation 4.3. A Simple Simulation Language: simlib 4.4. Single-Server Queuing.

Overall average job total delays for current and

proposed system configurations:

70

Number of machines in stations Overall average job total delay (in hours)

3, 2, 4, 3, 1 (current configuration) 10.94, 2, 4, 3, 1 (add a machine to station 1) 8.13, 3, 4, 3, 1 (add a machine to station 2) 7.63, 2, 4, 4, 1 (add a machine to station 4) 7.5