UNIT 3: SIMULATION & MODELING
1. Introduction to Simulation
Simulation is the process of developing a model of a real-world system and conducting experiments with this model to understand system behavior or evaluate strategies for operation.
Purpose: To analyze complex systems where analytical solutions are infeasible, to test "what-if" scenarios, and to train personnel without real-world risks.
Steps in Simulation Process (with flow diagram concept):
-
Problem Identification: Define the issue and objectives.
-
Project Planning: Scope, resources, timeline.
-
System Definition: Boundaries, components, interactions.
-
Model Formulation: Develop mathematical/logical model (flowchart, equations).
-
Data Collection: Gather input data (arrival rates, service times).
-
Model Translation: Code model into simulation software.
-
Verification & Validation: Ensure model is correct and accurate.
-
Experimental Design: Determine runs, inputs, outputs.
-
Simulation Execution: Run experiments, collect outputs.
-
Analysis & Interpretation: Statistical analysis of results.
-
Documentation & Reporting: Present findings and recommendations.
[!TIP] Exam Focus: The flow diagram is a high-frequency question. Memorize the sequence and purpose of each step.
When to Use Simulation:
-
Advantages over analytical methods:
-
Handles complex, non-linear, stochastic systems.
-
Allows testing of hazardous/costly scenarios.
-
Provides visual animation and detailed output.
-
Flexible for "what-if" analysis.
-
-
Limitations & Challenges:
-
Time-consuming and expensive to build.
-
Requires expertise in modeling and statistics.
-
Output analysis can be complex (needs statistical rigor).
-
Model may not perfectly represent reality (validation difficulty).
-
2. Classification of Systems and Simulation Approaches
| Classification | Characteristics | Examples |
|---|---|---|
| Continuous vs. Discrete | Continuous: State variables change continuously over time (e.g., fluid level).<br>Discrete: State changes at distinct points (e.g., customer arrivals). | Continuous: Tank filling, temperature change.<br>Discrete: Queue at bank, traffic at intersection. |
| Analog vs. Digital | Analog: Uses physical models (e.g., wind tunnel).<br>Digital: Uses computational models (software). | Analog: Flight simulator with physical cockpit.<br>Digital: Arena/Simul8 software models. |
| Deterministic vs. Stochastic | Deterministic: No randomness; same inputs → same outputs.<br>Stochastic: Incorporates randomness (probability distributions). | Deterministic: Simple kinematic equations.<br>Stochastic: Arrival times ~ Poisson process. |
| Static vs. Dynamic | Static: Time-independent (e.g., optimization).<br>Dynamic: Time-dependent behavior. | Static: Facility location problem.<br>Dynamic: Manufacturing system over a day. |
[!TIP] Exam Focus: Compare continuous vs. discrete and analog vs. digital in tabular form for 7-mark questions.
3. Probability and Statistical Foundations
Random Variables (RVs):
-
Discrete RV: Takes countable values (e.g., number of customers). PMF: $$\displaystyle P(X=x) $$.
-
Continuous RV: Takes any value in interval (e.g., service time). PDF: $f(x)$, CDF: $$\displaystyle F(x) = P(X \le x) = \int_{-\infty}^{x} f(t) dt $$.
Key Distributions:
| Distribution | PMF/PDF | Mean | Variance | Conditions/Notes |
|---|---|---|---|---|
| Binomial | $$\displaystyle P(X=k) = \binom{n}{k} p^k (1-p)^{n-k} $$ | $np$ | $np(1-p)$ | $n$ trials, success prob $p$, independent. |
| Poisson | $$\displaystyle P(X=k) = \frac{\lambda^k e^{-\lambda}}{k!} $$ | $\lambda$ | $\lambda$ | Events in fixed interval, rate $\lambda$, independent. |
| Normal | $$\displaystyle f(x) = \frac{1}{\sigma\sqrt{2\pi}} e^{-\frac{1}{2}\left(\frac{x-\mu}{\sigma}\right)^2} $$ | $\mu$ | $$\displaystyle \sigma^2 $$ | Symmetric, defined by $\mu, \sigma$. Standardization: $$\displaystyle Z = \frac{X-\mu}{\sigma} \sim N(0,1) $$. |
Approximating Binomial with Poisson:
- When $n$ is large ($n \ge 20$) and $p$ is small ($p \le 0.05$) such that $$\displaystyle \lambda = np $$ is moderate ($\lambda \le 5$).
\boxed{\text{If } n \to \infty,\ p \to 0,\ \lambda = np \text{ fixed, then } \text{Bin}(n,p) \approx \text{Poisson}(\lambda)}
Stochastic Variables & Processes:
-
Stochastic variable: Synonymous with random variable; outcome uncertain.
-
Stochastic process: Collection of random variables indexed by time (e.g., arrival process $N(t)$ = number of arrivals by time $t$).
Arrival Patterns:
-
Poisson Process:
-
Events occur continuously and independently.
-
Number of events in interval $(t, t+\tau]$ ~ Poisson($\lambda\tau$).
-
Exponential interarrival times: Time between arrivals ~ Exponential($\lambda$), PDF $$\displaystyle f(t) = \lambda e^{-\lambda t} $$, mean $1/\lambda$.
-
Memoryless property: $$\displaystyle P(T > s+t \mid T > s) = P(T > t) $$.
-
4. Queuing Theory and Simulation
Queuing System Components:
-
Arrival Process: Pattern of incoming entities (e.g., Poisson).
-
Service Mechanism: Number of servers, service time distribution (e.g., exponential).
-
Queue Discipline: Rule for service order (FIFO, LIFO, priority, SIRO).
-
Capacity: Maximum number of entities allowed (finite/infinite).
-
Population Size: Source of entities (finite/infinite).
Kendall's Notation: A/B/c/K/N/D
-
A: Arrival distribution (M=Markovian/Exponential, D=Deterministic, G=General). -
B: Service distribution. -
c: Number of servers. -
K: System capacity (optional, omitted if infinite). -
N: Population size (optional, omitted if infinite). -
D: Queue discipline (default FIFO, omitted if FIFO). -
Examples: M/M/1 (Poisson arrivals, exponential service, 1 server, infinite capacity/population, FIFO), M/G/1, M/M/c.
Performance Measures:
-
Utilization ($\rho$): Fraction of time servers busy. For M/M/1: $$\displaystyle \rho = \lambda / \mu $$ (must be $$\displaystyle \rho < 1 $$ for stability).
-
Average queue length ($$\displaystyle L_q $$): Expected number waiting.
-
Average waiting time ($$\displaystyle W_q $$): Expected time spent waiting.
-
Average time in system ($$\displaystyle W = W_q + 1/\mu $$).
-
Probability of delay ($$\displaystyle P_{delay} $$): Probability an arriving entity must wait.
-
Little's Law: $$\displaystyle L = \lambda W $$ (applies to stable system).
Basic Queuing Models (M/M/1 formulas):
$$L_q = \frac{\rho^2}{1-\rho},\quad W_q = \frac{L_q}{\lambda} = \frac{\rho}{\mu - \lambda},\quad P_{delay} = \rho,\quad L = \frac{\rho}{1-\rho},\quad W = \frac{1}{\mu - \lambda}$$
Simulation of Queuing Systems:
-
Event-Scheduling Approach:
-
Maintain Future Event List (FEL) sorted by event time.
-
Initialize: Set clock $$\displaystyle t=0 $$, schedule first arrival.
-
Loop:
-
Advance clock to next event in FEL.
-
Remove event from FEL, execute (update state, statistics).
-
Schedule new events (e.g., next arrival, service completion).
-
-
Terminate after specified time/events.
-
-
Time-Advance Mechanisms:
-
Next-event time advance: Jump to next scheduled event (most common).
-
Fixed-increment time advance: Increment clock by fixed $\Delta t$ (less efficient).
-
Applications:
-
Telecommunications: Call centers, network packet switching.
-
Customer Service: Banks, hospitals, ticket counters.
-
Manufacturing: Job shop scheduling, assembly lines.
-
Computer Systems: CPU scheduling, disk I/O, web servers.
5. Model Verification and Validation
| Aspect | Verification | Validation |
|---|---|---|
| Goal | "Build the model right": Implementation matches conceptual design. | "Build the right model": Model accurately represents real system. |
| Activities | Debugging, modular testing, code walkthrough, sensitivity to input test. | Face validation, historical data validation, predictive validation. |
| Methods | - Trace debugging.<br>- Compare outputs with simplified cases.<br>- Independent code review. | - Face validation: Expert scrutiny of model logic/outputs.<br>- Historical validation: Compare model output with past system data.<br>- Predictive validation: Compare model predictions with future real data. |
| When | During model development. | After model completion, before experimentation. |
Sensitivity Analysis:
-
Test how changes in input parameters affect outputs.
-
Identifies critical parameters and model robustness.
-
Example: Vary arrival rate $\lambda$ by ±10% and observe change in $$\displaystyle L_q $$.
[!TIP] Common Pitfall: Confusing verification (code correctness) with validation (realism). Always ask: "Is the model built correctly?" vs. "Is the correct model built?"
6. Simulation Languages and Tools
Classification of Simulation Languages:
| Type | Examples | Purpose |
|---|---|---|
| Discrete-event | GPSS, Simscript | Model systems where state changes at discrete events (queues, manufacturing). |
| Continuous | DYNAMO, ACSL | Model systems with continuous state variables (physics, chemical processes). |
| Combined/General | Simula, Arena, AnyLogic | Support both discrete and continuous; often graphical. |
Features of Simulation Software:
-
Random Number Generation (RNG): Pseudo-random streams, seed control.
-
Event Handling: Scheduling, FEL management.
-
Output Analysis: Automated statistics (means, confidence intervals), animation.
-
Input Modeling: Fit distributions to data.
-
User Interface: Graphical model building, debugging tools.
Simulation of Classification Languages:
-
Interpretation 1: Classification of simulation languages (as above table).
-
Interpretation 2: Use of classification algorithms (e.g., decision trees, neural networks) within simulation models to make decisions or classify entities.
- Example: In a hospital simulation, use a trained classifier to triage patients into urgency categories based on symptoms.
7. Advanced Simulation Techniques
AI Techniques in Simulation:
-
Neural Networks: Approximate complex system dynamics when equations are unknown; used for system identification and prediction.
-
Genetic Algorithms (GA): Optimization technique; evolve solutions (e.g., find optimal resource allocation) via selection, crossover, mutation.
-
Fuzzy Logic: Handle vague inputs (e.g., "high traffic") by defining membership functions; useful in control systems simulation.
Pure Pursuit Problem:
-
Algorithm: Path-tracking method for autonomous vehicles.
-
Identify a lookahead point at fixed distance $$\displaystyle L_d $$ ahead on desired path.
-
Compute curvature $$\displaystyle \kappa = \frac{2y}{L_d^2} $$ (for bicycle model), where $y$ is lateral error.
-
Steer angle $$\displaystyle \delta = \arctan(\kappa \cdot L) $$ (L = wheelbase).
-
-
Modeling: Vehicle kinematics (bicycle model), path geometry.
-
Simulation: Test with varying speeds, disturbances; measure tracking error.
Other Advanced Methods:
-
Agent-Based Simulation: Model individual autonomous agents with behaviors; used in social systems, traffic.
-
Monte Carlo Simulation: Repeated random sampling to estimate numerical results (e.g., risk analysis).
8. Application Examples
Autopilot Simulation:
-
System Components:
-
Sensors: Gyroscopes (attitude), GPS (position), airspeed sensors.
-
Controller: Computes control commands (e.g., PID, LQR) based on sensor feedback and reference path.
-
Actuators: Ailerons, rudder, elevator, throttle.
-
-
Simulation Model:
-
Aircraft 6-DOF (six degrees of freedom) dynamics equations.
-
Environment models: wind, turbulence.
-
Sensor models: noise, delays.
-
Controller logic implementation.
-
-
Example: Simulate a commercial aircraft following a predefined flight plan with wind gusts; evaluate controller performance (tracking error, control effort).
Other Applications:
-
Manufacturing: Assembly line balancing, inventory control.
-
Healthcare: Patient flow in ER, resource scheduling.
-
Transportation: Traffic light timing, port logistics.
-
Defense: War gaming, mission planning.
9. Mathematical Models in Simulation
Differential Equations:
-
Ordinary Differential Equations (ODEs): Derivatives w.r.t. single independent variable (usually time).<br>Example: $$\displaystyle \frac{dx}{dt} = f(x,t) $$ for population growth.
-
Partial Differential Equations (PDEs): Derivatives w.r.t. multiple variables (e.g., space and time).<br>Example: Heat equation $$\displaystyle \frac{\partial u}{\partial t} = \alpha \nabla^2 u $$.
Numerical Methods for ODEs:
- Euler's Method (first-order):
$$x_{n+1} = x_n + h f(t_n, x_n)$$
Simple but inaccurate for stiff systems; error $\mathcal{O}(h)$.
-
Runge-Kutta Methods (higher-order):
- RK4 (fourth-order):
$$k_1 = h f(t_n, x_n)$$
$$k_2 = h f(t_n + h/2, x_n + k_1/2)$$
$$k_3 = h f(t_n + h/2, x_n + k_2/2)$$
$$k_4 = h f(t_n + h, x_n + k_3)$$
$$x_{n+1} = x_n + \frac{1}{6}(k_1 + 2k_2 + 2k_3 + k_4)$$
More accurate, error $$\displaystyle \mathcal{O}(h^4) $$; widely used.
Role in Simulation:
-
Continuous simulation (e.g., chemical reactor, vehicle dynamics) requires solving ODEs/PDEs numerically at each time step.
-
Choice of method balances accuracy, stability, and computational cost.
[!TIP] Exam Focus: Derive Euler's method from Taylor series; compare with RK4 accuracy. Know when to use each (Euler for simple, non-stiff; RK4 for accuracy).