SlideShare a Scribd company logo
1 of 21
BEST PRACTICES IN DISCRETE-
EVENT SIMULATION
CARLOS NATALINO
2020-03-01 Chalmers University of Technology 2
OUTLINE
• Introduction
• Performance analysis
• Discrete-event simulation
• Routing and resource assignment in optical networks
• Implementation details
• Best practices
• Examples in Java and Python
• Conclusions
• Q&A
• Performance analysis
2020-03-01 Chalmers University of Technology 3
DISCRETE-EVENT SIMULATION
Analytic Simulation Prototyping
Realistic
Expensive
Prone to contamination
Set of equations
e.g.: queue theory
Set of events described by random numbers
e.g.: event-driven simulation
Real systems and devices
e.g.: testbed
2020-03-01 Chalmers University of Technology 4
DISCRETE-EVENT SIMULATION
• Environment
• Models the set of elements that the simulation is interested in
analyzing
• Discrete sequence of events in time
• Each event changes (or may change) the state of the
environment
• No changes between two consecutive events
• Next-time event progression: time between events may vary
(e.g., arrival/departure of requests)
• Fixed-increment time progression: time between events is
fixed (e.g., periodic reconfiguration)
2020-03-01 Chalmers University of Technology 5
DISCRETE-EVENT SIMULATION
• Main components:
• State: the environment state at a given point in time
• Clock: the current simulation clock, which is not tied to the wall
clock
• Event list: the list with the next events to be processed/executed
• Events: set of (problem-specific) procedures to be executed
over the environment
Event list
Simulation
clock
2020-03-01 Chalmers University of Technology 6
EVENT-DRIVEN SIMULATION
Examples of environments and their events
1. Bank queue
• Productor-consumer kind of problem
• Clients arrive, cashiers serve the clients
• Queue theory can be used for analytic assessment
2. Public transportation
• Passengers boarding/dropping at stops, vehicle speed change, etc.
3. Virus outbreak
• Contact probability between people, contamination probability, etc.
4. Networks
• Packet-based: packet arrival, enqueue, dequeue, departure
• Circuit-based: call arrival, call departure, etc.
2020-03-01 Chalmers University of Technology 7
ROUTING AND SPEC. ALLOC. IN OPTICAL NETWORKS
• Circuit-switched network
• Discrete resource allocation
• Wavelength division multiplexing
(WDM)
• Single-wavelength channels
• With wavelength conversion (opaque)
• No wavelength continuity constraint
• Without wavelength conversion (transparent)
• Elastic optical network (EON)
• Multiple-slice channels
• Spectrum continuity and contiguity constraint
Link A Link B Link C Link D Link E
S1
S2
S3
S4
Link A Link B Link C Link D Link E
S1
S2
S3
S4
Link A Link B Link C Link D Link E
S1
S2
S3
S4
2020-03-01 Chalmers University of Technology 8
IMPLEMENTATION DETAILS
State
• Can be modeled as a class
• Attributes of the class model the state of the environment
https://github.com/carlosnatalino/python-simple-anycast-wdm-simulator/blob/cdb1340234cad0217fc7687abcadb1a3f35c8522/core.py#L12
Python
Java
https://github.com/carlosnatalino/java-anycast-cs-simulator/blob/065e0726ffe7e7146616d5347b90c7da21bbf851/src/main/java/simulator/cs/anycast/components/Topology.java#L21
2020-03-01 Chalmers University of Technology 9
IMPLEMENTATION DETAILS
Event list
• Should be implemented as an ordered list
https://github.com/carlosnatalino/python-simple-anycast-wdm-simulator/blob/cdb1340234cad0217fc7687abcadb1a3f35c8522/core.py#L219
Python
Java
https://github.com/carlosnatalino/java-anycast-cs-simulator/blob/065e0726ffe7e7146616d5347b90c7da21bbf851/src/main/java/simulator/cs/anycast/core/Simulator.java#L27
2020-03-01 Chalmers University of Technology 10
IMPLEMENTATION DETAILS
Events
• Create a standard event model
https://github.com/carlosnatalino/python-simple-anycast-wdm-simulator/blob/cdb1340234cad0217fc7687abcadb1a3f35c8522/events.py#L6
Python
Java
https://github.com/carlosnatalino/java-anycast-cs-simulator/blob/065e0726ffe7e7146616d5347b90c7da21bbf851/src/main/java/simulator/cs/anycast/events/Event.java#L11
https://github.com/carlosnatalino/java-anycast-cs-simulator/blob/065e0726ffe7e7146616d5347b90c7da21bbf851/src/main/java/simulator/cs/anycast/events/ActiveProcess.java#L12
2020-03-01 Chalmers University of Technology 11
IMPLEMENTATION DETAILS
Events
• Create a standard event model and use it
https://github.com/carlosnatalino/python-simple-anycast-wdm-simulator/blob/cdb1340234cad0217fc7687abcadb1a3f35c8522/core.py#L318
Python
Java
https://github.com/carlosnatalino/java-anycast-cs-simulator/blob/065e0726ffe7e7146616d5347b90c7da21bbf851/src/main/java/simulator/cs/anycast/core/Simulator.java#L86
2020-03-01 Chalmers University of Technology 12
BEST PRACTICES
Never overwrite files
• Have a base folder for all results of a given batch
• Create a timestamp’d folder for the results of every run
https://github.com/carlosnatalino/python-simple-anycast-wdm-simulator/blob/cdb1340234cad0217fc7687abcadb1a3f35c8522/run.py#L37 https://github.com/carlosnatalino/java-anycast-cs-simulator/blob/065e0726ffe7e7146616d5347b90c7da21bbf851/src/main/java/simulator/cs/anycast/core/MultiThreadSimulator.java#L94
Python
Java
2020-03-01 Chalmers University of Technology 13
BEST PRACTICES
Have file- or argument-based configuration
• Prevents you from recompiling the code
https://github.com/carlosnatalino/python-simple-anycast-wdm-simulator/blob/cdb1340234cad0217fc7687abcadb1a3f35c8522/run.py#L137 https://github.com/carlosnatalino/java-anycast-cs-simulator/blob/065e0726ffe7e7146616d5347b90c7da21bbf851/src/main/java/simulator/cs/anycast/core/FileAgent.java#L89
Python
Java
2020-03-01 Chalmers University of Technology 14
BEST PRACTICES
Bonus: make a copy of the configurations for every result
https://github.com/carlosnatalino/python-simple-anycast-wdm-simulator/blob/cdb1340234cad0217fc7687abcadb1a3f35c8522/run.py#L45 https://github.com/carlosnatalino/java-anycast-cs-simulator/blob/065e0726ffe7e7146616d5347b90c7da21bbf851/src/main/java/simulator/cs/anycast/core/MultiThreadSimulator.java#L104
Python
Java
2020-03-01 Chalmers University of Technology 15
BEST PRACTICES
Bonus 2: make a copy of the current simulator version
https://github.com/carlosnatalino/python-simple-anycast-wdm-simulator/blob/cdb1340234cad0217fc7687abcadb1a3f35c8522/run.py#L59 https://github.com/carlosnatalino/java-anycast-cs-simulator/blob/065e0726ffe7e7146616d5347b90c7da21bbf851/src/main/java/simulator/cs/anycast/core/MultiThreadSimulator.java#L120
Python
Java
2020-03-01 Chalmers University of Technology 16
BEST PRACTICES
x. Only enqueue events when needed
https://github.com/carlosnatalino/python-simple-anycast-wdm-simulator/blob/cdb1340234cad0217fc7687abcadb1a3f35c8522/events.py#L17 https://github.com/carlosnatalino/java-anycast-cs-simulator/blob/065e0726ffe7e7146616d5347b90c7da21bbf851/src/main/java/simulator/cs/anycast/events/ConnectionManager.java#L104
Python
Java
2020-03-01 Chalmers University of Technology 17
BEST PRACTICES
Run different configurations in threads
• Single environment can/should not be parallelized
• Multiple environments can/should be parallelized
• Use of thread pool is recommended (improves resource efficiency)
https://github.com/carlosnatalino/python-simple-anycast-wdm-simulator/blob/cdb1340234cad0217fc7687abcadb1a3f35c8522/run.py#L93 https://github.com/carlosnatalino/java-anycast-cs-simulator/blob/065e0726ffe7e7146616d5347b90c7da21bbf851/src/main/java/simulator/cs/anycast/core/MultiThreadSimulator.java#L131
https://github.com/carlosnatalino/java-anycast-cs-simulator/blob/065e0726ffe7e7146616d5347b90c7da21bbf851/src/main/java/simulator/cs/anycast/core/MultiThreadSimulator.java#L152
Python
Java
2020-03-01 Chalmers University of Technology 18
BEST PRACTICES
Save averages and individual results
• Bonus: save everything possible
https://github.com/carlosnatalino/python-simple-anycast-wdm-simulator/blob/cdb1340234cad0217fc7687abcadb1a3f35c8522/core.py#L325
https://github.com/carlosnatalino/python-simple-anycast-wdm-simulator/blob/cdb1340234cad0217fc7687abcadb1a3f35c8522/run.py#L113
https://github.com/carlosnatalino/java-anycast-cs-simulator/blob/065e0726ffe7e7146616d5347b90c7da21bbf851/src/main/java/simulator/cs/anycast/core/Simulator.java#L100
https://github.com/carlosnatalino/java-anycast-cs-simulator/blob/065e0726ffe7e7146616d5347b90c7da21bbf851/src/main/java/simulator/cs/anycast/core/Simulator.java#L122
Python
Java
2020-03-01 Chalmers University of Technology 19
BEST PRACTICES
Plot results as you go
• Helps identifying problems before everything runs
https://github.com/carlosnatalino/python-simple-anycast-wdm-simulator/blob/cdb1340234cad0217fc7687abcadb1a3f35c8522/run.py#L103 https://github.com/carlosnatalino/java-anycast-cs-simulator/blob/bbede8fabadcc8c8c96542af469c7334e3ba1a67/src/main/java/simulator/cs/anycast/core/MultiThreadSimulator.java#L174
Python
Java
2020-03-01 Chalmers University of Technology 20
CONCLUSIONS AND LINKS
• Simulations are a good compromise between cost, time and
adherence to reality
• Java and Python are both great options to implement your simulator
• Good trade-off between development complexity and runtime efficiency
• C3SE offers computing power to run your simulations
• Versions used in this presentation:
• Python version: https://github.com/carlosnatalino/python-simple-anycast-
wdm-simulator
• Java version: https://github.com/carlosnatalino/java-anycast-cs-simulator/
• Presentation available at:
https://www.slideshare.net/CarlosNatalinoSilva/discreteevent-simulation-
best-practices-and-implementation-details-in-python-and-java
Discrete-event simulation: best practices and implementation details in Python and Java

