event lists
play

Event Lists Refs: Sections 2.2 and 2.8 in Law, Section 5.3 in - PowerPoint PPT Presentation

Event Lists Refs: Sections 2.2 and 2.8 in Law, Section 5.3 in Leemis and Park Peter J. Haas CS 590M: Simulation Spring Semester 2020 1 / 9 Event Lists Overview Linked Lists Heaps Hybrid Data Structures 2 / 9 Event Lists (aka Pending


  1. Event Lists Refs: Sections 2.2 and 2.8 in Law, Section 5.3 in Leemis and Park Peter J. Haas CS 590M: Simulation Spring Semester 2020 1 / 9

  2. Event Lists Overview Linked Lists Heaps Hybrid Data Structures 2 / 9

  3. Event Lists (aka Pending Event Sets) Fetch-next, insert, and cancel operations I Fundamental operations in discrete-event simulations (up to 40% of sim time) I So far we have used clock-reading vectors I For M events, it takes O ( M ) time to get next event I Unsuitable for large-scale simulation Alternative: event lists I For GSMP’s with unit speeds I Idea: Maintain list of (event type, event time) pairs I event time = (absolute) time when event is scheduled to occur I Challenge: support operations e ffi ciently (priority queue with removals) 3 / 9

  4. ⇐ Linked Lists Goal: Maintain events in sorted order I Singly-linked lists ÷ head tail 20.3 23.7 34.0 I fetch-next is O (1), insert and cancel are O ( M ) I Doubly-linked lists head tail . 20.3 23.7 34.0 4 / 9

  5. Linked Lists, Continued I Indexed doubly-linked lists head tail 20.3 23.7 34.0 23.7 I Faster lookup I Need to maintain median element I Cost outweighs benefit for more than one index 5 / 9

  6. Implicit Binary Heaps Binary tree that maintains min-heap property I Parent has smaller value than children I Can store e ffi ciently as an array I Fetch-next is O (1) plus an O (log M ) update 1.6 2.3 3.1 2.5 2.3 2.5 2.3 2.5 3.1 3.7 2.9 4.2 3.1 3.7 2.9 4.2 3.7 2.9 4.2 6 / 9

  7. Heaps, Continued I Insert is O (log M ) 2.3 2.3 2.1 2.5 3.1 2.5 2.1 2.5 2.3 3.7 2.9 4.2 2.1 3.7 2.9 4.2 3.1 3.7 2.9 4.2 3.1 I Cancellation is O ( M ) search + O (log M ) update I Python solution for O (1) cancellation 2.1 I Use heapq to implement heap I Use a dict for O (1) find 2.5 2.3 I Mark event as ”canceled ”and I Ignore cancelled events upon fetch I OK if not too many cancellations 3.7 2.9 4.2 3.1 I See code on website "e1" "e2" "e3" "e4" "e5" "e6" "e7" 7 / 9

  8. Hybrid Data Structures Bucket System I Event time “hashes” to a bucket ... 1-10 10-20 20-30 80-90 overflow I Recycle buckets when they become empty 1.3 12.6 24.0 87.2 230.1 Henriksen’s algorithm I Used in many 5.8 17.7 28.2 early commercial systems I Combines binary search tree 7.2 19.3 with doubly-linked list I Can have bad worst-case behavior 8 / 9

  9. Hybrid Data Structures, Continued Lazy Queue [Ronngren et al. 1991] I Three parts: I Near Future (NF): a sorted linked list I Far Future (FF): an unsorted bucket system I Very Far Future (VFF): an unsorted linked list I Sorting only happens when FF NF FF VFF bucket is moved to NF 0-1 1-2 2-3 3-4 4-5 5-6 > 6 I Occasional adaptive resizing of # and length of buckets I Dominates most other event list schemes for > 50 events sorted unsorted 9 / 9

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend