Simulation and ModelingUnit 114 min read
Simulation Basics: Definitions, Types, Models & Applications
Unit 1 of Simulation and Modeling introduces core concepts like simulation, models, systems, and their real-world applications. It covers definitions, types (discrete vs. continuous), model components, and how simulations replicate real-world processes for analysis.
What is a Simulation?
A simulation is an imitation of a real-world process or system over time. It uses mathematical models, algorithms, and computational tools to analyze behavior without physically interacting with the system.
Why Simulate?
- Cost-effective: Test systems virtually (e.g., crash-testing cars without building prototypes).
- Safe: Study dangerous scenarios (e.g., nuclear reactor failures).
- Time-efficient: Speed up or slow down processes (e.g., aging a product in hours instead of years).
- Flexibility: Modify variables easily (e.g., traffic flow under different weather conditions).
Key Components of a Simulation
Every simulation has three core elements:
- Real System: The physical or abstract process being studied (e.g., a hospital emergency room, a stock market).
- Model: A simplified representation of the system (e.g., equations, flowcharts, or agent-based rules).
- Simulation Engine: The computational tool that runs the model (e.g., Python, MATLAB, or specialized software like AnyLogic).
- Output: Results (e.g., graphs, statistics, or animations) used for decision-making.
Types of Simulations
Simulations are classified based on the nature of the system and time representation:
| Type | Description | Example | Real-World Use |
|---|---|---|---|
| Discrete | Events occur at distinct points in time (e.g., customer arrivals in a queue). | Bank teller transactions. | Khalti’s payment processing (simulate transaction delays). |
| Continuous | Variables change smoothly over time (e.g., temperature, fluid flow). | Chemical reactions in a reactor. | NTC’s power grid load simulation. |
| Hybrid | Combines discrete and continuous elements. | Manufacturing with machine breakdowns. | Daraz’s warehouse robotics (order picking + conveyor belt speed). |
| Static | No time dependency (e.g., structural analysis of a bridge). | Stress testing a building model. | Earthquake-resistant building designs. |
| Dynamic | Time-dependent (most common in simulations). | Traffic flow in Kathmandu. | Pathao’s ride-sharing demand forecasting. |
How Simulations Work: A Step-by-Step Trace
Let’s simulate a simple bank queue to understand the process.
Step 1: Define the System
- Real System: A bank with 1 teller, customers arriving randomly, and service times varying between 2–5 minutes.
- Assumptions:
- Customers arrive every 3 minutes on average (Poisson process).
- Service time is uniformly distributed between 2–5 minutes.
Step 2: Build the Model
We’ll use a discrete-event simulation (customers arrive and leave at specific times). Key Variables:
- Arrival time: Randomly generated using a Poisson distribution.
- Service time: Randomly generated between 2–5 minutes.
- Queue length: Number of customers waiting.
Step 3: Run the Simulation (Trace for 30 Minutes)
| Time (min) | Event | Action | Queue Length | Notes |
|---|---|---|---|---|
| 0 | System starts | Teller idle, queue empty. | 0 | |
| 2 | Customer arrives | Joins queue. | 1 | Arrival time = 2 min. |
| 4 | Customer starts service | Teller serves Customer 1 (service time = 3 min). | 0 | Service ends at 7 min. |
| 5 | Customer arrives | Joins queue. | 1 | |
| 7 | Customer 1 leaves | Teller serves Customer 2 (service time = 4 min). | 0 | Service ends at 11 min. |
| 8 | Customer arrives | Joins queue. | 1 | |
| 11 | Customer 2 leaves | Teller serves Customer 3 (service time = 2 min). | 0 | Service ends at 13 min. |
| 12 | Customer arrives | Joins queue. | 1 | |
| ... | ... | ... | ... | ... |
| 30 | Simulation ends | Total customers served: 10. | 0 | Average wait time: 4.2 min. |
Visualization of the Queue Over Time:
timeline
title Bank Queue Simulation (30 min)
0: System starts
2: Customer arrives (Queue: 1)
4: Service starts (Customer 1)
5: Customer arrives (Queue: 1)
7: Customer 1 leaves (Queue: 0)
8: Customer arrives (Queue: 1)
11: Customer 2 leaves (Queue: 0)
12: Customer arrives (Queue: 1)
13: Customer 3 leaves (Queue: 0)
...
30: End (10 customers served)In the Real World
Simulations are everywhere in Nepal and globally. Here’s how companies use them:
Khalti (Digital Payments)
- Idea Used: Discrete-event simulation of transaction queues.
- How: Khalti simulates peak-hour payment processing to optimize server capacity. For example, during Dashain, millions of transactions occur simultaneously. By simulating arrival rates (e.g., 10,000 transactions/minute) and processing times (e.g., 0.5 seconds/transaction), they ensure servers don’t crash.
- Real Trace:
- Input: 5000 transactions/minute, 90% success rate.
- Simulation: If servers handle 3000 transactions/minute, 20% fail → Khalti adds more servers.
- Output: Scaled to handle 8000 transactions/minute during festivals.
NTC (Power Grid Management)
- Idea Used: Continuous-time simulation of electrical load.
- How: NTC uses simulations to predict power demand during load-shedding periods. For example, during summer, AC usage spikes. By modeling temperature vs. power consumption (e.g., +5°C → +10% load), they schedule generators efficiently.
- Real Trace:
- Input: Historical data (2018–2023) shows July demand = 2500 MW at 35°C.
- Simulation: Predict 2024 demand at 38°C → 2800 MW.
- Output: Schedule 300 MW extra from hydropower plants.
Pathao (Ride-Sharing)
- Idea Used: Agent-based simulation of driver-customer matching.
- How: Pathao simulates driver availability vs. ride requests in Kathmandu. For example, during peak hours (6–9 PM), demand surges in Thapathali. By simulating 1000 drivers with 2-minute response times, they optimize pricing and driver incentives.
- Real Trace:
- Input: 5000 ride requests/hour, 80% driver acceptance rate.
- Simulation: If drivers take >3 min to accept, 30% requests fail → Pathao offers bonuses for faster responses.
- Output: Reduced wait time from 8 to 4 minutes.
Simulation vs. Real Experiment: A Comparison
| Feature | Simulation | Real Experiment |
|---|---|---|
| Cost | Low (no physical setup). | High (prototypes, labs, field tests). |
| Safety | Safe (no risks). | Risky (e.g., testing a bridge collapse). |
| Time | Fast (speed up/slow down time). | Slow (real-time constraints). |
| Flexibility | High (change variables easily). | Low (physical constraints). |
| Accuracy | Depends on model quality. | High (real data). |
| Example | Simulating a new drug’s side effects. | Testing a drug on patients. |
Advantages and Disadvantages of Simulations
✅ Advantages
- Cost savings: Avoid expensive real-world trials (e.g., airplane wing testing).
- Risk reduction: Test dangerous scenarios (e.g., nuclear meltdowns).
- Reproducibility: Run the same experiment multiple times.
- Complexity handling: Model systems with thousands of variables (e.g., climate models).
- Education: Train personnel (e.g., pilots in flight simulators).
❌ Disadvantages
- Model limitations: Simplifications may miss real-world nuances.
- Computational cost: Large simulations require powerful hardware.
- Validation needed: Results must be verified against real data.
- Learning curve: Requires expertise in modeling and programming.
Common Applications of Simulation
| Field | Example | Simulation Type |
|---|---|---|
| Healthcare | Hospital emergency room flow. | Discrete-event. |
| Transportation | Traffic light optimization in Kathmandu. | Continuous + discrete. |
| Finance | Stock market crash scenarios. | Agent-based. |
| Manufacturing | Robot arm assembly line. | Continuous. |
| Environmental | Wildfire spread prediction. | Continuous + stochastic. |
| Computer Systems | CPU cache performance. | Discrete-event. |
Worked Example: Simulating a Pendulum (Continuous System)
A pendulum’s motion is governed by physics equations, but we can simulate it digitally.
Step 1: Define the Model
The pendulum’s angle θ(t) follows: where:
- (gravity),
- (length),
- Initial angle .
Step 2: Discretize Time
Use Euler’s method to approximate the solution: Let .
Step 3: Simulate for 10 Seconds
| Time (s) | θ (degrees) | dθ/dt (rad/s) | Notes |
|---|---|---|---|
| 0.0 | 30.0 | 0.0 | Initial angle. |
| 0.1 | 29.9 | -0.26 | decreases due to gravity. |
| 0.2 | 29.6 | -0.52 | Acceleration increases. |
| ... | ... | ... | ... |
| 10.0 | -29.8 | 0.0 | Pendulum swings back to ~-30°. |
Visualization of Pendulum Motion:
Graph of Angle vs. Time:
Simulation Software Tools
Students often use these tools for assignments:
| Tool | Type | Best For | Example Use Case |
|---|---|---|---|
| AnyLogic | Hybrid (discrete + continuous) | Business processes, logistics. | Simulating a Daraz warehouse. |
| MATLAB/Simulink | Continuous/discrete | Engineering systems (control, physics). | Modeling a robot arm. |
| Python (SimPy) | Discrete-event | Custom simulations (queues, networks). | Bank queue simulation (as above). |
| Arena | Discrete-event | Manufacturing, supply chains. | Pathao’s driver dispatch system. |
| Anylogic | Agent-based | Crowd behavior, traffic. | Kathmandu traffic during Dashain. |
Exam Tip: How to Score Full Marks
This unit is theoretical but practical. Examiners test:
- Definitions: Know the difference between model, simulation, discrete vs. continuous.
- Applications: Link simulations to real-world examples (e.g., "How would you simulate Khalti’s payment system?").
- Diagrams: Draw a system model (like the bank queue) or a timeline (like the pendulum).
- Worked Examples: Show step-by-step traces (like the bank queue table).
- Advantages/Disadvantages: Compare simulations to real experiments.
Common Mistakes to Avoid:
- ❌ Confusing discrete (events at specific times) with continuous (smooth changes).
- ❌ Forgetting to mention randomness in simulations (e.g., arrival times in queues).
- ❌ Not validating the model (always check if the simulation matches reality).
Model Answer Structure for Short Questions:
Q: Explain discrete-event simulation with an example. A: A discrete-event simulation models a system where changes occur at distinct points in time (events). Example: A bank queue.
- Events: Customer arrival, service start, service completion.
- State variables: Queue length, teller status (idle/busy).
- Process:
- Customer arrives → joins queue.
- Teller becomes free → serves next customer.
- Service ends → customer leaves.
- Output: Average wait time, queue length distribution. Visual:
Summary Checklist
Before the exam, ensure you can: ✅ Define simulation, model, and system. ✅ Classify systems as discrete/continuous/hybrid. ✅ Trace a simple simulation (e.g., bank queue or pendulum). ✅ List 3 real-world Nepalese examples (Khalti, NTC, Pathao). ✅ Compare simulations to real experiments. ✅ Draw a timeline or state diagram for a simulation.
Based on the TU BIT syllabus for Simulation and Modeling, unit 1.
Discussion
Loading…