More Related Content

Similar to Discrete-event simulation: best practices and implementation details in Python and Java

Future services on Janet
Future services on JanetFuture services on Janet
Future services on JanetJisc
 
Implementation ans analysis_of_quic_for_mqtt
Implementation ans analysis_of_quic_for_mqttImplementation ans analysis_of_quic_for_mqtt
Implementation ans analysis_of_quic_for_mqttPuneet Kumar
 
Huawei Advanced Data Science With Spark Streaming
Huawei Advanced Data Science With Spark StreamingHuawei Advanced Data Science With Spark Streaming
Huawei Advanced Data Science With Spark StreamingJen Aman
 
Practical Routers & Switches for Electrical Engineers
Practical Routers & Switches for Electrical EngineersPractical Routers & Switches for Electrical Engineers
Practical Routers & Switches for Electrical EngineersLiving Online
 
Data Wrangling For Kaggle Data Science Competitions
Data Wrangling For Kaggle Data Science CompetitionsData Wrangling For Kaggle Data Science Competitions
Data Wrangling For Kaggle Data Science CompetitionsKrishna Sankar
 
Advancing VLSI Design Reliability: A Comprehensive Examination of Embedded De...
Advancing VLSI Design Reliability: A Comprehensive Examination of Embedded De...Advancing VLSI Design Reliability: A Comprehensive Examination of Embedded De...
Advancing VLSI Design Reliability: A Comprehensive Examination of Embedded De...IRJET Journal
 
