SlideShare a Scribd company logo
1 of 82
Download to read offline
Introduction to
Discrete-Event
  Simulation
 Using SimPy

  Chun-Chieh
     Huang         Introduction to Discrete-Event Simulation
    jjhuang
                                  Using SimPy
What is
Simulation and
When to Use it?

What is
Discrete-Event
                                 Chun-Chieh Huang
Simulation?
                                      jjhuang
Example to
Illustrate World
Views                       DSP and Algorithm Design Department
Introduction to                Metanoia Communications Inc.
SimPy                           <jiunjie.huang@gmail.com>
SimPy Example

References                           June 9, 2012
Outline

Introduction to
Discrete-Event
  Simulation
 Using SimPy

  Chun-Chieh
     Huang
                    1   What is Simulation and When to Use it?
    jjhuang


What is
Simulation and
                    2   What is Discrete-Event Simulation?
When to Use it?

What is
Discrete-Event      3   Example to Illustrate World Views
Simulation?

Example to
Illustrate World
Views               4   Introduction to SimPy
Introduction to
SimPy

SimPy Example       5   SimPy Example
References
What is Simulation and When to Use it?

Introduction to
Discrete-Event
  Simulation
 Using SimPy           Simulation
  Chun-Chieh               a computer program that creates a virtual environment
     Huang
    jjhuang                in order to study physical problems

What is
Simulation and
When to Use it?

What is
Discrete-Event
Simulation?

Example to
Illustrate World
Views

Introduction to
SimPy

SimPy Example

References
What is Simulation and When to Use it?

Introduction to
Discrete-Event
  Simulation
 Using SimPy           Simulation
  Chun-Chieh               a computer program that creates a virtual environment
     Huang
    jjhuang                in order to study physical problems

What is
                       When to use simulation
Simulation and
When to Use it?
                           hard to do real experiment,
                           e.g. battle field, or banking system
What is
Discrete-Event
Simulation?

Example to
Illustrate World
Views

Introduction to
SimPy

SimPy Example

References
What is Simulation and When to Use it?

Introduction to
Discrete-Event
  Simulation
 Using SimPy           Simulation
  Chun-Chieh               a computer program that creates a virtual environment
     Huang
    jjhuang                in order to study physical problems

What is
                       When to use simulation
Simulation and
When to Use it?
                           hard to do real experiment,
                           e.g. battle field, or banking system
What is
Discrete-Event             cheaper to do simulation,
Simulation?
                           e.g. RTL simulation for IC design,
Example to
Illustrate World           or highway/freeway route planning
Views

Introduction to
SimPy

SimPy Example

References
What is Simulation and When to Use it?

Introduction to
Discrete-Event
  Simulation
 Using SimPy           Simulation
  Chun-Chieh               a computer program that creates a virtual environment
     Huang
    jjhuang                in order to study physical problems

What is
                       When to use simulation
Simulation and
When to Use it?
                           hard to do real experiment,
                           e.g. battle field, or banking system
What is
Discrete-Event             cheaper to do simulation,
Simulation?
                           e.g. RTL simulation for IC design,
Example to
Illustrate World           or highway/freeway route planning
Views
                           analyzing bottleneck of current workflow
Introduction to
SimPy

SimPy Example

References
What is Simulation and When to Use it?

Introduction to
Discrete-Event
  Simulation
 Using SimPy           Simulation
  Chun-Chieh               a computer program that creates a virtual environment
     Huang
    jjhuang                in order to study physical problems

What is
                       When to use simulation
Simulation and
When to Use it?
                           hard to do real experiment,
                           e.g. battle field, or banking system
What is
Discrete-Event             cheaper to do simulation,
Simulation?
                           e.g. RTL simulation for IC design,
Example to
Illustrate World           or highway/freeway route planning
Views
                           analyzing bottleneck of current workflow
Introduction to
SimPy                  When not to use simulation
SimPy Example              more expensive to do simulation,
References                 e.g. simple harmonic motion
What is Simulation and When to Use it?

Introduction to
Discrete-Event
  Simulation
 Using SimPy           Simulation
  Chun-Chieh               a computer program that creates a virtual environment
     Huang
    jjhuang                in order to study physical problems

What is
                       When to use simulation
Simulation and
When to Use it?
                           hard to do real experiment,
                           e.g. battle field, or banking system
What is
Discrete-Event             cheaper to do simulation,
Simulation?
                           e.g. RTL simulation for IC design,
Example to
Illustrate World           or highway/freeway route planning
Views
                           analyzing bottleneck of current workflow
Introduction to
SimPy                  When not to use simulation
SimPy Example              more expensive to do simulation,
References                 e.g. simple harmonic motion
                           problems that can be analyzed by pencil and paper
Categories of Simulation

Introduction to
Discrete-Event
  Simulation
 Using SimPy

  Chun-Chieh
                       Continuous or discrete
     Huang
    jjhuang
                           state variable is continuous, e.g. weather systems
                           state variable is discrete, e.g. number of customers
What is
Simulation and
When to Use it?

What is
Discrete-Event
Simulation?

Example to
Illustrate World
Views

Introduction to
SimPy

SimPy Example

References
Categories of Simulation

Introduction to
Discrete-Event
  Simulation
 Using SimPy

  Chun-Chieh
                       Continuous or discrete
     Huang
    jjhuang
                           state variable is continuous, e.g. weather systems
                           state variable is discrete, e.g. number of customers
What is
Simulation and         Static or dynamic
When to Use it?
                           Static: represents a system at a particular point of time
What is
Discrete-Event                  representation of time is unnecessary [1]
Simulation?                     sometimes called Monte-Carlo simulation [2]
Example to                 Dynamic: represents systems as they change over time
Illustrate World
Views                           e.g. banking system from 9:00 AM to 5:00 PM
Introduction to
SimPy

SimPy Example

References
Categories of Simulation

Introduction to
Discrete-Event
  Simulation
 Using SimPy

  Chun-Chieh
                       Continuous or discrete
     Huang
    jjhuang
                            state variable is continuous, e.g. weather systems
                            state variable is discrete, e.g. number of customers
What is
Simulation and         Static or dynamic
When to Use it?
                            Static: represents a system at a particular point of time
What is
Discrete-Event                   representation of time is unnecessary [1]
Simulation?                      sometimes called Monte-Carlo simulation [2]
Example to                  Dynamic: represents systems as they change over time
Illustrate World
Views                            e.g. banking system from 9:00 AM to 5:00 PM
Introduction to
SimPy
                       Deterministic or stochastic
SimPy Example               Deterministic: contains no random variable
References                  Stochastic: has one or more random variables
What is Discrete-Event Simulation?

Introduction to
Discrete-Event
  Simulation
 Using SimPy

  Chun-Chieh
     Huang
    jjhuang            Discrete-Event Simulation is
                            Discrete
What is
Simulation and              Dynamic
When to Use it?
                            Stochastic
What is
Discrete-Event         Simulation for queueing in a post office is DES
Simulation?

Example to
                       Mostly, but not limited to, queueing systems
Illustrate World
Views
                            factory work flow
Introduction to
                            freeway traffic simulation
SimPy                       network traffic simulation
SimPy Example

References
Discrete-Event Simulation World Views

Introduction to
Discrete-Event
  Simulation
 Using SimPy

  Chun-Chieh
                       Activity-oriented
     Huang
    jjhuang
                            fixed increment of time
                            time-consuming
What is
Simulation and
When to Use it?

What is
Discrete-Event
Simulation?

Example to
Illustrate World
Views

Introduction to
SimPy

SimPy Example

References
Discrete-Event Simulation World Views

Introduction to
Discrete-Event
  Simulation
 Using SimPy

  Chun-Chieh
                       Activity-oriented
     Huang
    jjhuang
                            fixed increment of time
                            time-consuming
What is
Simulation and         Event-oriented
When to Use it?
                            on each event, generate next event and
What is
Discrete-Event              put into event queue and sort
Simulation?
                            simulation time advances to next closest event
Example to                  faster than activity-oriented
Illustrate World
Views

Introduction to
SimPy

SimPy Example

References
Discrete-Event Simulation World Views

Introduction to
Discrete-Event
  Simulation
 Using SimPy

  Chun-Chieh
                       Activity-oriented
     Huang
    jjhuang
                            fixed increment of time
                            time-consuming
What is
Simulation and         Event-oriented
When to Use it?
                            on each event, generate next event and
What is
Discrete-Event              put into event queue and sort
Simulation?
                            simulation time advances to next closest event
Example to                  faster than activity-oriented
Illustrate World
Views
                       Process-oriented
Introduction to
SimPy                       abstract one object into a process
SimPy Example
                            easier to maintain in the end
References
Discrete-Event Simulation World Views

Introduction to
Discrete-Event
  Simulation
 Using SimPy

  Chun-Chieh
                       Activity-oriented
     Huang
    jjhuang
                            fixed increment of time
                            time-consuming
What is
Simulation and         Event-oriented
When to Use it?
                            on each event, generate next event and
What is
Discrete-Event              put into event queue and sort
Simulation?
                            simulation time advances to next closest event
Example to                  faster than activity-oriented
Illustrate World
Views
                       Process-oriented
Introduction to
SimPy                       abstract one object into a process
SimPy Example
                            easier to maintain in the end
References
                            SimPy belongs here!
Example to Illustrate World Views

Introduction to
Discrete-Event
  Simulation
 Using SimPy

  Chun-Chieh
     Huang
    jjhuang


What is
Simulation and         Simulating a post office with only one clerk
When to Use it?
                       Customers come in at random time
What is
Discrete-Event         and wait if the clerk is already serving
Simulation?

Example to             Clerk serves each customer for a random period of time
Illustrate World
Views

Introduction to
SimPy

SimPy Example

References
Discrete-Event Simulation World Views

Introduction to
Discrete-Event
  Simulation
 Using SimPy

  Chun-Chieh           Activity-oriented
     Huang
    jjhuang                 fixed increment of time
What is
                            time-consuming
Simulation and
When to Use it?
                       Event-oriented
What is                     on each event, generate next event and
Discrete-Event
Simulation?
                            put into event queue and sort
Example to
                            simulation time advances to next closest event
Illustrate World            faster than activity-oriented
Views

Introduction to
                       Process-oriented
SimPy
                            abstract one object into a process
SimPy Example               easier to maintain in the end
References
Activity-Oriented Discrete-Event Simulation

Introduction to
Discrete-Event
  Simulation         6
 Using SimPy

  Chun-Chieh
     Huang           5
    jjhuang


What is
                     4
Simulation and
When to Use it?
                                Simulation starts at 2.0!
What is
Discrete-Event       3
Simulation?                         Gen 1st arr at 2.6
Example to
Illustrate World     2
Views                    Check events: 1st arr at 2.6, no action
Introduction to
SimPy                1
SimPy Example

References
                     0
                         0      1     2      3      4       5      6   7   8   9
Activity-Oriented Discrete-Event Simulation

Introduction to
Discrete-Event
  Simulation         6
 Using SimPy

  Chun-Chieh
     Huang           5
    jjhuang


What is
Simulation and
                     4
When to Use it?

What is
Discrete-Event       3
Simulation?

Example to
Illustrate World     2
Views                    Check events: 1st arr at 2.6, no action
Introduction to
SimPy                1
SimPy Example

References
                     0
                         0     1      2     3      4      5        6   7   8   9
Activity-Oriented Discrete-Event Simulation

Introduction to
Discrete-Event
  Simulation         6
 Using SimPy

  Chun-Chieh
     Huang           5
    jjhuang


What is
Simulation and
                     4
When to Use it?

What is
Discrete-Event       3
Simulation?

Example to
Illustrate World     2
Views                    Check events: 1st arr at 2.6, no action
Introduction to
SimPy                1
SimPy Example

References
                     0
                         0    1      2      3     4      5         6   7   8   9
Activity-Oriented Discrete-Event Simulation

Introduction to
Discrete-Event
  Simulation         6
 Using SimPy

  Chun-Chieh
     Huang           5
    jjhuang


What is
Simulation and
                     4
When to Use it?

What is
Discrete-Event       3
Simulation?

Example to
Illustrate World     2
Views                        Check events: 1st arr at 2.6, no action
Introduction to
SimPy                1
SimPy Example

References
                     0
                         0        1     2      3      4     5      6   7   8   9
Activity-Oriented Discrete-Event Simulation

Introduction to
Discrete-Event
  Simulation         6
 Using SimPy

  Chun-Chieh
     Huang           5
    jjhuang


What is
Simulation and
                     4
When to Use it?

What is
Discrete-Event       3
Simulation?

Example to
Illustrate World     2
Views                        Check events: 1st arr at 2.6, no action
Introduction to
SimPy                1
SimPy Example

References
                     0
                         0       1      2     3      4      5     6    7   8   9
Activity-Oriented Discrete-Event Simulation

Introduction to
Discrete-Event
  Simulation         6
 Using SimPy

  Chun-Chieh
     Huang           5
    jjhuang


What is
Simulation and
                     4
When to Use it?

What is
Discrete-Event       3
Simulation?

Example to
Illustrate World     2
Views                        Check events: 1st arr at 2.6, no action
Introduction to
SimPy                1
SimPy Example

References
                     0
                         0      1      2      3     4      5      6    7   8   9
Activity-Oriented Discrete-Event Simulation

Introduction to
Discrete-Event
  Simulation         6
 Using SimPy

  Chun-Chieh
     Huang           5
    jjhuang


What is
Simulation and
                     4
When to Use it?

What is
Discrete-Event       3
Simulation?

Example to
Illustrate World     2
Views                        Check events: 1st arr at 2.6, process now
Introduction to
SimPy                1
SimPy Example

References
                     0
                         0       1      2     3     4      5     6       7   8   9
Activity-Oriented Discrete-Event Simulation

Introduction to
Discrete-Event
  Simulation         6
 Using SimPy

  Chun-Chieh
     Huang           5
    jjhuang


What is
                     4
Simulation and
When to Use it?
                                     First arrival!
What is
Discrete-Event       3
Simulation?

Example to
Illustrate World     2
Views

Introduction to
SimPy                1
SimPy Example

References
                     0
                         0   1   2      3       4     5   6   7   8   9
Activity-Oriented Discrete-Event Simulation

Introduction to
Discrete-Event
  Simulation         6
 Using SimPy

  Chun-Chieh
     Huang           5
    jjhuang                  Calculate service time, end at 4.0
What is
                     4
Simulation and
When to Use it?
                                 Calculate next arrival at 3.5
What is
Discrete-Event       3
Simulation?

Example to
Illustrate World     2
Views

Introduction to
SimPy                1
SimPy Example

References
                     0
                         0   1       2      3      4      5      6   7   8   9
Activity-Oriented Discrete-Event Simulation

Introduction to
Discrete-Event
  Simulation         6
 Using SimPy

  Chun-Chieh
     Huang           5
    jjhuang


What is
Simulation and
                     4
When to Use it?

What is
Discrete-Event       3
Simulation?

Example to
Illustrate World     2
Views                        Check events: 2nd arrival at 3.5, no action
Introduction to
SimPy                1
SimPy Example

References
                     0
                         0       1      2     3      4      5     6        7   8   9
Activity-Oriented Discrete-Event Simulation

Introduction to
Discrete-Event
  Simulation         6
 Using SimPy

  Chun-Chieh
     Huang           5
    jjhuang


What is
Simulation and
                     4
When to Use it?

What is
Discrete-Event       3
Simulation?

Example to
Illustrate World     2
Views                        Check events: 2nd arrival at 3.5, no action
Introduction to
SimPy                1
SimPy Example

References
                     0
                         0      1      2      3     4      5      6        7   8   9
Activity-Oriented Discrete-Event Simulation

Introduction to
Discrete-Event
  Simulation         6
 Using SimPy

  Chun-Chieh
     Huang           5
    jjhuang


What is
Simulation and
                     4
When to Use it?

What is
Discrete-Event       3
Simulation?

Example to
Illustrate World     2
Views                        Check events: 2nd arrival at 3.5, no action
Introduction to
SimPy                1
SimPy Example

References
                     0
                         0      1     2      3      4     5      6         7   8   9
Activity-Oriented Discrete-Event Simulation

Introduction to
Discrete-Event
  Simulation         6
 Using SimPy

  Chun-Chieh
     Huang           5
    jjhuang


What is
Simulation and
                     4
When to Use it?

What is
Discrete-Event       3
Simulation?

Example to
Illustrate World     2
Views                        Check events: 2nd arrival at 3.5, no action
Introduction to
SimPy                1
SimPy Example

References
                     0
                         0     1      2     3      4      5     6      7   8   9
Activity-Oriented Discrete-Event Simulation

Introduction to
Discrete-Event
  Simulation         6
 Using SimPy

  Chun-Chieh
     Huang           5
    jjhuang


What is
Simulation and
                     4
When to Use it?

What is
Discrete-Event       3
Simulation?

Example to
Illustrate World     2
Views                        Check events: 2nd arrival at 3.5, no action
Introduction to
SimPy                1
SimPy Example

References
                     0
                         0    1      2      3     4      5      6     7    8   9
Activity-Oriented Discrete-Event Simulation

Introduction to
Discrete-Event
  Simulation         6
 Using SimPy

  Chun-Chieh
     Huang           5
    jjhuang


What is
Simulation and
                     4
When to Use it?

What is
Discrete-Event       3
Simulation?

Example to
Illustrate World     2
Views                        Check events: 2nd arrival at 3.5, no action
Introduction to
SimPy                1
SimPy Example

References
                     0
                         0    1     2      3      4     5      6      7    8   9
Activity-Oriented Discrete-Event Simulation

Introduction to
Discrete-Event
  Simulation         6
 Using SimPy

  Chun-Chieh
     Huang           5
    jjhuang


What is
Simulation and
                     4
When to Use it?

What is
Discrete-Event       3
Simulation?

Example to
Illustrate World     2
Views                        Check events: 2nd arrival at 3.5, no action
Introduction to
SimPy                1
SimPy Example

References
                     0
                         0   1      2     3      4      5     6      7     8   9
Activity-Oriented Discrete-Event Simulation

Introduction to
Discrete-Event
  Simulation         6
 Using SimPy

  Chun-Chieh
     Huang           5
    jjhuang


What is
Simulation and
                     4
When to Use it?

What is
Discrete-Event       3
Simulation?

Example to
Illustrate World     2
Views                        Check events: 2nd arrival at 3.5, no action
Introduction to
SimPy                1
SimPy Example

References
                     0
                         0   1     2      3     4      5      6     7      8   9
Activity-Oriented Discrete-Event Simulation

Introduction to
Discrete-Event
  Simulation         6
 Using SimPy

  Chun-Chieh
     Huang           5
    jjhuang


What is
Simulation and
                     4
When to Use it?

What is
Discrete-Event       3
Simulation?

Example to
Illustrate World     2
Views                        Check events: 2nd arrival at 3.5, process now
Introduction to
SimPy                1
SimPy Example

References
                     0
                         0   1      2     3      4     5      6     7        8   9
Activity-Oriented Discrete-Event Simulation

Introduction to
Discrete-Event
  Simulation         6
 Using SimPy

  Chun-Chieh
     Huang           5
    jjhuang


What is
                     4
Simulation and
When to Use it?
                                          Second arrival!
What is
Discrete-Event       3
Simulation?

Example to
Illustrate World     2
Views

Introduction to
SimPy                1
SimPy Example

References
                     0
                         0   1   2    3        4     5      6   7   8   9
Activity-Oriented Discrete-Event Simulation

Introduction to
Discrete-Event
  Simulation         6
 Using SimPy

  Chun-Chieh
     Huang           5
    jjhuang


What is
                     4
Simulation and
When to Use it?
                                     Calculate next arrival at ...
What is
Discrete-Event       3
Simulation?

Example to
Illustrate World     2
Views

Introduction to
SimPy                1
SimPy Example

References
                     0
                         0   1   2       3      4       5      6     7   8   9
Activity-Oriented Discrete-Event Simulation

Introduction to
Discrete-Event
  Simulation         6
 Using SimPy

  Chun-Chieh
     Huang           5
    jjhuang


What is
Simulation and
                     4
When to Use it?

What is
Discrete-Event       3
Simulation?

Example to
Illustrate World     2
Views                        Check events: service end at 4.0, no action
Introduction to
SimPy                1
SimPy Example

References
                     0
                         0   1    2      3     4     5      6     7        8   9
Activity-Oriented Discrete-Event Simulation

Introduction to
Discrete-Event
  Simulation         6
 Using SimPy

  Chun-Chieh
     Huang           5
    jjhuang


What is
Simulation and
                     4
When to Use it?

What is
Discrete-Event       3
Simulation?

Example to
Illustrate World     2
Views                            Check events: service end at 4.0, no action
Introduction to
SimPy                1
SimPy Example

References
                     0
                         0   1       2      3     4      5     6      7        8   9
Activity-Oriented Discrete-Event Simulation

Introduction to
Discrete-Event
  Simulation         6
 Using SimPy

  Chun-Chieh
     Huang           5
    jjhuang


What is
Simulation and
                     4
When to Use it?

What is
Discrete-Event       3
Simulation?

Example to
Illustrate World     2
Views                            Check events: service end at 4.0, no action...
Introduction to
SimPy                1
SimPy Example

References
                     0
                         0   1        2     3      4      5     6      7      8   9
Discrete-Event Simulation World Views

Introduction to
Discrete-Event
  Simulation
 Using SimPy

  Chun-Chieh           Activity-oriented
     Huang
    jjhuang                 fixed increment of time
                            time-consuming
What is
Simulation and
When to Use it?        Event-oriented
What is                     on each event, generate next event and
Discrete-Event
Simulation?                 put into event queue and sort
Example to
                            simulation time advances to next closest event
Illustrate World            faster than activity-oriented
Views

Introduction to        Process-oriented
SimPy
                            abstract one object into a process
SimPy Example
                            easier to maintain in the end
References
Event-Oriented Discrete-Event Simulation

Introduction to
Discrete-Event
  Simulation         6
 Using SimPy
                                                  2.6: 1st arr
  Chun-Chieh
     Huang           5
    jjhuang


What is
                     4
Simulation and
When to Use it?
                             Simulation starts!
What is
Discrete-Event       3
Simulation?

Example to
Illustrate World     2
Views

Introduction to
SimPy                1
SimPy Example

References
                     0
                         0     1      2      3    4     5        6   7   8   9
Event-Oriented Discrete-Event Simulation

Introduction to
Discrete-Event
  Simulation         6
 Using SimPy
                                                  2.6: 1st arr
  Chun-Chieh
     Huang           5
    jjhuang


What is
                     4
Simulation and
When to Use it?
                                 First arrival!
What is
Discrete-Event       3
Simulation?

Example to
Illustrate World     2
Views

Introduction to
SimPy                1
SimPy Example

References
                     0
                         0   1      2       3     4     5        6   7   8   9
Event-Oriented Discrete-Event Simulation

Introduction to
Discrete-Event
  Simulation         6
 Using SimPy
                                             3.5: 2nd arr 4.0: 1st arr end
  Chun-Chieh
     Huang           5
    jjhuang              Calculate service time, end at 4.0
What is
                     4
Simulation and
When to Use it?
                             Calculate next arrival at 3.5
What is
Discrete-Event       3
Simulation?

Example to
Illustrate World     2
Views

Introduction to
SimPy                1
SimPy Example

References
                     0
                         0       1      2      3      4      5    6      7   8   9
Event-Oriented Discrete-Event Simulation

Introduction to
Discrete-Event
  Simulation         6
 Using SimPy
                                        3.5: 2nd arr 4.0: 1st arr end
  Chun-Chieh
     Huang           5
    jjhuang


What is
                     4
Simulation and
When to Use it?
                                     Second arrival!
What is
Discrete-Event       3
Simulation?

Example to
Illustrate World     2
Views

Introduction to
SimPy                1
SimPy Example

References
                     0
                         0   1   2        3     4      5     6      7   8   9
Event-Oriented Discrete-Event Simulation

Introduction to
Discrete-Event
  Simulation         6
 Using SimPy
                                         4.0: 1st arr end
  Chun-Chieh
     Huang           5
    jjhuang


What is
Simulation and
                     4
When to Use it?

What is
Discrete-Event       3
Simulation?

Example to
Illustrate World     2
Views

Introduction to
SimPy                1
SimPy Example

References
                     0
                         0   1   2   3    4      5      6   7   8   9
Event-Oriented Discrete-Event Simulation

Introduction to
Discrete-Event
  Simulation         6
 Using SimPy
                                             4.0: 1st arr end
  Chun-Chieh
     Huang           5
    jjhuang                      End service of 1st arrival.
What is
Simulation and
                     4
When to Use it?

What is
Discrete-Event       3
Simulation?

Example to
Illustrate World     2
Views

Introduction to
SimPy                1
SimPy Example

References
                     0
                         0   1   2      3      4      5        6   7   8   9
Discrete-Event Simulation World Views

Introduction to
Discrete-Event
  Simulation
 Using SimPy
                       Activity-oriented
  Chun-Chieh
     Huang                  fixed increment of time
    jjhuang
                            time-consuming
What is                Event-oriented
Simulation and
When to Use it?             on each event, generate next event and
What is                     put into event queue and sort
Discrete-Event
Simulation?                 simulation time advances to next closest event
Example to
                            faster than activity-oriented
Illustrate World
Views                  Process-oriented
Introduction to             abstract one object into a process
SimPy
                                 Arrival process for customers, or A
SimPy Example
                                 Clerk process, or S
References
                            easier to maintain in the end
Process-Oriented Discrete-Event Simulation

Introduction to
Discrete-Event
  Simulation
 Using SimPy

  Chun-Chieh
     Huang
    jjhuang
                       Arrival is an infinite loop of the following
What is                     Calculate next arrival time
Simulation and
When to Use it?             Sleep until next arrival
What is                     Add customer into queue
Discrete-Event
Simulation?            Clerk is an infinite loop of the following
Example to                  Sleep until waken up by customers
Illustrate World
Views                       Serve the customer on waken up
Introduction to             until there is no customer in line
SimPy

