Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.
Donghun Kang
Postdoctoral Researcher
Dept. of Industrial & Systems
Engineering, KAIST, South Korea
WINTER SIMULATION CONFE...
Copyright ® 2014 VMS Lab. All rights reserved
Contents
1. Introduction
1.1 Event Graph
1.2 Activity Cycle Diagram
2. How t...
Copyright ® 2014 VMS Lab. All rights reserved
1. Introduction
 This section will
– Learn what the discrete-event system i...
Copyright ® 2014 VMS Lab. All rights reserved
1. Introduction
 Discrete-event system (DES)
– Regular DES
• Consists of re...
Copyright ® 2014 VMS Lab. All rights reserved
1.1 Event Graph (1/3)
 Event-based Modeling Concept
– Realized in SIMSCRIPT...
Copyright ® 2014 VMS Lab. All rights reserved
1.1 Event Graph (2/3)
 Event Graph Model of a Single Server System (e.g. AT...
Copyright ® 2014 VMS Lab. All rights reserved
1.1 Event Graph (3/3)
 Event Graph Model of a Single Server System
– Algebr...
Copyright ® 2014 VMS Lab. All rights reserved
1.2 Activity Cycle Diagram (1/2)
 Activity-based Modeling Concept
– Invente...
Copyright ® 2014 VMS Lab. All rights reserved
1.2 Activity Cycle Diagram (2/2)
 Classical ACD Model of a Single Server Sy...
Copyright ® 2014 VMS Lab. All rights reserved
2. How to Develop Your Own Dedicated Event Graph Simulators
 This section w...
Copyright ® 2014 VMS Lab. All rights reserved
EVENT: E1
TIME: 12.1
2.1 Functions for Handling Events
 In order to simulat...
Copyright ® 2014 VMS Lab. All rights reserved
2.2 Functions for generating Random Variates (1/2)
 Generating a standard u...
Copyright ® 2014 VMS Lab. All rights reserved
2.2 Functions for generating Random Variates (2/2)
 Free Open Source Librar...
Copyright ® 2014 VMS Lab. All rights reserved
2.3 Event Routines (1/2)
 Portion of an event graph
 Event Transition Tabl...
Copyright ® 2014 VMS Lab. All rights reserved
2.3 Event Routines (2/2)
 Event Routine
– A subprogram that describe the
1)...
Copyright ® 2014 VMS Lab. All rights reserved
2.4 Next Event Scheduling Algorithm for Simulation Execution (1/2)
 Next ev...
Copyright ® 2014 VMS Lab. All rights reserved
2.4 Next Event Scheduling Algorithm for Simulation Execution (2/2)
 Main Pr...
Copyright ® 2014 VMS Lab. All rights reserved
2.5 Single Server System Event Graph Simulator (1/6)
 Process of programmin...
Copyright ® 2014 VMS Lab. All rights reserved
2.5 Single Server System Event Graph Simulator (2/6)
1) Conversion to augmen...
Copyright ® 2014 VMS Lab. All rights reserved
2.5 Single Server System Event Graph Simulator (3/6)
2) Construction of even...
Copyright ® 2014 VMS Lab. All rights reserved
2.5 Single Server System Event Graph Simulator (4/6)
3) Development of routi...
Copyright ® 2014 VMS Lab. All rights reserved
2.5 Single Server System Event Graph Simulator (4/6)
4) Main program
No Orig...
Copyright ® 2014 VMS Lab. All rights reserved
2.5 Single Server System Event Graph Simulator (5/6)
 Single Server System ...
Copyright ® 2014 VMS Lab. All rights reserved
2.6 C# Implementation of the Single Server System Event Graph Simlator
 Cla...
Copyright ® 2014 VMS Lab. All rights reserved
2.6 C# Implementation of the Single Server System Event Graph Simlator
 Sou...
Copyright ® 2014 VMS Lab. All rights reserved
3. How to Develop Your Own Dedicated ACD Simulators
 This section will
– As...
Copyright ® 2014 VMS Lab. All rights reserved
3.1 Functions for Handling Activities
 Candidate Activity List (CAL)
– A fi...
Copyright ® 2014 VMS Lab. All rights reserved
3.2 Activity Routines and Event Routines (1/3)
 An activity is confined by ...
Copyright ® 2014 VMS Lab. All rights reserved
3.2 Activity Routines and Event Routines (2/3)
 Activity Transition Table (...
Copyright ® 2014 VMS Lab. All rights reserved
Execute-A1-activity-routine (Clock) {
}
Execute-E1-event-routine (t) {
}
3.2...
Copyright ® 2014 VMS Lab. All rights reserved
3.3 Activity Scanning Algorithm (1/3)
 Tocher’s three-phase process (Holloc...
Copyright ® 2014 VMS Lab. All rights reserved
3.3 Activity Scanning Algorithm (2/3)
 Activity scanning algorithm
– Benefi...
Copyright ® 2014 VMS Lab. All rights reserved
3.3 Activity Scanning Algorithm (3/3)
 Main Program Template for the ACD Si...
Copyright ® 2014 VMS Lab. All rights reserved
3.4 Single Server System ACD Simulator (1/5)
 Process of programming a dedi...
Copyright ® 2014 VMS Lab. All rights reserved
3.4 Single Server System ACD Simulator (2/5)
1) Conversion to augmented ACD ...
Copyright ® 2014 VMS Lab. All rights reserved
3.4 Single Server System ACD Simulator (3/5)
2) Construction of activity tra...
Copyright ® 2014 VMS Lab. All rights reserved
3.4 Single Server System ACD Simulator (4/5)
3) Development of routines
Exec...
Copyright ® 2014 VMS Lab. All rights reserved
3.4 Single Server System ACD Simulator (5/5)
4) Main program
Begin
CLK= 0;
E...
Copyright ® 2014 VMS Lab. All rights reserved
3.5 C# Implementation of the Single Server System ACD Simulator
 Class Diag...