Sta by usha_mehta
Sta by usha_mehtaSta by usha_mehta
Sta by usha_mehtaUsha Mehta
 
SHREYA_CISCO.pptx
SHREYA_CISCO.pptxSHREYA_CISCO.pptx
SHREYA_CISCO.pptxAkttripathi
 
Automatic Analyzing System for Packet Testing and Fault Mapping
Automatic Analyzing System for Packet Testing and Fault MappingAutomatic Analyzing System for Packet Testing and Fault Mapping
Automatic Analyzing System for Packet Testing and Fault MappingIRJET Journal
 
System on Chip
System on ChipSystem on Chip
System on ChipSwamy T N
 
Timing verification of real-time automotive Ethernet networks: what can we ex...
Timing verification of real-time automotive Ethernet networks: what can we ex...Timing verification of real-time automotive Ethernet networks: what can we ex...
Timing verification of real-time automotive Ethernet networks: what can we ex...RealTime-at-Work (RTaW)
 
The ACTION Project: Applications Coordinate with Transport, IP and Optical Ne...
The ACTION Project: Applications Coordinate with Transport, IP and Optical Ne...The ACTION Project: Applications Coordinate with Transport, IP and Optical Ne...
The ACTION Project: Applications Coordinate with Transport, IP and Optical Ne...CPqD
 