SimPy Example

References
Process-Oriented Discrete-Event Simulation

Introduction to
Discrete-Event
  Simulation         6
 Using SimPy

  Chun-Chieh
     Huang           5
    jjhuang                                               A: Gen 1st arr at 2.6
What is
                     4
Simulation and
When to Use it?
                             Simulation starts!
What is
Discrete-Event       3
Simulation?                                                        S:
Example to
Illustrate World     2
Views

Introduction to
SimPy                1
SimPy Example

References
                     0
                         0     1      2      3    4   5       6      7     8      9
Process-Oriented Discrete-Event Simulation

Introduction to
Discrete-Event
  Simulation         6
 Using SimPy

  Chun-Chieh
     Huang           5
    jjhuang                                           A: Add customer to queue

What is
                     4
Simulation and
When to Use it?
                                 First arrival!
What is
Discrete-Event       3
Simulation?                                                     S:
Example to
Illustrate World     2
Views

Introduction to
SimPy                1
SimPy Example

References
                     0
                         0   1      2       3     4   5     6     7     8        9
Process-Oriented Discrete-Event Simulation

Introduction to
Discrete-Event
  Simulation         6
 Using SimPy

  Chun-Chieh
     Huang           5
    jjhuang                                       A: Calc next arr at 3.5
What is
Simulation and
                     4
When to Use it?

What is
Discrete-Event       3
Simulation?                                                 S:
Example to
Illustrate World     2
Views

Introduction to
SimPy                1
SimPy Example

References
                     0
                         0   1   2   3    4   5        6      7     8       9
Process-Oriented Discrete-Event Simulation

Introduction to
Discrete-Event
  Simulation         6
 Using SimPy

  Chun-Chieh
     Huang           5
    jjhuang                                               A:
What is
Simulation and
                     4
When to Use it?

What is
Discrete-Event       3
Simulation?
                                              S: Serv, calc serv T at 4.0
Example to
Illustrate World     2
Views

Introduction to
SimPy                1
SimPy Example

References
                     0
                         0   1   2   3    4   5      6      7     8         9
Process-Oriented Discrete-Event Simulation

Introduction to
Discrete-Event
  Simulation         6
 Using SimPy

  Chun-Chieh
     Huang           5
    jjhuang                                            A: Add customer to queue

What is
                     4
Simulation and
When to Use it?
                                     Second arrival!
What is
Discrete-Event       3
Simulation?                                                      S:
Example to
Illustrate World     2
Views

Introduction to
SimPy                1
SimPy Example

References
                     0
                         0   1   2        3     4      5     6     7     8        9
Process-Oriented Discrete-Event Simulation

Introduction to
Discrete-Event
  Simulation         6
 Using SimPy

  Chun-Chieh
     Huang           5
    jjhuang                                                     A: Calc next arr at ...
What is
                     4
Simulation and
When to Use it?
                                 Calc next arrival at ...
What is
Discrete-Event       3
Simulation?                                                              S:
Example to
Illustrate World     2
Views

Introduction to
SimPy                1
SimPy Example

References
                     0
                         0   1    2       3      4          5       6       7      8      9
Process-Oriented Discrete-Event Simulation

Introduction to
Discrete-Event
  Simulation         6
 Using SimPy

  Chun-Chieh
     Huang           5
    jjhuang                                                A:
What is
Simulation and
                     4
When to Use it?

What is
Discrete-Event       3
Simulation?                                   S: 1st arr end serv. Call next.
Example to
Illustrate World     2
Views

Introduction to
SimPy                1
SimPy Example

References
                     0
                         0   1   2   3    4     5      6      7      8     9
Process-Oriented Discrete-Event Simulation

Introduction to
Discrete-Event
  Simulation         6
 Using SimPy

  Chun-Chieh
     Huang           5
    jjhuang                                                    A:
What is
Simulation and
                     4
When to Use it?

What is
Discrete-Event       3
Simulation?                                   S: Serv 2nd arr. Calc end time at ...
Example to
Illustrate World     2
Views

Introduction to
SimPy                1
SimPy Example

References
                     0
                         0   1   2   3    4        5      6      7     8      9
Implementing Discrete-Event Simulation

Introduction to
Discrete-Event
  Simulation
 Using SimPy

  Chun-Chieh           Use your own C/C++ implementation
     Huang
    jjhuang                takes time to write simulation engine and algorithm code
                           hard to debug when both are not verified
What is
Simulation and             not very convincing
When to Use it?

What is
Discrete-Event
Simulation?

Example to
Illustrate World
Views

Introduction to
SimPy

SimPy Example

References
Implementing Discrete-Event Simulation

Introduction to
Discrete-Event
  Simulation
 Using SimPy

  Chun-Chieh           Use your own C/C++ implementation
     Huang
    jjhuang                 takes time to write simulation engine and algorithm code
                            hard to debug when both are not verified
What is
Simulation and              not very convincing
When to Use it?

What is
                       Use generalized simulation library, or language
Discrete-Event
Simulation?
                            SIMULA programming language
                            C++SIM or JavaSIM [3]
Example to
Illustrate World            SimEvents in Simulink/MATLAB
Views
                            SimPy [4]
Introduction to
SimPy

SimPy Example

References
Implementing Discrete-Event Simulation

Introduction to
Discrete-Event
  Simulation
 Using SimPy

  Chun-Chieh           Use your own C/C++ implementation
     Huang
    jjhuang                 takes time to write simulation engine and algorithm code
                            hard to debug when both are not verified
What is
Simulation and              not very convincing
When to Use it?

What is
                       Use generalized simulation library, or language
Discrete-Event
Simulation?
                            SIMULA programming language
                            C++SIM or JavaSIM [3]
Example to
Illustrate World            SimEvents in Simulink/MATLAB
Views
                            SimPy [4]
Introduction to
SimPy                  Use special purpose simulation packages
SimPy Example               ns-3 for network simulation [5]
References
Introduction to SimPy

Introduction to
Discrete-Event
  Simulation
 Using SimPy

  Chun-Chieh           Uses Python for modeling
     Huang
    jjhuang                Python is a scripting language like MATLAB, but faster!
                           Python is free!
What is
Simulation and             Python is very easy to write and beautiful!
When to Use it?

What is
Discrete-Event
Simulation?

Example to
Illustrate World
Views

Introduction to
SimPy

SimPy Example

References
Introduction to SimPy

Introduction to
Discrete-Event
  Simulation
 Using SimPy

  Chun-Chieh           Uses Python for modeling
     Huang
    jjhuang                Python is a scripting language like MATLAB, but faster!
                           Python is free!
What is
Simulation and             Python is very easy to write and beautiful!
When to Use it?

What is
                       Process-oriented Discrete-Event Simulation Language
Discrete-Event             is easier to write model
Simulation?
                           provides proven event manager implementation
Example to
Illustrate World           lets you focus on algorithm code
Views

Introduction to
SimPy

SimPy Example

References
Introduction to SimPy

Introduction to
Discrete-Event
  Simulation
 Using SimPy

  Chun-Chieh           Uses Python for modeling
     Huang
    jjhuang                Python is a scripting language like MATLAB, but faster!
                           Python is free!
What is
Simulation and             Python is very easy to write and beautiful!
When to Use it?

What is
                       Process-oriented Discrete-Event Simulation Language
Discrete-Event             is easier to write model
Simulation?
                           provides proven event manager implementation
Example to
Illustrate World           lets you focus on algorithm code
Views

Introduction to
                       Uses coroutine to suspend/resume process
SimPy                      guarantees order of execution
SimPy Example              cannot run on parallel machine for a single simulation
References
SimPy Terminology: Classes

Introduction to
Discrete-Event
  Simulation
 Using SimPy

  Chun-Chieh
     Huang
    jjhuang
                       Process
What is                    simulates an entity which evolves in time, e.g.
Simulation and
When to Use it?            a clerk that serves customers
What is
                           refered to as thread in [6]
Discrete-Event
Simulation?

Example to
Illustrate World
Views

Introduction to
SimPy

SimPy Example

References
SimPy Terminology: Classes

Introduction to
Discrete-Event
  Simulation
 Using SimPy

  Chun-Chieh
     Huang
    jjhuang
                       Process
What is                    simulates an entity which evolves in time, e.g.
Simulation and
When to Use it?            a clerk that serves customers
What is
                           refered to as thread in [6]
Discrete-Event
Simulation?            Resource
Example to                 simulates something to be requested and
Illustrate World
Views                      queued if not available now
Introduction to
                           e.g. a wash machine
SimPy

SimPy Example

References
SimPy Terimnology: Functions

Introduction to
Discrete-Event
  Simulation          activate() used to mark a thread as runnable when it is first
 Using SimPy
                                 created
  Chun-Chieh
     Huang
    jjhuang


What is
Simulation and
When to Use it?

What is
Discrete-Event
Simulation?

Example to
Illustrate World
Views

Introduction to
SimPy

SimPy Example

References
SimPy Terimnology: Functions

Introduction to
Discrete-Event
  Simulation          activate() used to mark a thread as runnable when it is first
 Using SimPy
                                 created
  Chun-Chieh
     Huang
    jjhuang           simulate() starts the simulation

What is
Simulation and
When to Use it?

What is
Discrete-Event
Simulation?

Example to
Illustrate World
Views

Introduction to
SimPy

SimPy Example

References
SimPy Terimnology: Functions

Introduction to
Discrete-Event
  Simulation          activate() used to mark a thread as runnable when it is first
 Using SimPy
                                 created
  Chun-Chieh
     Huang
    jjhuang           simulate() starts the simulation

What is
                      yield hold put current thread into suspension for a certain
Simulation and
When to Use it?
                                 amount of time
What is
Discrete-Event
Simulation?

Example to
Illustrate World
Views

Introduction to
SimPy

SimPy Example

References
SimPy Terimnology: Functions

Introduction to
Discrete-Event
  Simulation          activate() used to mark a thread as runnable when it is first
 Using SimPy
                                 created
  Chun-Chieh
     Huang
    jjhuang           simulate() starts the simulation

What is
                      yield hold put current thread into suspension for a certain
Simulation and
When to Use it?
                                 amount of time
What is            yield passivate put current thread into suspension and
Discrete-Event
Simulation?                       wait until awakened by some other thread
Example to
Illustrate World
Views

Introduction to
SimPy

SimPy Example

References
SimPy Terimnology: Functions

Introduction to
Discrete-Event
  Simulation          activate() used to mark a thread as runnable when it is first
 Using SimPy
                                 created
  Chun-Chieh
     Huang
    jjhuang           simulate() starts the simulation

What is
                      yield hold put current thread into suspension for a certain
Simulation and
When to Use it?
                                 amount of time
What is            yield passivate put current thread into suspension and
Discrete-Event
Simulation?                       wait until awakened by some other thread
Example to
Illustrate World
                     reactivate() awakes a previously-passivated thread
Views

Introduction to
SimPy

SimPy Example

References
SimPy Terimnology: Functions

Introduction to
Discrete-Event
  Simulation          activate() used to mark a thread as runnable when it is first
 Using SimPy
                                 created
  Chun-Chieh
     Huang
    jjhuang           simulate() starts the simulation

What is
                      yield hold put current thread into suspension for a certain
Simulation and
When to Use it?
                                 amount of time
What is            yield passivate put current thread into suspension and
Discrete-Event
Simulation?                       wait until awakened by some other thread
Example to
Illustrate World
                     reactivate() awakes a previously-passivated thread
Views
                        cancel() cancels all the events associated with a
Introduction to
SimPy                            previously-passivated thread
SimPy Example

References
SimPy Terimnology: Functions

Introduction to
Discrete-Event
  Simulation           activate() used to mark a thread as runnable when it is first
 Using SimPy
                                  created
  Chun-Chieh
     Huang
    jjhuang           simulate() starts the simulation

What is
                       yield hold put current thread into suspension for a certain
Simulation and
When to Use it?
                                  amount of time
What is            yield passivate put current thread into suspension and
Discrete-Event
Simulation?                       wait until awakened by some other thread
Example to
Illustrate World
                     reactivate() awakes a previously-passivated thread
Views
                        cancel() cancels all the events associated with a
Introduction to
SimPy                            previously-passivated thread
SimPy Example
                    yield request requests for a given resource
References
                    yield release used to indicate that current thread no longer need
                                  the given resource
SimPy Example

Introduction to
Discrete-Event
  Simulation
 Using SimPy

  Chun-Chieh          Scenario
     Huang
    jjhuang                A post office with only one clerk.
                           Customer arrival is a poisson process,
What is
Simulation and             i.e. inter-arrival time is exponential distribution.
When to Use it?
                           Service time is also a poisson process.
What is
Discrete-Event             Classical M /M /1 problem in queueing theory
Simulation?
                      Process
Example to
Illustrate World           Arrival
Views
                           Clerk
Introduction to
SimPy                 Queue is managed by ourselves
SimPy Example             So that we can extend to M /M /m later, i.e. m clerks
References
Arrival Pseudo Code

Introduction to
Discrete-Event
  Simulation
 Using SimPy

  Chun-Chieh
     Huang
    jjhuang


