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

سلسلة ماركوف Markov chain
سلسلة ماركوف Markov chainسلسلة ماركوف Markov chain
سلسلة ماركوف Markov chainEhab Saad Ahmad
 
2014 data 보안 가이드라인 그랜드컨퍼런스 20140930
2014 data 보안 가이드라인 그랜드컨퍼런스 201409302014 data 보안 가이드라인 그랜드컨퍼런스 20140930
2014 data 보안 가이드라인 그랜드컨퍼런스 20140930eungjin cho
 
Reinforcement learning.pptx
Reinforcement learning.pptxReinforcement learning.pptx
Reinforcement learning.pptxaniketgupta16440
 
Data visualization in a nutshell
Data visualization in a nutshellData visualization in a nutshell
Data visualization in a nutshellDavid Alayón
 
"Introduction to Data Visualization" Workshop for General Assembly by Hunter ...
"Introduction to Data Visualization" Workshop for General Assembly by Hunter ..."Introduction to Data Visualization" Workshop for General Assembly by Hunter ...
"Introduction to Data Visualization" Workshop for General Assembly by Hunter ...Hunter Whitney
 
Object tracking survey
Object tracking surveyObject tracking survey
Object tracking surveyRich Nguyen
 
Discrete event simulation
Discrete event simulationDiscrete event simulation
Discrete event simulationssusera970cc
 
Simulation - Generating Continuous Random Variables
Simulation - Generating Continuous Random VariablesSimulation - Generating Continuous Random Variables
Simulation - Generating Continuous Random VariablesMartin Kretzer
 
Deep learning and feature extraction for time series forecasting
Deep learning and feature extraction for time series forecastingDeep learning and feature extraction for time series forecasting
Deep learning and feature extraction for time series forecastingPavel Filonov
 
선형대수 06. 영벡터공간과 해집합
선형대수 06. 영벡터공간과 해집합선형대수 06. 영벡터공간과 해집합
선형대수 06. 영벡터공간과 해집합AHRA CHO
 
Time Series Forecasting Using Recurrent Neural Network and Vector Autoregress...
Time Series Forecasting Using Recurrent Neural Network and Vector Autoregress...Time Series Forecasting Using Recurrent Neural Network and Vector Autoregress...
Time Series Forecasting Using Recurrent Neural Network and Vector Autoregress...Databricks
 
딥러닝 모델을 이용한 반도체 웨이퍼 가공 불량 타입 분류
딥러닝 모델을 이용한 반도체 웨이퍼 가공 불량 타입 분류딥러닝 모델을 이용한 반도체 웨이퍼 가공 불량 타입 분류
딥러닝 모델을 이용한 반도체 웨이퍼 가공 불량 타입 분류ssuserdff4c9
 
Andrew NG machine learning
Andrew NG machine learningAndrew NG machine learning
Andrew NG machine learningShareDocView.com
 
Engineering data quality
Engineering data qualityEngineering data quality
Engineering data qualityLars Albertsson
 
Survey on optical flow estimation with DL
Survey on optical flow estimation with DLSurvey on optical flow estimation with DL
Survey on optical flow estimation with DLLeapMind Inc
 
Big data visualization
Big data visualizationBig data visualization
Big data visualizationAnurag Gupta
 

What's hot (20)

سلسلة ماركوف Markov chain
سلسلة ماركوف Markov chainسلسلة ماركوف Markov chain
سلسلة ماركوف Markov chain
 
Human Action Recognition
Human Action RecognitionHuman Action Recognition
Human Action Recognition
 
Time series deep learning
Time series   deep learningTime series   deep learning
Time series deep learning
 
2014 data 보안 가이드라인 그랜드컨퍼런스 20140930
2014 data 보안 가이드라인 그랜드컨퍼런스 201409302014 data 보안 가이드라인 그랜드컨퍼런스 20140930
2014 data 보안 가이드라인 그랜드컨퍼런스 20140930
 
Reinforcement learning.pptx
Reinforcement learning.pptxReinforcement learning.pptx
Reinforcement learning.pptx
 
Data visualization in a nutshell
Data visualization in a nutshellData visualization in a nutshell
Data visualization in a nutshell
 
"Introduction to Data Visualization" Workshop for General Assembly by Hunter ...
"Introduction to Data Visualization" Workshop for General Assembly by Hunter ..."Introduction to Data Visualization" Workshop for General Assembly by Hunter ...
"Introduction to Data Visualization" Workshop for General Assembly by Hunter ...
 