NoC simulators presentation
NoC simulators presentationNoC simulators presentation
NoC simulators presentationHossam Hassan
 
|QAB> : Quantum Computing, AI and Blockchain
|QAB> : Quantum Computing, AI and Blockchain|QAB> : Quantum Computing, AI and Blockchain
|QAB> : Quantum Computing, AI and BlockchainKan Yuenyong
 
Enabling Cloud Storage Auditing with Key Exposure Resistance
Enabling Cloud Storage Auditing with Key Exposure ResistanceEnabling Cloud Storage Auditing with Key Exposure Resistance
Enabling Cloud Storage Auditing with Key Exposure ResistanceIRJET Journal
 
Cloud data management
Cloud data managementCloud data management
Cloud data managementambitlick
 
Automating Speed: A Proven Approach to Preventing Performance Regressions in ...
Automating Speed: A Proven Approach to Preventing Performance Regressions in ...Automating Speed: A Proven Approach to Preventing Performance Regressions in ...
Automating Speed: A Proven Approach to Preventing Performance Regressions in ...HostedbyConfluent
 

Similar to Discrete-event simulation: best practices and implementation details in Python and Java (20)

Future services on Janet
Future services on JanetFuture services on Janet
Future services on Janet
 
Implementation ans analysis_of_quic_for_mqtt
Implementation ans analysis_of_quic_for_mqttImplementation ans analysis_of_quic_for_mqtt
Implementation ans analysis_of_quic_for_mqtt
 
Huawei Advanced Data Science With Spark Streaming
Huawei Advanced Data Science With Spark StreamingHuawei Advanced Data Science With Spark Streaming
Huawei Advanced Data Science With Spark Streaming
 
Practical Routers & Switches for Electrical Engineers
Practical Routers & Switches for Electrical EngineersPractical Routers & Switches for Electrical Engineers
Practical Routers & Switches for Electrical Engineers
 
Soc.pptx
Soc.pptxSoc.pptx
Soc.pptx
 
Data Wrangling For Kaggle Data Science Competitions
Data Wrangling For Kaggle Data Science CompetitionsData Wrangling For Kaggle Data Science Competitions
Data Wrangling For Kaggle Data Science Competitions
 
Advancing VLSI Design Reliability: A Comprehensive Examination of Embedded De...
Advancing VLSI Design Reliability: A Comprehensive Examination of Embedded De...Advancing VLSI Design Reliability: A Comprehensive Examination of Embedded De...
Advancing VLSI Design Reliability: A Comprehensive Examination of Embedded De...
 
Sta by usha_mehta
Sta by usha_mehtaSta by usha_mehta
Sta by usha_mehta
 
SHREYA_CISCO.pptx
SHREYA_CISCO.pptxSHREYA_CISCO.pptx
SHREYA_CISCO.pptx
 
Automatic Analyzing System for Packet Testing and Fault Mapping
Automatic Analyzing System for Packet Testing and Fault MappingAutomatic Analyzing System for Packet Testing and Fault Mapping
Automatic Analyzing System for Packet Testing and Fault Mapping
 
Network Security Lecture
Network Security LectureNetwork Security Lecture
Network Security Lecture
 
System on Chip
System on ChipSystem on Chip
System on Chip
 
Applications of ATPG
Applications of ATPGApplications of ATPG
Applications of ATPG
 