What is
Simulation and         Arrival is an infinite loop of the following
When to Use it?
                            Calculate next arrival time
What is
Discrete-Event              Sleep until next arrival
Simulation?
                            Add customer into queue
Example to
Illustrate World
Views

Introduction to
SimPy

SimPy Example

References
Arrival Process

Introduction to
Discrete-Event
  Simulation
 Using SimPy

  Chun-Chieh
     Huang
                    1    class A r r i v a l C l a s s ( Process ) :
    jjhuang
                    2        " " " An a r r i v a l maintenance c l a s s " " "
                    3        ArrivalRate = 1/1.0                                              # r e c i p r o c a l o f mean i n t e r a r r i v a l t i m e
What is             4        def _ _ i n i t _ _ ( s e l f , name ) :
Simulation and      5               Process . _ _ i n i t _ _ ( s e l f )
When to Use it?     6               s e l f . name = name
                    7
What is             8         def Run ( s e l f ) :
Discrete-Event      9             while True :
Simulation?        10                   I n t e r A r r i v a l T i m e = G. Rnd . e x p o v a r i a t e ( A r r i v a l C l a s s . A r r i v a l R a t e )
                   11                   y i e l d hold , s e l f , I n t e r A r r i v a l T i m e
Example to
                   12                  C = Customer ( )
Illustrate World
                   13                   C l e r k C l a s s . Queue . append (C) # a customer a r r i v e s
Views
                   14                  G. NumCustomers += 1
Introduction to    15                   i f ClerkClass . I d l e != [ ] :                       # I s t h e r e any c l e r k i d l e ?
SimPy              16                           r e a c t i v a t e ( C l e r k C l a s s . I d l e [ 0 ] ) # Yes , wake him / her up

SimPy Example

References
Clerk Pseudo Code

Introduction to
Discrete-Event
  Simulation
 Using SimPy

  Chun-Chieh
     Huang
    jjhuang


What is
Simulation and         Clerk is an infinite loop of the following
When to Use it?
                            Sleep until waken up by customers
What is
Discrete-Event              Serve the customer on waken up
Simulation?
                            until there is no customer in line
Example to
Illustrate World
Views

Introduction to
SimPy

SimPy Example

References
Clerk Process

Introduction to
Discrete-Event      1    class C l e r k C l a s s ( Process ) :
  Simulation        2        " " " A s e r v e r process , o r c l e r k i n t h e p o s t o f f i c e " " "
 Using SimPy        3        ServiceRate = 1 / 1 . 2                                           # r e c i p r o c a l o f mean s e r v i c e t i m e
                    4        MaxQueueLength = 0
  Chun-Chieh        5        Queue = [ ]                                                       # customer queue
     Huang          6        Idle = [ ]                                                        # idle clerk l i s t
    jjhuang         7        Busy = [ ]                                                        # busy c l e r k l i s t
                    8        NumDone = 0                                                       # No . o f customers being s e r v i c e d
What is             9        def _ _ i n i t _ _ ( s e l f ) :
Simulation and     10               Process . _ _ i n i t _ _ ( s e l f )
When to Use it?    11               C l e r k C l a s s . I d l e . append ( s e l f )         # I n i t i a l l y idle
                   12        def Run ( s e l f ) :
What is            13               while True :
Discrete-Event     14                       y i e l d passivate , s e l f                      # w a i t u n t i l awaken by customers
Simulation?        15                       C l e r k C l a s s . I d l e . remove ( s e l f )
                   16                       C l e r k C l a s s . Busy . append ( s e l f ) # going t o be busy
Example to         17                       while C l e r k C l a s s . Queue ! = [ ] :
Illustrate World   18                                i f l e n ( C l e r k C l a s s . Queue ) > C l e r k C l a s s . MaxQueueLength :
Views              19                                       C l e r k C l a s s . MaxQueueLength = l e n ( C l e r k C l a s s . Queue )
                   20                               C = C l e r k C l a s s . Queue . pop ( ) # c a l l n e x t customer i n l i n e
Introduction to
                   21                               # S t a r t s e r v i c e t h e customer
SimPy
                   22                               ServiceTime = G. Rnd . e x p o v a r i a t e ( C l e r k C l a s s . ServiceRate )
SimPy Example      23                               y i e l d hold , s e l f , ServiceTime # s t a r t t o serve
                   24                               C . endService ( )                              # end o f s e r v i c e
References         25                               G. T o t a l W a i t i n g T i m e += now ( ) − C . A r r i v a l T i m e
                   26                               C l e r k C l a s s . NumDone += 1
                   27                               del C                                      # customer i s gone
                   28                       C l e r k C l a s s . Busy . remove ( s e l f )
                   29                       C l e r k C l a s s . I d l e . append ( s e l f )
Simulation Main Loop

Introduction to
Discrete-Event
  Simulation
 Using SimPy

  Chun-Chieh
     Huang          1    i f DEBUG:
    jjhuang         2         from SimPy . S i m u l a t i o n T r a c e import ∗
                    3    else :
What is             4         from SimPy . S i m u l a t i o n import ∗
Simulation and      5
When to Use it?     6   def main ( ) :
                    7       initialize ()                                             # I n i t i a l i z e s simulator
What is             8       A = A r r i v a l C l a s s ( name= " A r r i v a l " )
Discrete-Event      9       a c t i v a t e ( A , A . Run ( ) )                       # Activate a r r i v a l
Simulation?        10
                   11         S = C l e r k C l a s s ( name= " C l e r k " )
Example to         12         a c t i v a t e ( S , S . Run ( ) )                     # Activate clerk
Illustrate World   13
Views              14         s i m u l a t e ( u n t i l =MaxSimTime )               # S t a r t to simulate !
                   15
Introduction to    16    i f __name__ == ’ __main__ ’ :
SimPy              17         main ( )
SimPy Example

References
Concluding Remarks

Introduction to
Discrete-Event
  Simulation
 Using SimPy

  Chun-Chieh
     Huang
    jjhuang


What is                Simulation is a powerful tool to study physical problems at
Simulation and
When to Use it?        cheaper cost.
What is
Discrete-Event
                       SimPy provides process-oriendted DES framework
Simulation?            to write simulation easily and reasonably fast.
Example to
Illustrate World       And SimPy is free!
Views

Introduction to
SimPy

SimPy Example

References
References

Introduction to
Discrete-Event
  Simulation
 Using SimPy       [1] R. E. Nance, “A history of discrete event simulation
  Chun-Chieh           programming languages,” in The second ACM SIGPLAN
     Huang
    jjhuang            conference on History of programming languages, ser.
                       HOPL-II. New York, NY, USA: ACM, 1993, pp. 149–175.
What is
Simulation and         [Online]. Available: http://doi.acm.org/10.1145/154766.155368
When to Use it?

What is            [2] J. Banks, J. S. Carson, B. L. Nelson, and D. M. Nicol,
Discrete-Event
Simulation?            Discrete-Event System Simulation (5th Edition). Prentice
Example to             Hall, 2009.
Illustrate World
Views              [3] C++SIM and JavaSim, “http://javasim.codehaus.org/.”
Introduction to
SimPy              [4] S. S. Package, “http://simpy.sourceforge.net/.”
SimPy Example
                   [5] ns-3 Network Simulator, “http://www.nsnam.org/.”
References
                   [6] N. Matloff, “A discrete-event simulation course based on the
                       simpy language,” Davis, 2006.
Introduction to
Discrete-Event
  Simulation
 Using SimPy

  Chun-Chieh
     Huang
    jjhuang


What is
Simulation and
When to Use it?

What is
Discrete-Event
Simulation?
                   Q&A
Example to
Illustrate World
Views

Introduction to
SimPy

SimPy Example

References

More Related Content

What's hot (20)

Presentation on Solution to non linear equations
Presentation on Solution to non linear equationsPresentation on Solution to non linear equations
Presentation on Solution to non linear equations
 
The Jacobi and Gauss-Seidel Iterative Methods.pdf
The Jacobi and Gauss-Seidel Iterative Methods.pdfThe Jacobi and Gauss-Seidel Iterative Methods.pdf
The Jacobi and Gauss-Seidel Iterative Methods.pdf
 
Diagonalization of matrix
Diagonalization of matrixDiagonalization of matrix
Diagonalization of matrix
 
Cayley – hamiltion theorem By Sunny
Cayley – hamiltion theorem By SunnyCayley – hamiltion theorem By Sunny
Cayley – hamiltion theorem By Sunny
 
system of linear equations by Diler
system of linear equations by Dilersystem of linear equations by Diler
system of linear equations by Diler
 
Sets
SetsSets
Sets
 
Taylor and Maclaurin Series
Taylor and Maclaurin SeriesTaylor and Maclaurin Series
Taylor and Maclaurin Series
 
Integral Domains
Integral DomainsIntegral Domains
Integral Domains
 
Double integral
Double integralDouble integral
Double integral
 
Linear Algebra
Linear AlgebraLinear Algebra
Linear Algebra
 
Partial differentiation B tech
Partial differentiation B techPartial differentiation B tech
Partial differentiation B tech
 
Matrices
MatricesMatrices
Matrices
 
Lagrange's method
Lagrange's methodLagrange's method
Lagrange's method
 
Big m method
Big   m methodBig   m method
Big m method
 
Lesson 15: Exponential Growth and Decay (Section 021 slides)
Lesson 15: Exponential Growth and Decay (Section 021 slides)Lesson 15: Exponential Growth and Decay (Section 021 slides)
Lesson 15: Exponential Growth and Decay (Section 021 slides)
 
Matrices ppt
Matrices pptMatrices ppt
Matrices ppt
 
Group Ring.ppt
Group Ring.pptGroup Ring.ppt
Group Ring.ppt
 
Opearion on Fuzzy sets with Example
Opearion on Fuzzy sets with ExampleOpearion on Fuzzy sets with Example
Opearion on Fuzzy sets with Example
 
Higher order differential equations
Higher order differential equationsHigher order differential equations
Higher order differential equations
 
Matrix Algebra seminar ppt
Matrix Algebra seminar pptMatrix Algebra seminar ppt
Matrix Algebra seminar ppt
 

Viewers also liked

Chapter3 general principles of discrete event simulation
Chapter3   general principles of discrete event simulationChapter3   general principles of discrete event simulation
Chapter3 general principles of discrete event simulationDe La Salle University-Manila
 
S6 l04 analytical and numerical methods of structural analysis
S6 l04 analytical and numerical methods of structural analysisS6 l04 analytical and numerical methods of structural analysis
S6 l04 analytical and numerical methods of structural analysisShaikh Mohsin
 
Unit 5 general principles, simulation software
Unit 5 general principles, simulation softwareUnit 5 general principles, simulation software
Unit 5 general principles, simulation softwareraksharao
 
Simulation and Modeling
Simulation and ModelingSimulation and Modeling
Simulation and Modelinganhdbh
 
Simulation Techniques
Simulation TechniquesSimulation Techniques
Simulation Techniquesmailrenuka
 
Atm simulation program using python
Atm simulation program using pythonAtm simulation program using python
Atm simulation program using pythonHappy Nezza Aranjuez
 
ETOS discrete event simulation framework focused on easier team cooperation
ETOS discrete event simulation framework focused on easier team cooperationETOS discrete event simulation framework focused on easier team cooperation
ETOS discrete event simulation framework focused on easier team cooperationJiriFiser
 
Histopathology of alopecia
Histopathology of alopeciaHistopathology of alopecia
Histopathology of alopeciaMohammad Manzoor
 
Operating Systems - Queuing Systems
Operating Systems - Queuing SystemsOperating Systems - Queuing Systems
Operating Systems - Queuing SystemsEmery Berger
 

Viewers also liked (20)

Chapter3 general principles of discrete event simulation
Chapter3   general principles of discrete event simulationChapter3   general principles of discrete event simulation
Chapter3 general principles of discrete event simulation
 
Simulation
SimulationSimulation
Simulation
 
S6 l04 analytical and numerical methods of structural analysis
S6 l04 analytical and numerical methods of structural analysisS6 l04 analytical and numerical methods of structural analysis
S6 l04 analytical and numerical methods of structural analysis
 
Unit 5 general principles, simulation software
Unit 5 general principles, simulation softwareUnit 5 general principles, simulation software
Unit 5 general principles, simulation software
 
Simulation
SimulationSimulation
Simulation
 
Simulation and Modeling
Simulation and ModelingSimulation and Modeling
Simulation and Modeling
 
Simulation Techniques
Simulation TechniquesSimulation Techniques
Simulation Techniques
 
Simulation Powerpoint- Lecture Notes
Simulation Powerpoint- Lecture NotesSimulation Powerpoint- Lecture Notes
Simulation Powerpoint- Lecture Notes
 
Atm simulation program using python
Atm simulation program using pythonAtm simulation program using python
Atm simulation program using python
 
ETOS discrete event simulation framework focused on easier team cooperation
ETOS discrete event simulation framework focused on easier team cooperationETOS discrete event simulation framework focused on easier team cooperation
ETOS discrete event simulation framework focused on easier team cooperation
 
Alopecia
AlopeciaAlopecia
Alopecia
 