Copyright ® 2014 VMS Lab. All rights reserved
3.5 C# Implementation of the Single Server System ACD Simulator
 Source Cod...
Copyright ® 2014 VMS Lab. All rights reserved
4. A General Purpose ACD Executor: ACE® (1/3)
 Activity Cycle Executor: ACE...
Copyright ® 2014 VMS Lab. All rights reserved
4. A General Purpose ACD Executor: ACE® (2/3)
 Components of ACE®
– GUI com...
Copyright ® 2014 VMS Lab. All rights reserved
4. A General Purpose ACD Executor: ACE® (3/3)
 Components of ACE®
– Library...
Copyright ® 2014 VMS Lab. All rights reserved
5. Summary
 What we have explained
– How to develop dedicated simulators fo...
Copyright ® 2014 VMS Lab. All rights reserved
Donghun Kang
Postdoctoral Researcher
ISysE Dept., KAIST
donghun.kang@kaist.a...
Prochain SlideShare
Chargement dans…5
×

How to Develop Your Own Simulators for Discrete-Event Systems

278 vues

Publié le

an introductory tutorial presented at the 2014 Winter Simulation Conference

Publié dans : Technologie
  • Login to see the comments

How to Develop Your Own Simulators for Discrete-Event Systems

  1. 1. Donghun Kang Postdoctoral Researcher Dept. of Industrial & Systems Engineering, KAIST, South Korea WINTER SIMULATION CONFERENCE 2014 | Advanced Tutorials How to Develop Your Own Simulators for Discrete-Event Systems December 8, 2014 Byoung K. Choi Emeritus Professor Dept. of Industrial & Systems Engineering, KAIST, South Korea
  2. 2. Copyright ® 2014 VMS Lab. All rights reserved Contents 1. Introduction 1.1 Event Graph 1.2 Activity Cycle Diagram 2. How to Develop Your Own Dedicated Event Graph Simulators 2.1 Functions for Handling Events 2.2 Functions for Generating Random Variates 2.3 Event Routines 2.4 Next Event Scheduling Algorithm for Simulation Execution 2.5 Single Server System Event Graph Simulator 2.6 C# Implementation of the Single Server System Event Graph Simulator 3. How to Develop Your Own Dedicated ACD Simulators 3.1 Functions for Handling Activities 3.2 Activity Routines and Event Routines 3.3 Activity Scanning Algorithm 3.4 Single Server System ACD Simulator 3.5 C# Implementation of the Single Server System ACD Simulator 4. A General Purpose ACD Executor: ACE® 4.1 Simulation Coordinator 4.2 Event Object Simulator 5. Summary
  3. 3. Copyright ® 2014 VMS Lab. All rights reserved 1. Introduction  This section will – Learn what the discrete-event system is – Understand two representative modeling formalisms for the discrete-event system  Contents – Discre-Event System and modeling formalims – Event Graph – Activity Cycle Diagram
  4. 4. Copyright ® 2014 VMS Lab. All rights reserved 1. Introduction  Discrete-event system (DES) – Regular DES • Consists of resources (e.g. machines and buffers) and entities (e.g. jobs) • e.g. service systems, manufacturing systems, traffic systems, and military systems – Resource-less DES • A DES without physical resources • The entities in a resource-less DES are referred to as agents • Agent-based modeling – A system is modeled through placing agents in the system and let the system evolve from the interaction of those agents • e.g. flock of seasonal birds in the sky  Modeling formalism for the DES – Event Graph, Activity Cycle Diagram (ACD) • Commonly used in simulation modeling of regular DESs (modeling for simulation) – Petri nets and Timed Automata • Primarily used in modeling DESs for analysis purposes  You will learn through this tutorial – How to develop dedicated simulators for executing event graph models and ACD models. Discrete-Event System (DES): A discrete-state, event-driven system in which the state changes depend entirely on the occurrence of discrete events over time. Modeling Formalism: a well-defined set of graphical conventions for specifying a DES. It has a formal syntax and can be executed by a simulation algorithm.
  5. 5. Copyright ® 2014 VMS Lab. All rights reserved 1.1 Event Graph (1/3)  Event-based Modeling Concept – Realized in SIMSCRIPT II in the 1960s (Kiviat, Villanueva, and Markowitz 1968) – Established in event graph modeling formalism in the early 1980s (Schruben, 1983)  Event Graph – A directed graph of vertices and edges where a vertex represents an event where the system state changes and an edge represents the temporal and logical relationship between pairs of events – Directed graph GEG can be specified as a septuple structure (Savage, Schruben, and Yücesan (2005) – State-of-the-art review of event graph is given in Savage, Schruben, and Yücesan (2005) GEG = <V, E, S, F, C, D, A> where V = {v} is a set of event vertices, E = {eod = (vo, vd)} is a set of edges, // vo, vd: originating, destination vertex S = {s} is a set of state variables, F = {fv: S → S ∀ v ∈ V} is a set of state change functions associated with each vertex (v), C = {ce: S → {0, 1} ∀ e ∈ E} is a set of conditions associated with each edge (e), .. D = {de ∈ R+ ∀ e ∈ E} is a set of time delays associated with e, and A = {ae ∈ {scheduling, canceling} ∀ e ∈ E} is a set of action types associated with e.
  6. 6. Copyright ® 2014 VMS Lab. All rights reserved 1.1 Event Graph (2/3)  Event Graph Model of a Single Server System (e.g. ATM, Vending Machine) Initial State • Machine is idle (M = 1) • Buffer is empty (Q = 0)Arrive event • Increases the job count in the buffer (Q++), • Always schedules another Arrive event to occur after ta • Schedules a Load event to occur immediately if the machine is idle (M ≡ 1) Load event • Sets the machine to busy (M--) • Decreases the job count by one (Q--) • Schedules an Unload event to occur after ts Unload event • Resets the machine to idle (M++) • Schedules a Load event if the buffer is not empty (Q > 0).
  7. 7. Copyright ® 2014 VMS Lab. All rights reserved 1.1 Event Graph (3/3)  Event Graph Model of a Single Server System – Algebraic specification GEG = <V, E, S, F, C, D, A> where V = {v1 = Arrive, v2 = Load, v3 = Unload}, E = {e11 = (v1, v1), e12 = (v1, v2), e23 = (v2, v3), e32 = (v3, v2)}, S = {Q, M}, F = {f1: {Q++}, f2: {M--, Q--}, f3: {M++}}, C = {c11, c23: true, c12: (M≡1), c32: (Q>0)}, .. D = {c11: ta, c23: ts}, and A = {a11, a12, a23, a32: scheduling}.
  8. 8. Copyright ® 2014 VMS Lab. All rights reserved 1.2 Activity Cycle Diagram (1/2)  Activity-based Modeling Concept – Invented by Tocher in the late 1950s in order to solve a congestion control problem at a steel mill (Hollocks 2008) – Flow diagram of activities to model the dynamic behavior of the steel plant. – Activity flow diagram later evolved into the classical ACD (Carrier 1988)  Classical Activity Cycle Diagram (ACD) – an ‘activity’ typically represents the interaction between an entity and active resources. An entity or an active resource is either in a passive state called a queue or in an active state called an activity. Queue nodes and activity nodes are connected by arcs. – bipartite directed graph GACD can be specified as a sextuple structure – State-of-the-art review of ACD is given in Choi and Kang (2013) GACD = <A, Q, E, T, μ, μ0>) where A = {ai} is a finite set of activity nodes, Q = {qj} is a finite set of queue nodes, E = {ek} is a finite set of edges with ei ∈ (A ⨯ Q) ∪ (Q ⨯ A), T = {τa} is the time delay function associated with each activity node (a ∈ A), μ = {μq} is the marking vector associated with each queue node (q ∈ Q), and μ0 is the initial marking.
  9. 9. Copyright ® 2014 VMS Lab. All rights reserved 1.2 Activity Cycle Diagram (2/2)  Classical ACD Model of a Single Server System – Three activity cycles • One entity-activity cycle (in the solid-line loop) • Two resource-activity cycles for Creator and Machine (in the dahsed line loops) – Algebraic specification GACD = <A, Q, E, T, μ, μ0> where A = {a1 = Create, a2 = Process}, Q = {q1 = Jobs, q2 = C, q3 = Q, q4 = M}, E = {e11=(q1,a1), e21=(q2,a1), e12=(a1,q2), e13=(a1,q3), e32=(q3,a2), e42=(q4,a2), e24=(a2, q4), e21=(a2,q1)}, T = {f1: {Q++}, f2: {M--, Q--}, f3: {M++}}, μ = {μ1, μ2, μ3, μ4}, .. μ0 = {∞, 1, 0, 1}.
  10. 10. Copyright ® 2014 VMS Lab. All rights reserved 2. How to Develop Your Own Dedicated Event Graph Simulators  This section will – Assist you in developing your own simulation programs for executing a given event graph model using the next-event scheduling algorithm – Present the process of developing a dedicated simulator for a given event graph model in a bottom-up manner  Contents 2.2 Functions for Generating Random Variates 2.3 Event Routines 2.4 Next-Event Scheduling Algorithm 2.5 Single Server System Event Graph Simulator (Psuedo code) 2.6 Implementation of the Single Server System Event Graph Simulator (C#) 2.1 Functions for Handling Events
  11. 11. Copyright ® 2014 VMS Lab. All rights reserved EVENT: E1 TIME: 12.1 2.1 Functions for Handling Events  In order to simulate the system dynamics of a discrete event system, we need a mechanism for processing future events – Future event is an event that has been scheduled to occur in the future – Next event is a future event that has the smallest (i.e. earliest) event-time – Future event list (FEL) is an ordered list of pairs ({<Ek, Tk>}), where • Tk is the scheduled execution time of the future event (Ek) • Ordered in increasing values of Tk  Event-handling functions – Schedule-event(), Retrieve-event(), and Cancel-event(). (a) Schedule-event (E4, 22.7): (b) Retrieve-event (E, T): E= E1, T= 12.1 EVENT: E1 TIME: 12.1 EVENT: E2 TIME: 18.6 FEL EVENT: E3 TIME: 34.0 (c) Cancel-event (E4): EVENT: E4 TIME: 22.7 EVENT: E2 TIME: 18.6 EVENT: E3 TIME: 34.0 FEL Initial state of FEL: EVENT: E1 TIME: 12.1 EVENT: E2 TIME: 18.6 EVENT: E3 TIME: 34.0 FEL EVENT: E4 TIME: 22.7 EVENT: E1 TIME: 12.1 EVENT: E2 TIME: 18.6 EVENT: E3 TIME: 34.0 FEL EVENT: E4 TIME: 22.7 EVENT: E2 TIME: 18.6 EVENT: E3 TIME: 34.0 FEL EVENT: E4 TIME: 22.7
  12. 12. Copyright ® 2014 VMS Lab. All rights reserved 2.2 Functions for generating Random Variates (1/2)  Generating a standard uniform random number – u ~ U[0,1] – x ~ U[a, b]  Generating an exponential random variate using inverse tranformation – The distribution function F(X) can be regarded as a uniform random number (U) • U = F(X) = 1 ex/θ, where θ is the mean and X is exponential random variate – Solve the equation for X, we can obtain • X = θ*ln(1U), which is equivalent to X = θ*ln(U). u = Math.random(); (java) Random U = new Random(); u = U.NextDouble() (c#) public double Exp(double a) { if (a<=0) return -1; double u=Math.random(); return (-a*Math.log(u)); } (java) Random U = new Random(); public double Exp(double a) { if (a<=0) return -1; double u = U.NextDouble(); return (-a*Math.Log(u));} (c#) public double Uni(double a, double b) { if (a>=b) return -1; double u=Math.random(); return (a+(b- a)*u); } (java) public double Uni(double a, double b) { if (a >= b) return -1; double u = U.NextDouble(); return (a + (b-a)*u); } (c#)
  13. 13. Copyright ® 2014 VMS Lab. All rights reserved 2.2 Functions for generating Random Variates (2/2)  Free Open Source Library for Random Variate Generation – SSJ (Stochastic Simulation in Java) • Java library for stochastic simulation, developed under the direction of Pierre L’Ecuyer, University of Montreal • http://simul.iro.umontreal.ca/ssj/indexe.html – Troschuetz.Random • C# library for providing various random number generators and distributions, developed by Stefan Troschutz • http://www.codeproject.com/articles/15102/net-random-number-generators-and-distributions • https://bitbucket.org/pomma89/troschuetz.random – On the web, you can find other libraries including commerical library that guarantees the performance and correctness.
  14. 14. Copyright ® 2014 VMS Lab. All rights reserved 2.3 Event Routines (1/2)  Portion of an event graph  Event Transition Table – tabular form of formally specifying an event graph model The above event graph indicates that “whenever E0 occurs, the state variable s changes to fE0(s). Then, if edge condition C1 is true, E1 is scheduled to occur after t1; if edge condition C2 is true, E2 is canceled immediately”. Originating Event State Change Edge Condition Action Delay Destination Event E0 s = fE0(s) 1 C1 schedule t1 E1 2 C2 cancel 0 E2 E0 {s = fE0(s)} t1 E1 E2 (C2)(C1)
  15. 15. Copyright ® 2014 VMS Lab. All rights reserved 2.3 Event Routines (2/2)  Event Routine – A subprogram that describe the 1) Changes in the state variables and 2) How the future events are scheduled and/or canceled – Event routine for the E0 event can be expressed as follows Execute-E0-event-routine (Now) { s = fE0(s); if (C1) Schedule-event (E1, Now+ t1); if (C2) Cancel-event (E2) }
  16. 16. Copyright ® 2014 VMS Lab. All rights reserved 2.4 Next Event Scheduling Algorithm for Simulation Execution (1/2)  Next event scheduling algorithm – The overall procedure will proceed the simulation clock by processing the future event in the order of the event time using the future-event handling functions (1) Initialize state variables & schedule initial events (2) Time-flow mechanism: Retrieve Next-event & update CLK (3) Execute the event-routine for the Next-event. Terminate? (4) Output statistics No FEL Event-scheduling Event-scheduling Event-retrieval (0) Reset simulation clock: CLK = 0; Yes
  17. 17. Copyright ® 2014 VMS Lab. All rights reserved 2.4 Next Event Scheduling Algorithm for Simulation Execution (2/2)  Main Program Template for the Event Graph Simulator – Implements the next event scheduling algorithm Begin CLK = 0; Execute-initialize-routine (CLK); While (CLK < te) do { Retrieve-event (EVENT,TIME); CLK =TIME; Case EVENT of { E1: Execute-E1-event-routine (CLK); E2: Execute-E2-event-routine (CLK); …. En: Execute-En-event-routine (CLK); } // end-of-case }; // end-of-while Execute-statistics-routine (CLK); End Event-routines list // (1) Initialize // (2) Time-flow mechanism // (3) Execute event-routine // (4) Output statistics
  18. 18. Copyright ® 2014 VMS Lab. All rights reserved 2.5 Single Server System Event Graph Simulator (1/6)  Process of programming a dedicated simulator  Let’s develop the event graph simulator of the single server system – EOS time (te): 500 – Inter-arrival time (ta) ~ Exp(5) – Service time: (ts) ~ Uni(4,6) Conversion to augmented event graph model • Statistics variables • Statistics routine Construction of event transition table • Tabular specification of augmented event graph model Development of routines • Initialize routine • Event routines • Statistics routine Main program • Obtained from the main program template
  19. 19. Copyright ® 2014 VMS Lab. All rights reserved 2.5 Single Server System Event Graph Simulator (2/6) 1) Conversion to augmented event graph model – Collecting the average queue length (AQL) • {Ck}: queue length change times • ∆k: kth queue length change interval (Ck+1  Ck) • Qk: queue size during ∆k • AQL = (Qk  k) / (k) ≡ SumQ / CLK – Augmented event graph model for collecting the AQL • SumQ: accumulating the queue length values over time • Before: previous event time Load Unload {SumQ += Q*(CLK−Before), Before = CLK, Q++} {M++} Arrive ts~ Uni(4,6) ta~ Exp(5)Initialize: Q=0, M=1, Before=0, SumQ=0 (Q>0) {SumQ += Q*(CLK−Before), Before = CLK, M−−, Q−−} Statistics: SumQ+= Q*(CLK–Before), AQL= SumQ / CLK (CLK>500) (M≡1) C1=3 C2=5 C9 C10 Qk 2 1 0 C3=6 C4=8 C5=9 C6=10.5 C7=12 C8=13.5
  20. 20. Copyright ® 2014 VMS Lab. All rights reserved 2.5 Single Server System Event Graph Simulator (3/6) 2) Construction of event transition table No Originating Event State Change Edge Condition Delay Destination Event 0 Initialize Q= 0; M= 1; Before=0; SumQ =0; 1 True - Arrive 1 Arrive SumQ += Q*(CLK–Before); Before= CLK; Q++; 1 True Exp(5) Arrive 2 M≡1 0 Load 2 Load SumQ += Q*(CLK–Before); Before= CLK; M−−; Q−−; 1 True Uni(4,6) Unload 3 Unload M++; 1 Q>0 0 Load 4 Statistics SumQ+= Q*(CLK–Before); AQL= SumQ/CLK Load Unload {SumQ += Q*(CLK−Before), Before = CLK, Q++} {M++} Arrive ts~ Uni(4,6) ta~ Exp(5)Initialize: Q=0, M=1, Before=0, SumQ=0 (Q>0) {SumQ += Q*(CLK−Before), Before = CLK, M−−, Q−−} Statistics: SumQ+= Q*(CLK–Before), AQL= SumQ / CLK (CLK>500) (M≡1)
  21. 21. Copyright ® 2014 VMS Lab. All rights reserved 2.5 Single Server System Event Graph Simulator (4/6) 3) Development of routines No Originating Event State Change Edge Condition Delay Destination Event 0 Initialize Q= 0; M= 1; Before=0; SumQ =0; 1 True - Arrive 1 Arrive SumQ += Q*(CLK–Before); Before= CLK; Q++; 1 True Exp(5) Arrive 2 M≡1 0 Load 2 Load SumQ += Q*(CLK–Before); Before= CLK; M−−; Q−−; 1 True Uni(4,6) Unload 3 Unload M++; 1 Q>0 0 Load 4 Statistics SumQ+= Q*(CLK–Before); AQL= SumQ/CLK Execute-Initialize-routine (Now) { Q = 0; M = 1; Before = 0; SumQ = 0; Schedule-event (Arrive, Now); } Execute-statistics-routine (Now) { SumQ += Q*(Now – Before); AQL = SumQ / Now; } Execute-Arrive-event-routine (Now) { SumQ += Q*(Now – Before); Before = Now; Q++; Schedule-event (Arrive, Now+ Exp (5)); if (M≡1) Schedule-event (Load, Now); } Execute-Load-event-routine (Now) { SumQ += Q*(Now – Before); Before = Now; M--; Q--; Schedule-event (Unload, Now+ Uni (4, 6)); } Execute-Unload-event-routine (Now) { M++; if (Q>0) Schedule-event (Load, Now);
  22. 22. Copyright ® 2014 VMS Lab. All rights reserved 2.5 Single Server System Event Graph Simulator (4/6) 4) Main program No Originating Event State Change Edge Condition Delay Destination Event 0 Initialize Q= 0; M= 1; Before=0; SumQ =0; 1 True - Arrive 1 Arrive SumQ += Q*(CLK–Before); Before= CLK; Q++; 1 True Exp(5) Arrive 2 M≡1 0 Load 2 Load SumQ += Q*(CLK–Before); Before= CLK; M−−; Q−−; 1 True Uni(4,6) Unload 3 Unload M++; 1 Q>0 0 Load 4 Statistics SumQ+= Q*(CLK–Before); AQL= SumQ/CLK Begin CLK = 0; Execute-initialize-routine (CLK); While (CLK < 500) do { // te = 500 Retrieve-event (EVENT,TIME); CLK =TIME; Case EVENT of { Arrive: Execute-Arrive-event-routine (CLK); Load: Execute-Load-event-routine (CLK); Unload: Execute-Unload-event-routine (CLK); } // end-of-case }; // end-of-while Execute-statistics-routine (CLK); End
  23. 23. Copyright ® 2014 VMS Lab. All rights reserved 2.5 Single Server System Event Graph Simulator (5/6)  Single Server System with Resource Failure – tf: inter-failure time – tr: repair time – Revised and added routines No O.E. State Change Edge Cond. Action Delay D.E. 0 Initialize Q=0; M=1; Before=0; SumQ=0; 1 True schedule 0 Arrive 2 True schedule tf Fail 1 Arrive SumQ+=Q*(CLK−Before); Before=CLK; Q++ 1 True schedule ta Arrive 2 M≡1 schedule 0 Load 2 Load SumQ+=Q*(CLK−Before); Before=CLK; M−−; Q−−; 1 True schedule ts Unload 3 Unload M++; 1 Q>0 schedule 0 Load 4 Repair M=1; 1 True schedule tf Fail 2 Q>0 schedule 0 Load 5 Fail M=−1; 1 True schedule tr Repair 2 True cancel 0 Unload 6 Statistics SumQ+= Q*(CLK−Before); AQL= SumQ/CLK; (a) Event graph model (b) Augmented event transition table Load Unload {Q++} {M−−, Q−−} {M++} (M≡1) (Q>0) Arrive ts ta Repair Fail {M=1} {M=−1} (Q>0) tf tf tr Execute-Initialize-routine (Now) { Q= 0; M= 1; Before= 0; SumQ= 0; Schedule-event (Arrive, Now); Schedule-event (Fail, Now + tf); } Execute-Repair-event-routine (Now) { M= 1; Schedule-event (Fail, Now + tf); if (Q>0) Schedule-event (Load, Now); } Execute-Fail-event-routine (Now) { M= −1; Schedule-event (Repair, Now + tr); Cancel-event (Unload); }
  24. 24. Copyright ® 2014 VMS Lab. All rights reserved 2.6 C# Implementation of the Single Server System Event Graph Simlator  Class Diagram Event class presents the next event • Name: event name • Time: scheduled event time EventList class contains • Methods for manipulating the FEL Simulator class contains methods for • Main program: Run • Initialize routine: Execute_Initialize_Routine • Three event routines • Statistics routine: Execute_Statistics_routine • Event-handling functions: Retrieve_Event, Schedule_Event • Random variate generators: Exp, Uni Simulator class contains member variables for • State variables: M, Q • Simulation clock: CLK • Statistics variables: SumQ, Before, AQL • Random number variable: U • Event-list variable: FEL
  25. 25. Copyright ® 2014 VMS Lab. All rights reserved 2.6 C# Implementation of the Single Server System Event Graph Simlator  Source Code for the Main Program public void Run(double eosTime) { //1. Initialization phase CLK = 0.0; FEL = new EventList(); U = new Random(); Event nextEvent = null; Execute_Initialize_routine(CLK); while (CLK < eosTime) { //2. Time-flow mechanism phase nextEvent = Retrieve_Event(); CLK = nextEvent.Time; //3. Event-routine execution phase switch(nextEvent.Name) { case "Arrive": { Execute_Arrive_event_routine(CLK);break; } case "Load": { Execute_Load_event_routine(CLK);break; } case "Unload": { Execute_Unload_event_routine(CLK);break; } } } //4. Statistics collection phase Execute_Statistics_routine(CLK); }
  26. 26. Copyright ® 2014 VMS Lab. All rights reserved 3. How to Develop Your Own Dedicated ACD Simulators  This section will – Assist you in developing your own simulation programs for executing a given ACD model using the activity scanning algorithm – Present the process of developing a dedicated simulator for a given ACD in a bottom-up manner  Contents 3.2 Activity Routines and Event Routines 3.3 Activity Scanning Algorithm 3.4 Single Server System ACD Simulator (Psuedo code) 3.5 Implementation of the Single Server System ACD Simulator (C#) 3.1 Functions for Handling Activities
  27. 27. Copyright ® 2014 VMS Lab. All rights reserved 3.1 Functions for Handling Activities  Candidate Activity List (CAL) – A first-in-first-out (FIFO) queue is used to handle the candidate (or influenced) activities in the simulation executions of ACD models  Activity-handling functions – Store-activity() and Get-activity() A1 A2 A3CAL A4 A2 A4CAL A3 (a) Store-activity (A4): (b) Get-activity (A): A= A1 A1 Initial state of CAL: A1 A2 A3CAL A4
  28. 28. Copyright ® 2014 VMS Lab. All rights reserved 3.2 Activity Routines and Event Routines (1/3)  An activity is confined by two events 1) Activity-begin event • Once this event occurs, the activity-end event is bound to occur after the time delay of the activity duration • This event is often referred to as ‘conditional’event 2) Activity-end event (or bound-to-occur event: BTO event) • This event is often referred to as ‘bound’event  Execution rules of an activity S1 • Q1 A1 <t1> Q2 A2 <t2> A3 <t3> (1) At-begin execution rules of activity A1: “If the number of tokens in input queue Q1 is at least one and if there is at least one token in queue S1, then the A1 activity will begin after de-queuing one token from Q1 and one token from S1, and its BTO event E1 is scheduled to occur after the activity duration (t1).” (2) At-end execution rules of activity A1: “one token is created and en-queued into output queue Q2 and a token is returned to queue S1. Then, the influenced activities A2 and A3 are examined for execution”
  29. 29. Copyright ® 2014 VMS Lab. All rights reserved 3.2 Activity Routines and Event Routines (2/3)  Activity Transition Table (ATT) – Formal specification of the ACD model in a tabular form (Kang and Choi 2010) No Activity At-begin BTO-event At-end Condition Action Time Name Arc Condition Action Influenced Activity 1 A1 (Q1>0) & (S1>0) Q1−−; S1−−; t1 E1 1 True S1++; A1 2 True Q2++; A2, A3 2 A2 … 3 A3 … S1 • Q1 A1 <t1> Q2 A2 <t2> A3 <t3> <ACD> <ATT>
  30. 30. Copyright ® 2014 VMS Lab. All rights reserved Execute-A1-activity-routine (Clock) { } Execute-E1-event-routine (t) { } 3.2 Activity Routines and Event Routines (3/3)  Execution of an activity (1) Activity routine: at-begin execution (2) Event routine: at-end execution subprogram that describes the changes in the state variables made at the beginning of an activity and schedules its BTO event into the FEL subprogram that describes the changes in the state variables made at the beginning of an activity and schedules its BTO event E1 into the FEL If (At-begin Condition) { At-begin Action; Schedule-event ( Event Name, Clock + Event Time); } For each At-end arc { If (At-end Condition) { At-end Action; Store-activity (Influenced Activity); } } No Activity At-begin BTO-event At-end Condition Action Time Name Arc Condition Action Influenced Activity 1 A1 (Q1>0) & (S1>0) Q1−−; S1−−; t1 E1 1 True S1++; A1 2 True Q2++; A2, A3 if ((Q1>0) & (S1>0)) { Q1--; S1--; Schedule-event (E1, Clock+t1); } S1++; Store-activity (A1); Q2++; Store-activity (A2); Store-activity (A3); Similarity with event graph - Changes in the state variables are described Difference with event graph - Stores the influenced activities into CAL instead of scheduling or canceling future events into the FEL
  31. 31. Copyright ® 2014 VMS Lab. All rights reserved 3.3 Activity Scanning Algorithm (1/3)  Tocher’s three-phase process (Hollocks 2008) • Phase A (Timing): Advance the clock to the time of the next bound-to-occur (BTO) event. • Phase B (Execution): Execute the BTO event. • Phase C (Scanning): Initiate conditioned activities that the conditions in the model permit. Advance time to next event A BCInitiate ‘conditioned’ activities Process BTO-event
  32. 32. Copyright ® 2014 VMS Lab. All rights reserved 3.3 Activity Scanning Algorithm (2/3)  Activity scanning algorithm – Benefits of adopting CAL • assists in Phase C of the three-phase process through reducing the number of activities to scan for the execution • Allows the management of tie-breaking among the concurrent activities
  33. 33. Copyright ® 2014 VMS Lab. All rights reserved 3.3 Activity Scanning Algorithm (3/3)  Main Program Template for the ACD Simulator – Implements the activity scanning algorithm Begin CLK= 0; Execute-initialize-routine(CLK); do { while (CAL is not empty) { ACTIVITY = Get-activity(); Case ACTIVITY of { A1: Execute-A1-activity-routine (CLK); A2: Execute-A2-activity-routine (CLK); … An: Execute-An-activity-routine (CLK); } // end-of-case } //end-of-while Retrieve-event (EVENT, TIME); CLK =TIME; Case EVENT of { E1: Execute-E1-event-routine (CLK); E2: Execute-E2-event-routine (CLK); … En: Execute-En-event-routine (CLK); } // end-of-case } while (CLK < te); Execute-statistics-routine(CLK); End Activity-routines list Event-routines list // (1) Initialize // (2) Scanning phase // (3) timing phase // (4) Executing phase // (5) Output statistics
  34. 34. Copyright ® 2014 VMS Lab. All rights reserved 3.4 Single Server System ACD Simulator (1/5)  Process of programming a dedicated simulator  Let’s develop the ACD simulator of the single server system – EOS time (te): 500 – Inter-arrival time (ta) ~ Exp(5) – Service time: (ts) ~ Uni(4,6) Conversion to augmented ACD model • Statistics variables • Statistics routine Construction of activity transition table • Tabular specification of augmented ACD model Development of routines • Initialize routine • Activity/Event routines • Statistics routine Main program • Obtained from the main program template
  35. 35. Copyright ® 2014 VMS Lab. All rights reserved 3.4 Single Server System ACD Simulator (2/5) 1) Conversion to augmented ACD model – Introducing two statistics variables • SumQ: accumulating the queue length values over time • Before: previous event time – Collecting the queue length change times • At-begin actions of Create and Process activities are modified – Augmented ACD model for collecting the AQL C • M • Jobs ∞ QCreate <Exp(5)> Process <Uni(4,6)> Statistics: SumQ+= Q*(CLK–Before), AQL= SumQ/CLK (CLK>500) Initialize: C=1, Q=0, M=1, Before=0, SumQ=0 E1, E2: {SumQ += Q*(CLK−Before), Before = CLK} {E1} {E2}
  36. 36. Copyright ® 2014 VMS Lab. All rights reserved 3.4 Single Server System ACD Simulator (3/5) 2) Construction of activity transition table C • M • Jobs ∞ QCreate <Exp(5)> Process <Uni(4,6)> Statistics: SumQ+= Q*(CLK–Before), AQL= SumQ/CLK (CLK>500) Initialize: C=1, Q=0, M=1, Before=0, SumQ=0 E1, E2: {SumQ += Q*(CLK−Before), Before = CLK} {E1} {E2} No Activity At-begin BTO-event At-end Condition Action Time Name Arc Condition Action Influenced Activity 1 Create (C>0) C−−; Exp(5) Created 1 True C++; Create 2 True SumQ+=Q*(CLK-Before); Before=CLK; Q++; Process 2 Process (M>0) & (Q>0) SumQ+=Q*(CLK-Before); Before=CLK; M−−; Q−−; Uni(4,6) Processed 1 True M++; Process Initialize Initial Marking = {C=1, M=1, Q=0}; Enabled Activities = {Create}; Statistics Variables = {SumQ=Before=0} Statistics SumQ+=Q*(CLK-Before); AQL=SumQ/CLK;
  37. 37. Copyright ® 2014 VMS Lab. All rights reserved 3.4 Single Server System ACD Simulator (4/5) 3) Development of routines Execute-Initialize-routine (Now) { C = 1; M = 1; Q = 0; SumQ = 0 ; Before = 0; Store-activity (Create); } Execute-Create-activity-routine (Now) { if (C > 0) { C−−; Schedule-event (Created, Now + Exp(5)); } } Execute-Process-activity-routine (Now) { if ((M>0) & (Q>0)) { SumQ+=Q*(Now - Before); Before= Now; M--; Q--; Schedule-event (Processed, Now + Uni(4,6)); } } Execute-Created-event-routine (Now) { if (True) { C++; Store-activity (Create); } if (True) { SumQ+=Q*(Now − Before); Before=Now; Q++; Store-activity (Process); } } Execute-Processed-event-routine (Now) { if (True) { M++; Store-activity (Process); } } Execute-statistics-routine (Now) { SumQ += Q*(Now – Before); AQL = SumQ / Now; }
  38. 38. Copyright ® 2014 VMS Lab. All rights reserved 3.4 Single Server System ACD Simulator (5/5) 4) Main program Begin CLK= 0; Execute-initialize-routine(CLK); do { while (CAL is not empty) { ACTIVITY = Get-activity(); Case ACTIVITY of { Create: Execute-Create-activity-routine (CLK); Process: Execute-Process-activity-routine (CLK); } // end-of-case } //end-of-while Retrieve-event (EVENT,TIME); CLK =TIME; Case EVENT of { Created: Execute-Created-event-routine (CLK); Processed: Execute-Processed-event-routine (CLK); } // end-of-case } while (CLK < 500); Execute-statistics-routine(CLK); End
  39. 39. Copyright ® 2014 VMS Lab. All rights reserved 3.5 C# Implementation of the Single Server System ACD Simulator  Class Diagram Activity class: - candidate (or influecned) activity ActivityList class: Contains methods for manipulating the CAL
  40. 40. Copyright ® 2014 VMS Lab. All rights reserved 3.5 C# Implementation of the Single Server System ACD Simulator  Source Code for the Main Program public void Run(double eosTime) { //1. Initialization Phase Clock = 0; FEL = new EventList(); R = new Random(); CAL = new ActivityList(); Event nextEvent = null; Execute_Initialize_routine(Clock); do { //2. Scanning Phase while (!CAL.IsEmpty()) { string ACTIVITY = Get_Activity(); switch (ACTIVITY) { case "Create": {Execute_Create_activity_routine(Clock);break;} case "Process":{Execute_Process_activity_routine(Clock);break;}}} //3. Timing phase nextEvent = Retrieve_Event(); Clock = nextEvent.Time; //4. Executing phase switch (nextEvent.Name) { case "Created": {Execute_Created_event_routine(); break;} case "Processed":{Execute_Processed_event_routine(); break;}} } while (Clock < eosTime); //5. Statistics collection phase Execute_Statistics_routine(CLK); }
  41. 41. Copyright ® 2014 VMS Lab. All rights reserved 4. A General Purpose ACD Executor: ACE® (1/3)  Activity Cycle Executor: ACE® – The only tool that can exceute ACD models – Use of a formal model as its input in the form of an activity transition table Main Menu Activity Transition Table (ATT) Window Spreadsheet Window ATT Tool Bar Queue Tool Bar Queue Tool Bar
  42. 42. Copyright ® 2014 VMS Lab. All rights reserved 4. A General Purpose ACD Executor: ACE® (2/3)  Components of ACE® – GUI components • ATT Editor – Constructs an activity transition table, stored in ATT model – ATT model consists of a set of queues, a set of variables, and a set of activity transitions • Run Options Editor – Specity the EOS time, random number seed, other options for data collection • Output Report Viewer – Provide the system trajectories and statistics with regard to the resources and queues ATT Editor ATT model ATT Simulator Run Options Editor Output Report Generator Output Report Viewer Output Report Data Model File (XML) Collected Output Data Run Options
  43. 43. Copyright ® 2014 VMS Lab. All rights reserved 4. A General Purpose ACD Executor: ACE® (3/3)  Components of ACE® – Library components • ATT Simulator Library – Implement the activity scanning algorithm » CLK, FEL, CAL, Queues, activity routines, event routines, and main program – Activity/event routines and main program of the ATT simulator are automatically constructed from the given ATT model with the specified run options • Output Report Generator Library – Collect the output data using the Publish-Subscribe mechanism of the observer software design pattern (Gamma 1994) » Simulation events are published whenver changes in the system states are made » The observer collects these simulation events and stores them in the collected output data » The collected output data are transformed into the an output report data (KPI with system trajectories) ATT Editor ATT model ATT Simulator Run Options Editor Output Report Generator Output Report Viewer Output Report Data Model File (XML) Collected Output Data Run Options
  44. 44. Copyright ® 2014 VMS Lab. All rights reserved 5. Summary  What we have explained – How to develop dedicated simulators for executing • event graph models and • activity cycle diagram (ACD) models  What we have presented – Event-graph simulator template and its implementation • based on Next-event scheduling algorithm – ACD simulator template and its implementation • Based on Activity scanning algorithm – Activity Cycle Executor (ACE) • a generator-purpose simulator for executing ACD models
  45. 45. Copyright ® 2014 VMS Lab. All rights reserved Donghun Kang Postdoctoral Researcher ISysE Dept., KAIST donghun.kang@kaist.ac.kr Thank you Inquiry: Acknowledgements: The tutorial was supported in part by VMS-Solutions Co., Ltd., for which the authors are grateful. Download: http://www.vms-technology.com/book/msdestutorial/

×