Timing verification of real-time automotive Ethernet networks: what can we ex...
Timing verification of real-time automotive Ethernet networks: what can we ex...Timing verification of real-time automotive Ethernet networks: what can we ex...
Timing verification of real-time automotive Ethernet networks: what can we ex...
 
The ACTION Project: Applications Coordinate with Transport, IP and Optical Ne...
The ACTION Project: Applications Coordinate with Transport, IP and Optical Ne...The ACTION Project: Applications Coordinate with Transport, IP and Optical Ne...
The ACTION Project: Applications Coordinate with Transport, IP and Optical Ne...
 
NoC simulators presentation
NoC simulators presentationNoC simulators presentation
NoC simulators presentation
 
|QAB> : Quantum Computing, AI and Blockchain
|QAB> : Quantum Computing, AI and Blockchain|QAB> : Quantum Computing, AI and Blockchain
|QAB> : Quantum Computing, AI and Blockchain
 
Enabling Cloud Storage Auditing with Key Exposure Resistance
Enabling Cloud Storage Auditing with Key Exposure ResistanceEnabling Cloud Storage Auditing with Key Exposure Resistance
Enabling Cloud Storage Auditing with Key Exposure Resistance
 
Cloud data management
Cloud data managementCloud data management
Cloud data management
 
Automating Speed: A Proven Approach to Preventing Performance Regressions in ...
Automating Speed: A Proven Approach to Preventing Performance Regressions in ...Automating Speed: A Proven Approach to Preventing Performance Regressions in ...
Automating Speed: A Proven Approach to Preventing Performance Regressions in ...
 

Recently uploaded

Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxKartikeyaDwivedi3
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfme23b1001
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxvipinkmenon1
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2RajaP95
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLDeelipZope
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .Satyam Kumar
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 

Recently uploaded (20)

Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptx
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdf
 
POWER SYSTEMS-1 Complete notes examples
POWER SYSTEMS-1 Complete notes  examplesPOWER SYSTEMS-1 Complete notes  examples
POWER SYSTEMS-1 Complete notes examples
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptx
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCL
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 