Alopecia
AlopeciaAlopecia
Alopecia
 
Histopathology of alopecia
Histopathology of alopeciaHistopathology of alopecia
Histopathology of alopecia
 
Androgenetic alopecia
Androgenetic alopecia Androgenetic alopecia
Androgenetic alopecia
 
Queuing analysis
Queuing analysisQueuing analysis
Queuing analysis
 
Guide to Queuing System
Guide to Queuing SystemGuide to Queuing System
Guide to Queuing System
 
Operating Systems - Queuing Systems
Operating Systems - Queuing SystemsOperating Systems - Queuing Systems
Operating Systems - Queuing Systems
 
14 queuing
14 queuing14 queuing
14 queuing
 
Chapter1
Chapter1Chapter1
Chapter1
 
Female hair loss
Female hair lossFemale hair loss
Female hair loss
 

Similar to Introduction to Discrete-Event Simulation Using SimPy

What is sim?ulation
What is sim?ulationWhat is sim?ulation
What is sim?ulationMusab Cannon
 
Strategy for Social Media MK Plan by Slidesgo.pptx
Strategy for Social Media MK Plan by Slidesgo.pptxStrategy for Social Media MK Plan by Slidesgo.pptx
Strategy for Social Media MK Plan by Slidesgo.pptxjshwyi
 
Simulation theory
Simulation theorySimulation theory
Simulation theoryAbu Bashar
 
Unleashing Real-World Simulations: A Python Tutorial by Avjinder Kaler
Unleashing Real-World Simulations: A Python Tutorial by Avjinder KalerUnleashing Real-World Simulations: A Python Tutorial by Avjinder Kaler
Unleashing Real-World Simulations: A Python Tutorial by Avjinder KalerAvjinder (Avi) Kaler
 
Cs854 lecturenotes01
Cs854 lecturenotes01Cs854 lecturenotes01
Cs854 lecturenotes01Mehmet Çelik
 
Advantages and disadvantages of Simulation
Advantages and disadvantages of SimulationAdvantages and disadvantages of Simulation
Advantages and disadvantages of SimulationTilakpoudel2
 
O2DESUltra - a new appoach to acceleration simulation-opimization using machi...
O2DESUltra - a new appoach to acceleration simulation-opimization using machi...O2DESUltra - a new appoach to acceleration simulation-opimization using machi...
O2DESUltra - a new appoach to acceleration simulation-opimization using machi...Nutchanon Ninyawee
 
Basics of modeling and simulation
Basics of modeling and simulationBasics of modeling and simulation
Basics of modeling and simulationSerdar Kaya
 
Introduction to simulation and modeling
Introduction to simulation and modelingIntroduction to simulation and modeling
Introduction to simulation and modelingantim19
 
Velocity 2015: Building Self-Healing Systems
Velocity 2015: Building Self-Healing SystemsVelocity 2015: Building Self-Healing Systems
Velocity 2015: Building Self-Healing SystemsSOASTA
 
Velocity 2015 building self healing systems (slide share version)
Velocity 2015 building self healing systems (slide share version)Velocity 2015 building self healing systems (slide share version)
Velocity 2015 building self healing systems (slide share version)SOASTA
 
Simulation and modeling
Simulation and modelingSimulation and modeling
Simulation and modelingmegersaoljira
 
SLAM Zero to One
SLAM Zero to OneSLAM Zero to One
SLAM Zero to OneGavin Gao
 
4_5821003798000177081.pdf
4_5821003798000177081.pdf4_5821003798000177081.pdf
4_5821003798000177081.pdfozgenn4242
 
Manual del modulo Sympy
Manual del modulo SympyManual del modulo Sympy
Manual del modulo SympyAngieB
 
Manual Simpy
Manual SimpyManual Simpy
Manual SimpyAngieB
 
Assignment 1 - Application of Simulation Software.pdf
Assignment 1 - Application of Simulation Software.pdfAssignment 1 - Application of Simulation Software.pdf
Assignment 1 - Application of Simulation Software.pdfSafeen Yaseen Ja'far
 

Similar to Introduction to Discrete-Event Simulation Using SimPy (20)

What is sim?ulation
What is sim?ulationWhat is sim?ulation
What is sim?ulation
 
Strategy for Social Media MK Plan by Slidesgo.pptx
Strategy for Social Media MK Plan by Slidesgo.pptxStrategy for Social Media MK Plan by Slidesgo.pptx
Strategy for Social Media MK Plan by Slidesgo.pptx
 
Simulation theory
Simulation theorySimulation theory
Simulation theory
 
Unleashing Real-World Simulations: A Python Tutorial by Avjinder Kaler
Unleashing Real-World Simulations: A Python Tutorial by Avjinder KalerUnleashing Real-World Simulations: A Python Tutorial by Avjinder Kaler
Unleashing Real-World Simulations: A Python Tutorial by Avjinder Kaler
 
Cs854 lecturenotes01
Cs854 lecturenotes01Cs854 lecturenotes01
Cs854 lecturenotes01
 
Simulator
SimulatorSimulator
Simulator
 
cs1538.ppt
cs1538.pptcs1538.ppt
cs1538.ppt
 
Advantages and disadvantages of Simulation
Advantages and disadvantages of SimulationAdvantages and disadvantages of Simulation
Advantages and disadvantages of Simulation
 
O2DESUltra - a new appoach to acceleration simulation-opimization using machi...
O2DESUltra - a new appoach to acceleration simulation-opimization using machi...O2DESUltra - a new appoach to acceleration simulation-opimization using machi...
O2DESUltra - a new appoach to acceleration simulation-opimization using machi...
 
Basics of modeling and simulation
Basics of modeling and simulationBasics of modeling and simulation
Basics of modeling and simulation
 
Introduction to simulation and modeling
Introduction to simulation and modelingIntroduction to simulation and modeling
Introduction to simulation and modeling
 
Velocity 2015: Building Self-Healing Systems
Velocity 2015: Building Self-Healing SystemsVelocity 2015: Building Self-Healing Systems
Velocity 2015: Building Self-Healing Systems
 
Velocity 2015 building self healing systems (slide share version)
Velocity 2015 building self healing systems (slide share version)Velocity 2015 building self healing systems (slide share version)
Velocity 2015 building self healing systems (slide share version)
 
Simulation and modeling
Simulation and modelingSimulation and modeling
Simulation and modeling
 
SLAM Zero to One
SLAM Zero to OneSLAM Zero to One
SLAM Zero to One
 
SIMULATION
SIMULATIONSIMULATION
SIMULATION
 
4_5821003798000177081.pdf
4_5821003798000177081.pdf4_5821003798000177081.pdf
4_5821003798000177081.pdf
 
Manual del modulo Sympy
Manual del modulo SympyManual del modulo Sympy
Manual del modulo Sympy
 
Manual Simpy
Manual SimpyManual Simpy
Manual Simpy
 
Assignment 1 - Application of Simulation Software.pdf
Assignment 1 - Application of Simulation Software.pdfAssignment 1 - Application of Simulation Software.pdf
Assignment 1 - Application of Simulation Software.pdf
 

More from pycontw

Network Security and Analysis with Python
Network Security and Analysis with PythonNetwork Security and Analysis with Python
Network Security and Analysis with Pythonpycontw
 
Python on FreeBSD
Python on FreeBSDPython on FreeBSD
Python on FreeBSDpycontw
 
讓 Python Script 擁有圖形化介面的簡單方法
讓 Python Script 擁有圖形化介面的簡單方法讓 Python Script 擁有圖形化介面的簡單方法
讓 Python Script 擁有圖形化介面的簡單方法pycontw
 
CyberLink Meets Python
CyberLink Meets PythonCyberLink Meets Python
CyberLink Meets Pythonpycontw
 
PyKinect: Body Iteration Application Development Using Python
PyKinect: Body Iteration Application Development Using PythonPyKinect: Body Iteration Application Development Using Python
PyKinect: Body Iteration Application Development Using Pythonpycontw
 
Developing Python Apps on Windows Azure
Developing Python Apps on Windows AzureDeveloping Python Apps on Windows Azure
Developing Python Apps on Windows Azurepycontw
 
Qt Quick GUI Programming with PySide
Qt Quick GUI Programming with PySideQt Quick GUI Programming with PySide
Qt Quick GUI Programming with PySidepycontw
 
STAF 在自動化測試上的延伸應用 -- TMSTAF (TrendMicro STAF)
STAF 在自動化測試上的延伸應用 -- TMSTAF (TrendMicro STAF)STAF 在自動化測試上的延伸應用 -- TMSTAF (TrendMicro STAF)
STAF 在自動化測試上的延伸應用 -- TMSTAF (TrendMicro STAF)pycontw
 
Grid Job Management
Grid Job ManagementGrid Job Management
Grid Job Managementpycontw
 
Small Python Tools for Software Release Engineering
Small Python Tools for Software Release EngineeringSmall Python Tools for Software Release Engineering
Small Python Tools for Software Release Engineeringpycontw
 
Python and Startup
Python and StartupPython and Startup
Python and Startuppycontw
 
Panoramic Video in Environmental Monitoring Software Development and Applica...
Panoramic Video in Environmental Monitoring Software Development and Applica...Panoramic Video in Environmental Monitoring Software Development and Applica...
Panoramic Video in Environmental Monitoring Software Development and Applica...pycontw
 
那些年 Python 攻佔了 GIS / The Year Python Takes Over GIS
那些年 Python 攻佔了 GIS / The Year Python Takes Over GIS那些年 Python 攻佔了 GIS / The Year Python Takes Over GIS
那些年 Python 攻佔了 GIS / The Year Python Takes Over GISpycontw
 
Python and the Web
Python and the WebPython and the Web
Python and the Webpycontw
 
Large-scale Array-oriented Computing with Python
Large-scale Array-oriented Computing with PythonLarge-scale Array-oriented Computing with Python
Large-scale Array-oriented Computing with Pythonpycontw
 

More from pycontw (15)

Network Security and Analysis with Python
Network Security and Analysis with PythonNetwork Security and Analysis with Python
Network Security and Analysis with Python
 
Python on FreeBSD
Python on FreeBSDPython on FreeBSD
Python on FreeBSD
 
讓 Python Script 擁有圖形化介面的簡單方法
讓 Python Script 擁有圖形化介面的簡單方法讓 Python Script 擁有圖形化介面的簡單方法
讓 Python Script 擁有圖形化介面的簡單方法
 
CyberLink Meets Python
CyberLink Meets PythonCyberLink Meets Python
CyberLink Meets Python
 
PyKinect: Body Iteration Application Development Using Python
PyKinect: Body Iteration Application Development Using PythonPyKinect: Body Iteration Application Development Using Python
PyKinect: Body Iteration Application Development Using Python
 
Developing Python Apps on Windows Azure
Developing Python Apps on Windows AzureDeveloping Python Apps on Windows Azure
Developing Python Apps on Windows Azure
 
Qt Quick GUI Programming with PySide
Qt Quick GUI Programming with PySideQt Quick GUI Programming with PySide
Qt Quick GUI Programming with PySide
 
STAF 在自動化測試上的延伸應用 -- TMSTAF (TrendMicro STAF)
STAF 在自動化測試上的延伸應用 -- TMSTAF (TrendMicro STAF)STAF 在自動化測試上的延伸應用 -- TMSTAF (TrendMicro STAF)
STAF 在自動化測試上的延伸應用 -- TMSTAF (TrendMicro STAF)
 
Grid Job Management
Grid Job ManagementGrid Job Management
Grid Job Management
 
Small Python Tools for Software Release Engineering
Small Python Tools for Software Release EngineeringSmall Python Tools for Software Release Engineering
Small Python Tools for Software Release Engineering
 
Python and Startup
Python and StartupPython and Startup
Python and Startup
 
Panoramic Video in Environmental Monitoring Software Development and Applica...
Panoramic Video in Environmental Monitoring Software Development and Applica...Panoramic Video in Environmental Monitoring Software Development and Applica...
Panoramic Video in Environmental Monitoring Software Development and Applica...
 
那些年 Python 攻佔了 GIS / The Year Python Takes Over GIS
那些年 Python 攻佔了 GIS / The Year Python Takes Over GIS那些年 Python 攻佔了 GIS / The Year Python Takes Over GIS
那些年 Python 攻佔了 GIS / The Year Python Takes Over GIS
 
Python and the Web
Python and the WebPython and the Web
Python and the Web
 
Large-scale Array-oriented Computing with Python
Large-scale Array-oriented Computing with PythonLarge-scale Array-oriented Computing with Python
Large-scale Array-oriented Computing with Python
 

Recently uploaded

2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 

Recently uploaded (20)

2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 