Object tracking survey
Object tracking surveyObject tracking survey
Object tracking survey
 
Discrete event simulation
Discrete event simulationDiscrete event simulation
Discrete event simulation
 
Simulation - Generating Continuous Random Variables
Simulation - Generating Continuous Random VariablesSimulation - Generating Continuous Random Variables
Simulation - Generating Continuous Random Variables
 
Federated Learning
Federated LearningFederated Learning
Federated Learning
 
Deep learning and feature extraction for time series forecasting
Deep learning and feature extraction for time series forecastingDeep learning and feature extraction for time series forecasting
Deep learning and feature extraction for time series forecasting
 
Uml and enterprise architect
Uml and enterprise architectUml and enterprise architect
Uml and enterprise architect
 
선형대수 06. 영벡터공간과 해집합
선형대수 06. 영벡터공간과 해집합선형대수 06. 영벡터공간과 해집합
선형대수 06. 영벡터공간과 해집합
 
Time Series Forecasting Using Recurrent Neural Network and Vector Autoregress...
Time Series Forecasting Using Recurrent Neural Network and Vector Autoregress...Time Series Forecasting Using Recurrent Neural Network and Vector Autoregress...
Time Series Forecasting Using Recurrent Neural Network and Vector Autoregress...
 
딥러닝 모델을 이용한 반도체 웨이퍼 가공 불량 타입 분류
딥러닝 모델을 이용한 반도체 웨이퍼 가공 불량 타입 분류딥러닝 모델을 이용한 반도체 웨이퍼 가공 불량 타입 분류
딥러닝 모델을 이용한 반도체 웨이퍼 가공 불량 타입 분류
 
Andrew NG machine learning
Andrew NG machine learningAndrew NG machine learning
Andrew NG machine learning
 
Engineering data quality
Engineering data qualityEngineering data quality
Engineering data quality
 
Survey on optical flow estimation with DL
Survey on optical flow estimation with DLSurvey on optical flow estimation with DL
Survey on optical flow estimation with DL
 
Big data visualization
Big data visualizationBig data visualization
Big data visualization
 

Viewers also liked

Pycontw2013x
Pycontw2013xPycontw2013x
Pycontw2013xweijr
 
Pysx presentation at Pycontw
Pysx presentation at PycontwPysx presentation at Pycontw
Pysx presentation at Pycontwweijr
 
Rapid prototypingembeddedsystemsbypython
Rapid prototypingembeddedsystemsbypythonRapid prototypingembeddedsystemsbypython
Rapid prototypingembeddedsystemsbypythonAlbert Huang
 
A Glimpse into Developing Software-Defined Radio by Python
A Glimpse into Developing Software-Defined Radio by PythonA Glimpse into Developing Software-Defined Radio by Python
A Glimpse into Developing Software-Defined Radio by PythonAlbert Huang
 
Introduction to Digital Signal Processing Using GNU Radio
Introduction to Digital Signal Processing Using GNU RadioIntroduction to Digital Signal Processing Using GNU Radio
Introduction to Digital Signal Processing Using GNU RadioAlbert Huang
 

Viewers also liked (6)

Pycontw2013x
Pycontw2013xPycontw2013x
Pycontw2013x
 
Pysx presentation at Pycontw
Pysx presentation at PycontwPysx presentation at Pycontw
Pysx presentation at Pycontw
 
Rapid prototypingembeddedsystemsbypython
Rapid prototypingembeddedsystemsbypythonRapid prototypingembeddedsystemsbypython
Rapid prototypingembeddedsystemsbypython
 
Gnu radio lecture
Gnu radio lectureGnu radio lecture
Gnu radio lecture
 
A Glimpse into Developing Software-Defined Radio by Python
A Glimpse into Developing Software-Defined Radio by PythonA Glimpse into Developing Software-Defined Radio by Python
A Glimpse into Developing Software-Defined Radio by Python
 
Introduction to Digital Signal Processing Using GNU Radio
Introduction to Digital Signal Processing Using GNU RadioIntroduction to Digital Signal Processing Using GNU Radio
Introduction to Digital Signal Processing Using GNU Radio
 

Similar to Introduction 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 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
 

Recently uploaded

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
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
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
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
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
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
 
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
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
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
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
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
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 

Recently uploaded (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
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
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
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
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
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
 
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...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
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
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
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?
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 

Introduction 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