Discrete-event simulation: best practices and implementation details in Python and Java

  • 1. BEST PRACTICES IN DISCRETE- EVENT SIMULATION CARLOS NATALINO
  • 2. 2020-03-01 Chalmers University of Technology 2 OUTLINE • Introduction • Performance analysis • Discrete-event simulation • Routing and resource assignment in optical networks • Implementation details • Best practices • Examples in Java and Python • Conclusions • Q&A
  • 3. • Performance analysis 2020-03-01 Chalmers University of Technology 3 DISCRETE-EVENT SIMULATION Analytic Simulation Prototyping Realistic Expensive Prone to contamination Set of equations e.g.: queue theory Set of events described by random numbers e.g.: event-driven simulation Real systems and devices e.g.: testbed
  • 4. 2020-03-01 Chalmers University of Technology 4 DISCRETE-EVENT SIMULATION • Environment • Models the set of elements that the simulation is interested in analyzing • Discrete sequence of events in time • Each event changes (or may change) the state of the environment • No changes between two consecutive events • Next-time event progression: time between events may vary (e.g., arrival/departure of requests) • Fixed-increment time progression: time between events is fixed (e.g., periodic reconfiguration)
  • 5. 2020-03-01 Chalmers University of Technology 5 DISCRETE-EVENT SIMULATION • Main components: • State: the environment state at a given point in time • Clock: the current simulation clock, which is not tied to the wall clock • Event list: the list with the next events to be processed/executed • Events: set of (problem-specific) procedures to be executed over the environment Event list Simulation clock
  • 6. 2020-03-01 Chalmers University of Technology 6 EVENT-DRIVEN SIMULATION Examples of environments and their events 1. Bank queue • Productor-consumer kind of problem • Clients arrive, cashiers serve the clients • Queue theory can be used for analytic assessment 2. Public transportation • Passengers boarding/dropping at stops, vehicle speed change, etc. 3. Virus outbreak • Contact probability between people, contamination probability, etc. 4. Networks • Packet-based: packet arrival, enqueue, dequeue, departure • Circuit-based: call arrival, call departure, etc.
  • 7. 2020-03-01 Chalmers University of Technology 7 ROUTING AND SPEC. ALLOC. IN OPTICAL NETWORKS • Circuit-switched network • Discrete resource allocation • Wavelength division multiplexing (WDM) • Single-wavelength channels • With wavelength conversion (opaque) • No wavelength continuity constraint • Without wavelength conversion (transparent) • Elastic optical network (EON) • Multiple-slice channels • Spectrum continuity and contiguity constraint Link A Link B Link C Link D Link E S1 S2 S3 S4 Link A Link B Link C Link D Link E S1 S2 S3 S4 Link A Link B Link C Link D Link E S1 S2 S3 S4
  • 8. 2020-03-01 Chalmers University of Technology 8 IMPLEMENTATION DETAILS State • Can be modeled as a class • Attributes of the class model the state of the environment https://github.com/carlosnatalino/python-simple-anycast-wdm-simulator/blob/cdb1340234cad0217fc7687abcadb1a3f35c8522/core.py#L12 Python Java https://github.com/carlosnatalino/java-anycast-cs-simulator/blob/065e0726ffe7e7146616d5347b90c7da21bbf851/src/main/java/simulator/cs/anycast/components/Topology.java#L21
  • 9. 2020-03-01 Chalmers University of Technology 9 IMPLEMENTATION DETAILS Event list • Should be implemented as an ordered list https://github.com/carlosnatalino/python-simple-anycast-wdm-simulator/blob/cdb1340234cad0217fc7687abcadb1a3f35c8522/core.py#L219 Python Java https://github.com/carlosnatalino/java-anycast-cs-simulator/blob/065e0726ffe7e7146616d5347b90c7da21bbf851/src/main/java/simulator/cs/anycast/core/Simulator.java#L27
  • 10. 2020-03-01 Chalmers University of Technology 10 IMPLEMENTATION DETAILS Events • Create a standard event model https://github.com/carlosnatalino/python-simple-anycast-wdm-simulator/blob/cdb1340234cad0217fc7687abcadb1a3f35c8522/events.py#L6 Python Java https://github.com/carlosnatalino/java-anycast-cs-simulator/blob/065e0726ffe7e7146616d5347b90c7da21bbf851/src/main/java/simulator/cs/anycast/events/Event.java#L11 https://github.com/carlosnatalino/java-anycast-cs-simulator/blob/065e0726ffe7e7146616d5347b90c7da21bbf851/src/main/java/simulator/cs/anycast/events/ActiveProcess.java#L12
  • 11. 2020-03-01 Chalmers University of Technology 11 IMPLEMENTATION DETAILS Events • Create a standard event model and use it https://github.com/carlosnatalino/python-simple-anycast-wdm-simulator/blob/cdb1340234cad0217fc7687abcadb1a3f35c8522/core.py#L318 Python Java https://github.com/carlosnatalino/java-anycast-cs-simulator/blob/065e0726ffe7e7146616d5347b90c7da21bbf851/src/main/java/simulator/cs/anycast/core/Simulator.java#L86
  • 12. 2020-03-01 Chalmers University of Technology 12 BEST PRACTICES Never overwrite files • Have a base folder for all results of a given batch • Create a timestamp’d folder for the results of every run https://github.com/carlosnatalino/python-simple-anycast-wdm-simulator/blob/cdb1340234cad0217fc7687abcadb1a3f35c8522/run.py#L37 https://github.com/carlosnatalino/java-anycast-cs-simulator/blob/065e0726ffe7e7146616d5347b90c7da21bbf851/src/main/java/simulator/cs/anycast/core/MultiThreadSimulator.java#L94 Python Java
  • 13. 2020-03-01 Chalmers University of Technology 13 BEST PRACTICES Have file- or argument-based configuration • Prevents you from recompiling the code https://github.com/carlosnatalino/python-simple-anycast-wdm-simulator/blob/cdb1340234cad0217fc7687abcadb1a3f35c8522/run.py#L137 https://github.com/carlosnatalino/java-anycast-cs-simulator/blob/065e0726ffe7e7146616d5347b90c7da21bbf851/src/main/java/simulator/cs/anycast/core/FileAgent.java#L89 Python Java
  • 14. 2020-03-01 Chalmers University of Technology 14 BEST PRACTICES Bonus: make a copy of the configurations for every result https://github.com/carlosnatalino/python-simple-anycast-wdm-simulator/blob/cdb1340234cad0217fc7687abcadb1a3f35c8522/run.py#L45 https://github.com/carlosnatalino/java-anycast-cs-simulator/blob/065e0726ffe7e7146616d5347b90c7da21bbf851/src/main/java/simulator/cs/anycast/core/MultiThreadSimulator.java#L104 Python Java
  • 15. 2020-03-01 Chalmers University of Technology 15 BEST PRACTICES Bonus 2: make a copy of the current simulator version https://github.com/carlosnatalino/python-simple-anycast-wdm-simulator/blob/cdb1340234cad0217fc7687abcadb1a3f35c8522/run.py#L59 https://github.com/carlosnatalino/java-anycast-cs-simulator/blob/065e0726ffe7e7146616d5347b90c7da21bbf851/src/main/java/simulator/cs/anycast/core/MultiThreadSimulator.java#L120 Python Java
  • 16. 2020-03-01 Chalmers University of Technology 16 BEST PRACTICES x. Only enqueue events when needed https://github.com/carlosnatalino/python-simple-anycast-wdm-simulator/blob/cdb1340234cad0217fc7687abcadb1a3f35c8522/events.py#L17 https://github.com/carlosnatalino/java-anycast-cs-simulator/blob/065e0726ffe7e7146616d5347b90c7da21bbf851/src/main/java/simulator/cs/anycast/events/ConnectionManager.java#L104 Python Java
  • 17. 2020-03-01 Chalmers University of Technology 17 BEST PRACTICES Run different configurations in threads • Single environment can/should not be parallelized • Multiple environments can/should be parallelized • Use of thread pool is recommended (improves resource efficiency) https://github.com/carlosnatalino/python-simple-anycast-wdm-simulator/blob/cdb1340234cad0217fc7687abcadb1a3f35c8522/run.py#L93 https://github.com/carlosnatalino/java-anycast-cs-simulator/blob/065e0726ffe7e7146616d5347b90c7da21bbf851/src/main/java/simulator/cs/anycast/core/MultiThreadSimulator.java#L131 https://github.com/carlosnatalino/java-anycast-cs-simulator/blob/065e0726ffe7e7146616d5347b90c7da21bbf851/src/main/java/simulator/cs/anycast/core/MultiThreadSimulator.java#L152 Python Java
  • 18. 2020-03-01 Chalmers University of Technology 18 BEST PRACTICES Save averages and individual results • Bonus: save everything possible https://github.com/carlosnatalino/python-simple-anycast-wdm-simulator/blob/cdb1340234cad0217fc7687abcadb1a3f35c8522/core.py#L325 https://github.com/carlosnatalino/python-simple-anycast-wdm-simulator/blob/cdb1340234cad0217fc7687abcadb1a3f35c8522/run.py#L113 https://github.com/carlosnatalino/java-anycast-cs-simulator/blob/065e0726ffe7e7146616d5347b90c7da21bbf851/src/main/java/simulator/cs/anycast/core/Simulator.java#L100 https://github.com/carlosnatalino/java-anycast-cs-simulator/blob/065e0726ffe7e7146616d5347b90c7da21bbf851/src/main/java/simulator/cs/anycast/core/Simulator.java#L122 Python Java
  • 19. 2020-03-01 Chalmers University of Technology 19 BEST PRACTICES Plot results as you go • Helps identifying problems before everything runs https://github.com/carlosnatalino/python-simple-anycast-wdm-simulator/blob/cdb1340234cad0217fc7687abcadb1a3f35c8522/run.py#L103 https://github.com/carlosnatalino/java-anycast-cs-simulator/blob/bbede8fabadcc8c8c96542af469c7334e3ba1a67/src/main/java/simulator/cs/anycast/core/MultiThreadSimulator.java#L174 Python Java
  • 20. 2020-03-01 Chalmers University of Technology 20 CONCLUSIONS AND LINKS • Simulations are a good compromise between cost, time and adherence to reality • Java and Python are both great options to implement your simulator • Good trade-off between development complexity and runtime efficiency • C3SE offers computing power to run your simulations • Versions used in this presentation: • Python version: https://github.com/carlosnatalino/python-simple-anycast- wdm-simulator • Java version: https://github.com/carlosnatalino/java-anycast-cs-simulator/ • Presentation available at: https://www.slideshare.net/CarlosNatalinoSilva/discreteevent-simulation- best-practices-and-implementation-details-in-python-and-java

Editor's Notes

  1. Comment that one event list does not allow for multithreading