Introduction to Discrete-Event Simulation Using SimPy

  • 1. Introduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang Introduction to Discrete-Event Simulation jjhuang Using SimPy What is Simulation and When to Use it? What is Discrete-Event Chun-Chieh Huang Simulation? jjhuang Example to Illustrate World Views DSP and Algorithm Design Department Introduction to Metanoia Communications Inc. SimPy <jiunjie.huang@gmail.com> SimPy Example References June 9, 2012
  • 2. Outline Introduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang 1 What is Simulation and When to Use it? jjhuang What is Simulation and 2 What is Discrete-Event Simulation? When to Use it? What is Discrete-Event 3 Example to Illustrate World Views Simulation? Example to Illustrate World Views 4 Introduction to SimPy Introduction to SimPy SimPy Example 5 SimPy Example References
  • 3. What is Simulation and When to Use it? Introduction to Discrete-Event Simulation Using SimPy Simulation Chun-Chieh a computer program that creates a virtual environment Huang jjhuang in order to study physical problems What is Simulation and When to Use it? What is Discrete-Event Simulation? Example to Illustrate World Views Introduction to SimPy SimPy Example References
  • 4. What is Simulation and When to Use it? Introduction to Discrete-Event Simulation Using SimPy Simulation Chun-Chieh a computer program that creates a virtual environment Huang jjhuang in order to study physical problems What is When to use simulation Simulation and When to Use it? hard to do real experiment, e.g. battle field, or banking system What is Discrete-Event Simulation? Example to Illustrate World Views Introduction to SimPy SimPy Example References
  • 5. What is Simulation and When to Use it? Introduction to Discrete-Event Simulation Using SimPy Simulation Chun-Chieh a computer program that creates a virtual environment Huang jjhuang in order to study physical problems What is When to use simulation Simulation and When to Use it? hard to do real experiment, e.g. battle field, or banking system What is Discrete-Event cheaper to do simulation, Simulation? e.g. RTL simulation for IC design, Example to Illustrate World or highway/freeway route planning Views Introduction to SimPy SimPy Example References
  • 6. What is Simulation and When to Use it? Introduction to Discrete-Event Simulation Using SimPy Simulation Chun-Chieh a computer program that creates a virtual environment Huang jjhuang in order to study physical problems What is When to use simulation Simulation and When to Use it? hard to do real experiment, e.g. battle field, or banking system What is Discrete-Event cheaper to do simulation, Simulation? e.g. RTL simulation for IC design, Example to Illustrate World or highway/freeway route planning Views analyzing bottleneck of current workflow Introduction to SimPy SimPy Example References
  • 7. What is Simulation and When to Use it? Introduction to Discrete-Event Simulation Using SimPy Simulation Chun-Chieh a computer program that creates a virtual environment Huang jjhuang in order to study physical problems What is When to use simulation Simulation and When to Use it? hard to do real experiment, e.g. battle field, or banking system What is Discrete-Event cheaper to do simulation, Simulation? e.g. RTL simulation for IC design, Example to Illustrate World or highway/freeway route planning Views analyzing bottleneck of current workflow Introduction to SimPy When not to use simulation SimPy Example more expensive to do simulation, References e.g. simple harmonic motion
  • 8. What is Simulation and When to Use it? Introduction to Discrete-Event Simulation Using SimPy Simulation Chun-Chieh a computer program that creates a virtual environment Huang jjhuang in order to study physical problems What is When to use simulation Simulation and When to Use it? hard to do real experiment, e.g. battle field, or banking system What is Discrete-Event cheaper to do simulation, Simulation? e.g. RTL simulation for IC design, Example to Illustrate World or highway/freeway route planning Views analyzing bottleneck of current workflow Introduction to SimPy When not to use simulation SimPy Example more expensive to do simulation, References e.g. simple harmonic motion problems that can be analyzed by pencil and paper
  • 9. Categories of Simulation Introduction to Discrete-Event Simulation Using SimPy Chun-Chieh Continuous or discrete Huang jjhuang state variable is continuous, e.g. weather systems state variable is discrete, e.g. number of customers What is Simulation and When to Use it? What is Discrete-Event Simulation? Example to Illustrate World Views Introduction to SimPy SimPy Example References
  • 10. Categories of Simulation Introduction to Discrete-Event Simulation Using SimPy Chun-Chieh Continuous or discrete Huang jjhuang state variable is continuous, e.g. weather systems state variable is discrete, e.g. number of customers What is Simulation and Static or dynamic When to Use it? Static: represents a system at a particular point of time What is Discrete-Event representation of time is unnecessary [1] Simulation? sometimes called Monte-Carlo simulation [2] Example to Dynamic: represents systems as they change over time Illustrate World Views e.g. banking system from 9:00 AM to 5:00 PM Introduction to SimPy SimPy Example References
  • 11. Categories of Simulation Introduction to Discrete-Event Simulation Using SimPy Chun-Chieh Continuous or discrete Huang jjhuang state variable is continuous, e.g. weather systems state variable is discrete, e.g. number of customers What is Simulation and Static or dynamic When to Use it? Static: represents a system at a particular point of time What is Discrete-Event representation of time is unnecessary [1] Simulation? sometimes called Monte-Carlo simulation [2] Example to Dynamic: represents systems as they change over time Illustrate World Views e.g. banking system from 9:00 AM to 5:00 PM Introduction to SimPy Deterministic or stochastic SimPy Example Deterministic: contains no random variable References Stochastic: has one or more random variables
  • 12. What is Discrete-Event Simulation? Introduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang jjhuang Discrete-Event Simulation is Discrete What is Simulation and Dynamic When to Use it? Stochastic What is Discrete-Event Simulation for queueing in a post office is DES Simulation? Example to Mostly, but not limited to, queueing systems Illustrate World Views factory work flow Introduction to freeway traffic simulation SimPy network traffic simulation SimPy Example References
  • 13. Discrete-Event Simulation World Views Introduction to Discrete-Event Simulation Using SimPy Chun-Chieh Activity-oriented Huang jjhuang fixed increment of time time-consuming What is Simulation and When to Use it? What is Discrete-Event Simulation? Example to Illustrate World Views Introduction to SimPy SimPy Example References
  • 14. Discrete-Event Simulation World Views Introduction to Discrete-Event Simulation Using SimPy Chun-Chieh Activity-oriented Huang jjhuang fixed increment of time time-consuming What is Simulation and Event-oriented When to Use it? on each event, generate next event and What is Discrete-Event put into event queue and sort Simulation? simulation time advances to next closest event Example to faster than activity-oriented Illustrate World Views Introduction to SimPy SimPy Example References
  • 15. Discrete-Event Simulation World Views Introduction to Discrete-Event Simulation Using SimPy Chun-Chieh Activity-oriented Huang jjhuang fixed increment of time time-consuming What is Simulation and Event-oriented When to Use it? on each event, generate next event and What is Discrete-Event put into event queue and sort Simulation? simulation time advances to next closest event Example to faster than activity-oriented Illustrate World Views Process-oriented Introduction to SimPy abstract one object into a process SimPy Example easier to maintain in the end References
  • 16. Discrete-Event Simulation World Views Introduction to Discrete-Event Simulation Using SimPy Chun-Chieh Activity-oriented Huang jjhuang fixed increment of time time-consuming What is Simulation and Event-oriented When to Use it? on each event, generate next event and What is Discrete-Event put into event queue and sort Simulation? simulation time advances to next closest event Example to faster than activity-oriented Illustrate World Views Process-oriented Introduction to SimPy abstract one object into a process SimPy Example easier to maintain in the end References SimPy belongs here!
  • 17. Example to Illustrate World Views Introduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang jjhuang What is Simulation and Simulating a post office with only one clerk When to Use it? Customers come in at random time What is Discrete-Event and wait if the clerk is already serving Simulation? Example to Clerk serves each customer for a random period of time Illustrate World Views Introduction to SimPy SimPy Example References
  • 18. Discrete-Event Simulation World Views Introduction to Discrete-Event Simulation Using SimPy Chun-Chieh Activity-oriented Huang jjhuang fixed increment of time What is time-consuming Simulation and When to Use it? Event-oriented What is on each event, generate next event and Discrete-Event Simulation? put into event queue and sort Example to simulation time advances to next closest event Illustrate World faster than activity-oriented Views Introduction to Process-oriented SimPy abstract one object into a process SimPy Example easier to maintain in the end References
  • 19. Activity-Oriented Discrete-Event Simulation Introduction to Discrete-Event Simulation 6 Using SimPy Chun-Chieh Huang 5 jjhuang What is 4 Simulation and When to Use it? Simulation starts at 2.0! What is Discrete-Event 3 Simulation? Gen 1st arr at 2.6 Example to Illustrate World 2 Views Check events: 1st arr at 2.6, no action Introduction to SimPy 1 SimPy Example References 0 0 1 2 3 4 5 6 7 8 9
  • 20. Activity-Oriented Discrete-Event Simulation Introduction to Discrete-Event Simulation 6 Using SimPy Chun-Chieh Huang 5 jjhuang What is Simulation and 4 When to Use it? What is Discrete-Event 3 Simulation? Example to Illustrate World 2 Views Check events: 1st arr at 2.6, no action Introduction to SimPy 1 SimPy Example References 0 0 1 2 3 4 5 6 7 8 9
  • 21. Activity-Oriented Discrete-Event Simulation Introduction to Discrete-Event Simulation 6 Using SimPy Chun-Chieh Huang 5 jjhuang What is Simulation and 4 When to Use it? What is Discrete-Event 3 Simulation? Example to Illustrate World 2 Views Check events: 1st arr at 2.6, no action Introduction to SimPy 1 SimPy Example References 0 0 1 2 3 4 5 6 7 8 9
  • 22. Activity-Oriented Discrete-Event Simulation Introduction to Discrete-Event Simulation 6 Using SimPy Chun-Chieh Huang 5 jjhuang What is Simulation and 4 When to Use it? What is Discrete-Event 3 Simulation? Example to Illustrate World 2 Views Check events: 1st arr at 2.6, no action Introduction to SimPy 1 SimPy Example References 0 0 1 2 3 4 5 6 7 8 9
  • 23. Activity-Oriented Discrete-Event Simulation Introduction to Discrete-Event Simulation 6 Using SimPy Chun-Chieh Huang 5 jjhuang What is Simulation and 4 When to Use it? What is Discrete-Event 3 Simulation? Example to Illustrate World 2 Views Check events: 1st arr at 2.6, no action Introduction to SimPy 1 SimPy Example References 0 0 1 2 3 4 5 6 7 8 9
  • 24. Activity-Oriented Discrete-Event Simulation Introduction to Discrete-Event Simulation 6 Using SimPy Chun-Chieh Huang 5 jjhuang What is Simulation and 4 When to Use it? What is Discrete-Event 3 Simulation? Example to Illustrate World 2 Views Check events: 1st arr at 2.6, no action Introduction to SimPy 1 SimPy Example References 0 0 1 2 3 4 5 6 7 8 9
  • 25. Activity-Oriented Discrete-Event Simulation Introduction to Discrete-Event Simulation 6 Using SimPy Chun-Chieh Huang 5 jjhuang What is Simulation and 4 When to Use it? What is Discrete-Event 3 Simulation? Example to Illustrate World 2 Views Check events: 1st arr at 2.6, process now Introduction to SimPy 1 SimPy Example References 0 0 1 2 3 4 5 6 7 8 9
  • 26. Activity-Oriented Discrete-Event Simulation Introduction to Discrete-Event Simulation 6 Using SimPy Chun-Chieh Huang 5 jjhuang What is 4 Simulation and When to Use it? First arrival! What is Discrete-Event 3 Simulation? Example to Illustrate World 2 Views Introduction to SimPy 1 SimPy Example References 0 0 1 2 3 4 5 6 7 8 9
  • 27. Activity-Oriented Discrete-Event Simulation Introduction to Discrete-Event Simulation 6 Using SimPy Chun-Chieh Huang 5 jjhuang Calculate service time, end at 4.0 What is 4 Simulation and When to Use it? Calculate next arrival at 3.5 What is Discrete-Event 3 Simulation? Example to Illustrate World 2 Views Introduction to SimPy 1 SimPy Example References 0 0 1 2 3 4 5 6 7 8 9
  • 28. Activity-Oriented Discrete-Event Simulation Introduction to Discrete-Event Simulation 6 Using SimPy Chun-Chieh Huang 5 jjhuang What is Simulation and 4 When to Use it? What is Discrete-Event 3 Simulation? Example to Illustrate World 2 Views Check events: 2nd arrival at 3.5, no action Introduction to SimPy 1 SimPy Example References 0 0 1 2 3 4 5 6 7 8 9
  • 29. Activity-Oriented Discrete-Event Simulation Introduction to Discrete-Event Simulation 6 Using SimPy Chun-Chieh Huang 5 jjhuang What is Simulation and 4 When to Use it? What is Discrete-Event 3 Simulation? Example to Illustrate World 2 Views Check events: 2nd arrival at 3.5, no action Introduction to SimPy 1 SimPy Example References 0 0 1 2 3 4 5 6 7 8 9
  • 30. Activity-Oriented Discrete-Event Simulation Introduction to Discrete-Event Simulation 6 Using SimPy Chun-Chieh Huang 5 jjhuang What is Simulation and 4 When to Use it? What is Discrete-Event 3 Simulation? Example to Illustrate World 2 Views Check events: 2nd arrival at 3.5, no action Introduction to SimPy 1 SimPy Example References 0 0 1 2 3 4 5 6 7 8 9
  • 31. Activity-Oriented Discrete-Event Simulation Introduction to Discrete-Event Simulation 6 Using SimPy Chun-Chieh Huang 5 jjhuang What is Simulation and 4 When to Use it? What is Discrete-Event 3 Simulation? Example to Illustrate World 2 Views Check events: 2nd arrival at 3.5, no action Introduction to SimPy 1 SimPy Example References 0 0 1 2 3 4 5 6 7 8 9
  • 32. Activity-Oriented Discrete-Event Simulation Introduction to Discrete-Event Simulation 6 Using SimPy Chun-Chieh Huang 5 jjhuang What is Simulation and 4 When to Use it? What is Discrete-Event 3 Simulation? Example to Illustrate World 2 Views Check events: 2nd arrival at 3.5, no action Introduction to SimPy 1 SimPy Example References 0 0 1 2 3 4 5 6 7 8 9
  • 33. Activity-Oriented Discrete-Event Simulation Introduction to Discrete-Event Simulation 6 Using SimPy Chun-Chieh Huang 5 jjhuang What is Simulation and 4 When to Use it? What is Discrete-Event 3 Simulation? Example to Illustrate World 2 Views Check events: 2nd arrival at 3.5, no action Introduction to SimPy 1 SimPy Example References 0 0 1 2 3 4 5 6 7 8 9
  • 34. Activity-Oriented Discrete-Event Simulation Introduction to Discrete-Event Simulation 6 Using SimPy Chun-Chieh Huang 5 jjhuang What is Simulation and 4 When to Use it? What is Discrete-Event 3 Simulation? Example to Illustrate World 2 Views Check events: 2nd arrival at 3.5, no action Introduction to SimPy 1 SimPy Example References 0 0 1 2 3 4 5 6 7 8 9
  • 35. Activity-Oriented Discrete-Event Simulation Introduction to Discrete-Event Simulation 6 Using SimPy Chun-Chieh Huang 5 jjhuang What is Simulation and 4 When to Use it? What is Discrete-Event 3 Simulation? Example to Illustrate World 2 Views Check events: 2nd arrival at 3.5, no action Introduction to SimPy 1 SimPy Example References 0 0 1 2 3 4 5 6 7 8 9
  • 36. Activity-Oriented Discrete-Event Simulation Introduction to Discrete-Event Simulation 6 Using SimPy Chun-Chieh Huang 5 jjhuang What is Simulation and 4 When to Use it? What is Discrete-Event 3 Simulation? Example to Illustrate World 2 Views Check events: 2nd arrival at 3.5, process now Introduction to SimPy 1 SimPy Example References 0 0 1 2 3 4 5 6 7 8 9
  • 37. Activity-Oriented Discrete-Event Simulation Introduction to Discrete-Event Simulation 6 Using SimPy Chun-Chieh Huang 5 jjhuang What is 4 Simulation and When to Use it? Second arrival! What is Discrete-Event 3 Simulation? Example to Illustrate World 2 Views Introduction to SimPy 1 SimPy Example References 0 0 1 2 3 4 5 6 7 8 9
  • 38. Activity-Oriented Discrete-Event Simulation Introduction to Discrete-Event Simulation 6 Using SimPy Chun-Chieh Huang 5 jjhuang What is 4 Simulation and When to Use it? Calculate next arrival at ... What is Discrete-Event 3 Simulation? Example to Illustrate World 2 Views Introduction to SimPy 1 SimPy Example References 0 0 1 2 3 4 5 6 7 8 9
  • 39. Activity-Oriented Discrete-Event Simulation Introduction to Discrete-Event Simulation 6 Using SimPy Chun-Chieh Huang 5 jjhuang What is Simulation and 4 When to Use it? What is Discrete-Event 3 Simulation? Example to Illustrate World 2 Views Check events: service end at 4.0, no action Introduction to SimPy 1 SimPy Example References 0 0 1 2 3 4 5 6 7 8 9
  • 40. Activity-Oriented Discrete-Event Simulation Introduction to Discrete-Event Simulation 6 Using SimPy Chun-Chieh Huang 5 jjhuang What is Simulation and 4 When to Use it? What is Discrete-Event 3 Simulation? Example to Illustrate World 2 Views Check events: service end at 4.0, no action Introduction to SimPy 1 SimPy Example References 0 0 1 2 3 4 5 6 7 8 9
  • 41. Activity-Oriented Discrete-Event Simulation Introduction to Discrete-Event Simulation 6 Using SimPy Chun-Chieh Huang 5 jjhuang What is Simulation and 4 When to Use it? What is Discrete-Event 3 Simulation? Example to Illustrate World 2 Views Check events: service end at 4.0, no action... Introduction to SimPy 1 SimPy Example References 0 0 1 2 3 4 5 6 7 8 9
  • 42. Discrete-Event Simulation World Views Introduction to Discrete-Event Simulation Using SimPy Chun-Chieh Activity-oriented Huang jjhuang fixed increment of time time-consuming What is Simulation and When to Use it? Event-oriented What is on each event, generate next event and Discrete-Event Simulation? put into event queue and sort Example to simulation time advances to next closest event Illustrate World faster than activity-oriented Views Introduction to Process-oriented SimPy abstract one object into a process SimPy Example easier to maintain in the end References
  • 43. Event-Oriented Discrete-Event Simulation Introduction to Discrete-Event Simulation 6 Using SimPy 2.6: 1st arr Chun-Chieh Huang 5 jjhuang What is 4 Simulation and When to Use it? Simulation starts! What is Discrete-Event 3 Simulation? Example to Illustrate World 2 Views Introduction to SimPy 1 SimPy Example References 0 0 1 2 3 4 5 6 7 8 9
  • 44. Event-Oriented Discrete-Event Simulation Introduction to Discrete-Event Simulation 6 Using SimPy 2.6: 1st arr Chun-Chieh Huang 5 jjhuang What is 4 Simulation and When to Use it? First arrival! What is Discrete-Event 3 Simulation? Example to Illustrate World 2 Views Introduction to SimPy 1 SimPy Example References 0 0 1 2 3 4 5 6 7 8 9
  • 45. Event-Oriented Discrete-Event Simulation Introduction to Discrete-Event Simulation 6 Using SimPy 3.5: 2nd arr 4.0: 1st arr end Chun-Chieh Huang 5 jjhuang Calculate service time, end at 4.0 What is 4 Simulation and When to Use it? Calculate next arrival at 3.5 What is Discrete-Event 3 Simulation? Example to Illustrate World 2 Views Introduction to SimPy 1 SimPy Example References 0 0 1 2 3 4 5 6 7 8 9
  • 46. Event-Oriented Discrete-Event Simulation Introduction to Discrete-Event Simulation 6 Using SimPy 3.5: 2nd arr 4.0: 1st arr end Chun-Chieh Huang 5 jjhuang What is 4 Simulation and When to Use it? Second arrival! What is Discrete-Event 3 Simulation? Example to Illustrate World 2 Views Introduction to SimPy 1 SimPy Example References 0 0 1 2 3 4 5 6 7 8 9
  • 47. Event-Oriented Discrete-Event Simulation Introduction to Discrete-Event Simulation 6 Using SimPy 4.0: 1st arr end Chun-Chieh Huang 5 jjhuang What is Simulation and 4 When to Use it? What is Discrete-Event 3 Simulation? Example to Illustrate World 2 Views Introduction to SimPy 1 SimPy Example References 0 0 1 2 3 4 5 6 7 8 9
  • 48. Event-Oriented Discrete-Event Simulation Introduction to Discrete-Event Simulation 6 Using SimPy 4.0: 1st arr end Chun-Chieh Huang 5 jjhuang End service of 1st arrival. What is Simulation and 4 When to Use it? What is Discrete-Event 3 Simulation? Example to Illustrate World 2 Views Introduction to SimPy 1 SimPy Example References 0 0 1 2 3 4 5 6 7 8 9
  • 49. Discrete-Event Simulation World Views Introduction to Discrete-Event Simulation Using SimPy Activity-oriented Chun-Chieh Huang fixed increment of time jjhuang time-consuming What is Event-oriented Simulation and When to Use it? on each event, generate next event and What is put into event queue and sort Discrete-Event Simulation? simulation time advances to next closest event Example to faster than activity-oriented Illustrate World Views Process-oriented Introduction to abstract one object into a process SimPy Arrival process for customers, or A SimPy Example Clerk process, or S References easier to maintain in the end
  • 50. Process-Oriented Discrete-Event Simulation Introduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang jjhuang Arrival is an infinite loop of the following What is Calculate next arrival time Simulation and When to Use it? Sleep until next arrival What is Add customer into queue Discrete-Event Simulation? Clerk is an infinite loop of the following Example to Sleep until waken up by customers Illustrate World Views Serve the customer on waken up Introduction to until there is no customer in line SimPy SimPy Example References
  • 51. Process-Oriented Discrete-Event Simulation Introduction to Discrete-Event Simulation 6 Using SimPy Chun-Chieh Huang 5 jjhuang A: Gen 1st arr at 2.6 What is 4 Simulation and When to Use it? Simulation starts! What is Discrete-Event 3 Simulation? S: Example to Illustrate World 2 Views Introduction to SimPy 1 SimPy Example References 0 0 1 2 3 4 5 6 7 8 9
  • 52. Process-Oriented Discrete-Event Simulation Introduction to Discrete-Event Simulation 6 Using SimPy Chun-Chieh Huang 5 jjhuang A: Add customer to queue What is 4 Simulation and When to Use it? First arrival! What is Discrete-Event 3 Simulation? S: Example to Illustrate World 2 Views Introduction to SimPy 1 SimPy Example References 0 0 1 2 3 4 5 6 7 8 9
  • 53. Process-Oriented Discrete-Event Simulation Introduction to Discrete-Event Simulation 6 Using SimPy Chun-Chieh Huang 5 jjhuang A: Calc next arr at 3.5 What is Simulation and 4 When to Use it? What is Discrete-Event 3 Simulation? S: Example to Illustrate World 2 Views Introduction to SimPy 1 SimPy Example References 0 0 1 2 3 4 5 6 7 8 9
  • 54. Process-Oriented Discrete-Event Simulation Introduction to Discrete-Event Simulation 6 Using SimPy Chun-Chieh Huang 5 jjhuang A: What is Simulation and 4 When to Use it? What is Discrete-Event 3 Simulation? S: Serv, calc serv T at 4.0 Example to Illustrate World 2 Views Introduction to SimPy 1 SimPy Example References 0 0 1 2 3 4 5 6 7 8 9
  • 55. Process-Oriented Discrete-Event Simulation Introduction to Discrete-Event Simulation 6 Using SimPy Chun-Chieh Huang 5 jjhuang A: Add customer to queue What is 4 Simulation and When to Use it? Second arrival! What is Discrete-Event 3 Simulation? S: Example to Illustrate World 2 Views Introduction to SimPy 1 SimPy Example References 0 0 1 2 3 4 5 6 7 8 9
  • 56. Process-Oriented Discrete-Event Simulation Introduction to Discrete-Event Simulation 6 Using SimPy Chun-Chieh Huang 5 jjhuang A: Calc next arr at ... What is 4 Simulation and When to Use it? Calc next arrival at ... What is Discrete-Event 3 Simulation? S: Example to Illustrate World 2 Views Introduction to SimPy 1 SimPy Example References 0 0 1 2 3 4 5 6 7 8 9
  • 57. Process-Oriented Discrete-Event Simulation Introduction to Discrete-Event Simulation 6 Using SimPy Chun-Chieh Huang 5 jjhuang A: What is Simulation and 4 When to Use it? What is Discrete-Event 3 Simulation? S: 1st arr end serv. Call next. Example to Illustrate World 2 Views Introduction to SimPy 1 SimPy Example References 0 0 1 2 3 4 5 6 7 8 9
  • 58. Process-Oriented Discrete-Event Simulation Introduction to Discrete-Event Simulation 6 Using SimPy Chun-Chieh Huang 5 jjhuang A: What is Simulation and 4 When to Use it? What is Discrete-Event 3 Simulation? S: Serv 2nd arr. Calc end time at ... Example to Illustrate World 2 Views Introduction to SimPy 1 SimPy Example References 0 0 1 2 3 4 5 6 7 8 9
  • 59. Implementing Discrete-Event Simulation Introduction to Discrete-Event Simulation Using SimPy Chun-Chieh Use your own C/C++ implementation Huang jjhuang takes time to write simulation engine and algorithm code hard to debug when both are not verified What is Simulation and not very convincing When to Use it? What is Discrete-Event Simulation? Example to Illustrate World Views Introduction to SimPy SimPy Example References
  • 60. Implementing Discrete-Event Simulation Introduction to Discrete-Event Simulation Using SimPy Chun-Chieh Use your own C/C++ implementation Huang jjhuang takes time to write simulation engine and algorithm code hard to debug when both are not verified What is Simulation and not very convincing When to Use it? What is Use generalized simulation library, or language Discrete-Event Simulation? SIMULA programming language C++SIM or JavaSIM [3] Example to Illustrate World SimEvents in Simulink/MATLAB Views SimPy [4] Introduction to SimPy SimPy Example References
  • 61. Implementing Discrete-Event Simulation Introduction to Discrete-Event Simulation Using SimPy Chun-Chieh Use your own C/C++ implementation Huang jjhuang takes time to write simulation engine and algorithm code hard to debug when both are not verified What is Simulation and not very convincing When to Use it? What is Use generalized simulation library, or language Discrete-Event Simulation? SIMULA programming language C++SIM or JavaSIM [3] Example to Illustrate World SimEvents in Simulink/MATLAB Views SimPy [4] Introduction to SimPy Use special purpose simulation packages SimPy Example ns-3 for network simulation [5] References
  • 62. Introduction to SimPy Introduction to Discrete-Event Simulation Using SimPy Chun-Chieh Uses Python for modeling Huang jjhuang Python is a scripting language like MATLAB, but faster! Python is free! What is Simulation and Python is very easy to write and beautiful! When to Use it? What is Discrete-Event Simulation? Example to Illustrate World Views Introduction to SimPy SimPy Example References
  • 63. Introduction to SimPy Introduction to Discrete-Event Simulation Using SimPy Chun-Chieh Uses Python for modeling Huang jjhuang Python is a scripting language like MATLAB, but faster! Python is free! What is Simulation and Python is very easy to write and beautiful! When to Use it? What is Process-oriented Discrete-Event Simulation Language Discrete-Event is easier to write model Simulation? provides proven event manager implementation Example to Illustrate World lets you focus on algorithm code Views Introduction to SimPy SimPy Example References
  • 64. Introduction to SimPy Introduction to Discrete-Event Simulation Using SimPy Chun-Chieh Uses Python for modeling Huang jjhuang Python is a scripting language like MATLAB, but faster! Python is free! What is Simulation and Python is very easy to write and beautiful! When to Use it? What is Process-oriented Discrete-Event Simulation Language Discrete-Event is easier to write model Simulation? provides proven event manager implementation Example to Illustrate World lets you focus on algorithm code Views Introduction to Uses coroutine to suspend/resume process SimPy guarantees order of execution SimPy Example cannot run on parallel machine for a single simulation References
  • 65. SimPy Terminology: Classes Introduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang jjhuang Process What is simulates an entity which evolves in time, e.g. Simulation and When to Use it? a clerk that serves customers What is refered to as thread in [6] Discrete-Event Simulation? Example to Illustrate World Views Introduction to SimPy SimPy Example References
  • 66. SimPy Terminology: Classes Introduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang jjhuang Process What is simulates an entity which evolves in time, e.g. Simulation and When to Use it? a clerk that serves customers What is refered to as thread in [6] Discrete-Event Simulation? Resource Example to simulates something to be requested and Illustrate World Views queued if not available now Introduction to e.g. a wash machine SimPy SimPy Example References
  • 67. SimPy Terimnology: Functions Introduction to Discrete-Event Simulation activate() used to mark a thread as runnable when it is first Using SimPy created Chun-Chieh Huang jjhuang What is Simulation and When to Use it? What is Discrete-Event Simulation? Example to Illustrate World Views Introduction to SimPy SimPy Example References
  • 68. SimPy Terimnology: Functions Introduction to Discrete-Event Simulation activate() used to mark a thread as runnable when it is first Using SimPy created Chun-Chieh Huang jjhuang simulate() starts the simulation What is Simulation and When to Use it? What is Discrete-Event Simulation? Example to Illustrate World Views Introduction to SimPy SimPy Example References
  • 69. SimPy Terimnology: Functions Introduction to Discrete-Event Simulation activate() used to mark a thread as runnable when it is first Using SimPy created Chun-Chieh Huang jjhuang simulate() starts the simulation What is yield hold put current thread into suspension for a certain Simulation and When to Use it? amount of time What is Discrete-Event Simulation? Example to Illustrate World Views Introduction to SimPy SimPy Example References
  • 70. SimPy Terimnology: Functions Introduction to Discrete-Event Simulation activate() used to mark a thread as runnable when it is first Using SimPy created Chun-Chieh Huang jjhuang simulate() starts the simulation What is yield hold put current thread into suspension for a certain Simulation and When to Use it? amount of time What is yield passivate put current thread into suspension and Discrete-Event Simulation? wait until awakened by some other thread Example to Illustrate World Views Introduction to SimPy SimPy Example References
  • 71. SimPy Terimnology: Functions Introduction to Discrete-Event Simulation activate() used to mark a thread as runnable when it is first Using SimPy created Chun-Chieh Huang jjhuang simulate() starts the simulation What is yield hold put current thread into suspension for a certain Simulation and When to Use it? amount of time What is yield passivate put current thread into suspension and Discrete-Event Simulation? wait until awakened by some other thread Example to Illustrate World reactivate() awakes a previously-passivated thread Views Introduction to SimPy SimPy Example References
  • 72. SimPy Terimnology: Functions Introduction to Discrete-Event Simulation activate() used to mark a thread as runnable when it is first Using SimPy created Chun-Chieh Huang jjhuang simulate() starts the simulation What is yield hold put current thread into suspension for a certain Simulation and When to Use it? amount of time What is yield passivate put current thread into suspension and Discrete-Event Simulation? wait until awakened by some other thread Example to Illustrate World reactivate() awakes a previously-passivated thread Views cancel() cancels all the events associated with a Introduction to SimPy previously-passivated thread SimPy Example References
  • 73. SimPy Terimnology: Functions Introduction to Discrete-Event Simulation activate() used to mark a thread as runnable when it is first Using SimPy created Chun-Chieh Huang jjhuang simulate() starts the simulation What is yield hold put current thread into suspension for a certain Simulation and When to Use it? amount of time What is yield passivate put current thread into suspension and Discrete-Event Simulation? wait until awakened by some other thread Example to Illustrate World reactivate() awakes a previously-passivated thread Views cancel() cancels all the events associated with a Introduction to SimPy previously-passivated thread SimPy Example yield request requests for a given resource References yield release used to indicate that current thread no longer need the given resource
  • 74. SimPy Example Introduction to Discrete-Event Simulation Using SimPy Chun-Chieh Scenario Huang jjhuang A post office with only one clerk. Customer arrival is a poisson process, What is Simulation and i.e. inter-arrival time is exponential distribution. When to Use it? Service time is also a poisson process. What is Discrete-Event Classical M /M /1 problem in queueing theory Simulation? Process Example to Illustrate World Arrival Views Clerk Introduction to SimPy Queue is managed by ourselves SimPy Example So that we can extend to M /M /m later, i.e. m clerks References
  • 75. Arrival Pseudo Code Introduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang jjhuang What is Simulation and Arrival is an infinite loop of the following When to Use it? Calculate next arrival time What is Discrete-Event Sleep until next arrival Simulation? Add customer into queue Example to Illustrate World Views Introduction to SimPy SimPy Example References
  • 76. Arrival Process Introduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang 1 class A r r i v a l C l a s s ( Process ) : jjhuang 2 " " " An a r r i v a l maintenance c l a s s " " " 3 ArrivalRate = 1/1.0 # r e c i p r o c a l o f mean i n t e r a r r i v a l t i m e What is 4 def _ _ i n i t _ _ ( s e l f , name ) : Simulation and 5 Process . _ _ i n i t _ _ ( s e l f ) When to Use it? 6 s e l f . name = name 7 What is 8 def Run ( s e l f ) : Discrete-Event 9 while True : Simulation? 10 I n t e r A r r i v a l T i m e = G. Rnd . e x p o v a r i a t e ( A r r i v a l C l a s s . A r r i v a l R a t e ) 11 y i e l d hold , s e l f , I n t e r A r r i v a l T i m e Example to 12 C = Customer ( ) Illustrate World 13 C l e r k C l a s s . Queue . append (C) # a customer a r r i v e s Views 14 G. NumCustomers += 1 Introduction to 15 i f ClerkClass . I d l e != [ ] : # I s t h e r e any c l e r k i d l e ? SimPy 16 r e a c t i v a t e ( C l e r k C l a s s . I d l e [ 0 ] ) # Yes , wake him / her up SimPy Example References
  • 77. Clerk Pseudo Code Introduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang jjhuang What is Simulation and Clerk is an infinite loop of the following When to Use it? Sleep until waken up by customers What is Discrete-Event Serve the customer on waken up Simulation? until there is no customer in line Example to Illustrate World Views Introduction to SimPy SimPy Example References
  • 78. Clerk Process Introduction to Discrete-Event 1 class C l e r k C l a s s ( Process ) : Simulation 2 " " " A s e r v e r process , o r c l e r k i n t h e p o s t o f f i c e " " " Using SimPy 3 ServiceRate = 1 / 1 . 2 # r e c i p r o c a l o f mean s e r v i c e t i m e 4 MaxQueueLength = 0 Chun-Chieh 5 Queue = [ ] # customer queue Huang 6 Idle = [ ] # idle clerk l i s t jjhuang 7 Busy = [ ] # busy c l e r k l i s t 8 NumDone = 0 # No . o f customers being s e r v i c e d What is 9 def _ _ i n i t _ _ ( s e l f ) : Simulation and 10 Process . _ _ i n i t _ _ ( s e l f ) When to Use it? 11 C l e r k C l a s s . I d l e . append ( s e l f ) # I n i t i a l l y idle 12 def Run ( s e l f ) : What is 13 while True : Discrete-Event 14 y i e l d passivate , s e l f # w a i t u n t i l awaken by customers Simulation? 15 C l e r k C l a s s . I d l e . remove ( s e l f ) 16 C l e r k C l a s s . Busy . append ( s e l f ) # going t o be busy Example to 17 while C l e r k C l a s s . Queue ! = [ ] : Illustrate World 18 i f l e n ( C l e r k C l a s s . Queue ) > C l e r k C l a s s . MaxQueueLength : Views 19 C l e r k C l a s s . MaxQueueLength = l e n ( C l e r k C l a s s . Queue ) 20 C = C l e r k C l a s s . Queue . pop ( ) # c a l l n e x t customer i n l i n e Introduction to 21 # S t a r t s e r v i c e t h e customer SimPy 22 ServiceTime = G. Rnd . e x p o v a r i a t e ( C l e r k C l a s s . ServiceRate ) SimPy Example 23 y i e l d hold , s e l f , ServiceTime # s t a r t t o serve 24 C . endService ( ) # end o f s e r v i c e References 25 G. T o t a l W a i t i n g T i m e += now ( ) − C . A r r i v a l T i m e 26 C l e r k C l a s s . NumDone += 1 27 del C # customer i s gone 28 C l e r k C l a s s . Busy . remove ( s e l f ) 29 C l e r k C l a s s . I d l e . append ( s e l f )
  • 79. Simulation Main Loop Introduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang 1 i f DEBUG: jjhuang 2 from SimPy . S i m u l a t i o n T r a c e import ∗ 3 else : What is 4 from SimPy . S i m u l a t i o n import ∗ Simulation and 5 When to Use it? 6 def main ( ) : 7 initialize () # I n i t i a l i z e s simulator What is 8 A = A r r i v a l C l a s s ( name= " A r r i v a l " ) Discrete-Event 9 a c t i v a t e ( A , A . Run ( ) ) # Activate a r r i v a l Simulation? 10 11 S = C l e r k C l a s s ( name= " C l e r k " ) Example to 12 a c t i v a t e ( S , S . Run ( ) ) # Activate clerk Illustrate World 13 Views 14 s i m u l a t e ( u n t i l =MaxSimTime ) # S t a r t to simulate ! 15 Introduction to 16 i f __name__ == ’ __main__ ’ : SimPy 17 main ( ) SimPy Example References
  • 80. Concluding Remarks Introduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang jjhuang What is Simulation is a powerful tool to study physical problems at Simulation and When to Use it? cheaper cost. What is Discrete-Event SimPy provides process-oriendted DES framework Simulation? to write simulation easily and reasonably fast. Example to Illustrate World And SimPy is free! Views Introduction to SimPy SimPy Example References
  • 81. References Introduction to Discrete-Event Simulation Using SimPy [1] R. E. Nance, “A history of discrete event simulation Chun-Chieh programming languages,” in The second ACM SIGPLAN Huang jjhuang conference on History of programming languages, ser. HOPL-II. New York, NY, USA: ACM, 1993, pp. 149–175. What is Simulation and [Online]. Available: http://doi.acm.org/10.1145/154766.155368 When to Use it? What is [2] J. Banks, J. S. Carson, B. L. Nelson, and D. M. Nicol, Discrete-Event Simulation? Discrete-Event System Simulation (5th Edition). Prentice Example to Hall, 2009. Illustrate World Views [3] C++SIM and JavaSim, “http://javasim.codehaus.org/.” Introduction to SimPy [4] S. S. Package, “http://simpy.sourceforge.net/.” SimPy Example [5] ns-3 Network Simulator, “http://www.nsnam.org/.” References [6] N. Matloff, “A discrete-event simulation course based on the simpy language,” Davis, 2006.
  • 82. Introduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang jjhuang What is Simulation and When to Use it? What is Discrete-Event Simulation? Q&A Example to Illustrate World Views Introduction to SimPy SimPy Example References