CMP338 Simulation and Modeling

Simulation and ModelingUnit 610 min read

Verification & Validation in Simulation: Techniques, Metrics & Pitfalls

Unit 6 of Simulation and Modeling explores how to ensure simulation models are correct (verification) and useful (validation), covering techniques like face validation, animation checks, and statistical tests, with real-world examples from Nepalese tech companies.

Key Concepts and Definitions

Verification vs. Validation

Verification asks: "Are we building the model right?" It checks if the model implementation matches the conceptual design and mathematical formulation. Validation asks: "Are we building the right model?" It assesses whether the model accurately represents the real-world system it simulates.

flowchart LR
    A["Verification"] -->|"Checks"| B["Model matches design"]
    C["Validation"] -->|"Checks"| D["Model matches reality"]
    B -->|"✓ Passes"| E["Proceed to Validation"]
    D -->|"✓ Passes"| F["Model is useful"]

Common Verification Techniques

  1. Face Validation: Experts visually inspect the model to ensure it "looks right."
  2. Animation Checks: Simulate the model and observe if outputs align with expectations.
  3. Tracing: Compare simulation outputs with analytical solutions for simple cases.
  4. Unit Testing: Test individual components (e.g., a queueing module) in isolation.
Unit TestingDebuggingCode ReviewConservation LawsBoundary ConditionsMathematical ChecksParameter SensitivityExtreme Value TestingStructural ValidationVerification Process
Hierarchy of verification techniques for simulation models

Common Validation Techniques

  1. Historical Data Comparison: Run the model with past data and compare outputs to real historical outcomes.
  2. Sensitivity Analysis: Vary inputs to see if outputs behave as expected.
  3. Expert Opinion: Consult domain experts (e.g., traffic engineers for a road simulation).
  4. Statistical Tests: Use hypothesis testing (e.g., t-tests) to compare simulation vs. real data.

Worked Example: Validating a Queueing Model for Pathao Drivers

0.511.522.533.544.5512345678910xyL = λ/μ(μ-λ) (M/M/1/K)L = 3 (for λ=2, μ=3)
Queueing model: Steady-state probability L vs. arrival/service rates (λ=10, μ=12 for Pathao)

Scenario

Pathao wants to simulate driver wait times at pickup points in Kathmandu. They built a queueing model with:

  • Arrival rate (λ) = 10 drivers/hour (Poisson)
  • Service rate (μ) = 12 drivers/hour (Exponential)
  • Queue capacity = 5 drivers

Goal: Validate if the model predicts real-world wait times.

Step 1: Verification (Is the model built correctly?)

  • Face Validation: Experts confirm the queueing logic (M/M/1/K) matches Pathao’s operations.
  • Tracing: For λ=2, μ=3, the steady-state probability . The model’s code outputs . ✅ Correct.

Step 2: Validation (Does the model match reality?)

Pathao collects real data for 1 week:

Hour Avg. Wait Time (Real) Model Prediction
8 AM 4.2 min 4.1 min
12 PM 8.5 min 8.7 min
5 PM 12.3 min 12.0 min
03.086.159.2312.38 AM4.212 PM8.55 PM12.3Wait Time (minutes)
Real vs. Model Wait Times (Pathao Drivers)

Statistical Test: Perform a paired t-test (H₀: mean difference = 0).

  • Null hypothesis: Model predictions ≠ real data.
  • Test statistic: , where , , .
  • . Critical t-value (α=0.05, df=2) = 4.30.
  • Since , fail to reject H₀. The model is statistically valid.

Visualizing Validation: Animation Check for a Traffic Simulation

Startt=0Cars (λ=5/hour)Traffic Lights (Green/Red)Accidents (P=0.01)t=1 hourObservation (No crashes, queue <10)Expert Confirmation
Traffic simulation validation workflow (animation check)

Common Pitfalls and How to Avoid Them

Pitfall Cause Solution
Overfitting Model matches training data but fails on new data Use cross-validation and test on unseen data
Ignoring Randomness Deterministic assumptions in stochastic systems Use proper random number generators (e.g., Mersenne Twister)
Validation on Noisy Data Real-world data has errors Clean data (remove outliers, smooth trends)
Incorrect Model Structure Wrong assumptions (e.g., M/M/1 instead of M/G/1) Consult domain experts and literature
Overfitting (25%)Ignoring Edge Cases (20%)Poor Data Quality (15%)Incorrect Assumptions (20%)Lack of Expert Review (20%)
Distribution of common simulation validation pitfalls (based on industry studies)

In the Real World

  1. eSewa’s Payment Queue Simulation

    • Idea Used: Verification via animation checks.
    • How: eSewa simulates payment processing queues to ensure no transactions are dropped during peak hours (e.g., Dashain). Animations show transaction flows, and developers verify that the queue logic matches the system design.
  2. NTC’s Network Traffic Model

    • Idea Used: Validation with historical data.
    • How: NTC validates its network congestion model by comparing simulated traffic volumes against real call-drop rates during festivals (e.g., Tihar). If the model predicts 5% drops but reality shows 15%, they adjust parameters (e.g., increase server capacity in the model).
  3. Daraz’s Warehouse Robot Simulation

    • Idea Used: Sensitivity analysis.
    • How: Daraz tests its automated warehouse model by varying robot speeds and order volumes. If increasing speed from 1 m/s to 1.5 m/s reduces delivery time by only 5% (instead of the expected 20%), they validate that the model’s speed parameter needs recalibration.

Worked Example: Verifying a Markov Chain for NEPSE Stock Prices

0.60.30.10.20.50.30.10.40.5BullishStableBearish
NEPSE Markov Chain Transition Matrix (Pathao: Bullish → Stable → Bearish)

Scenario

NEPSE wants to model stock price movements as a Markov chain with 3 states:

  1. Bullish (price ↑)
  2. Stable (price ≈)
  3. Bearish (price ↓)

Transition matrix (from a study):

      Bullish | Stable | Bearish
Bullish: 0.6    | 0.3    | 0.1
Stable:  0.2    | 0.5    | 0.3
Bearish: 0.1    | 0.4    | 0.5

Step 1: Verification (Does the matrix sum to 1?)

Check rows:

  • Bullish: 0.6 + 0.3 + 0.1 = 1 ✅
  • Stable: 0.2 + 0.5 + 0.3 = 1 ✅
  • Bearish: 0.1 + 0.4 + 0.5 = 1 ✅

Step 2: Validation (Does it match real data?)

Collect NEPSE’s daily price changes for 100 days:

  • Bullish days: 40
  • Stable days: 35
  • Bearish days: 25

Compare with model’s steady-state probabilities (π): Solve :

π₁ = 0.6π₁ + 0.2π₂ + 0.1π₃
π₂ = 0.3π₁ + 0.5π₂ + 0.4π₃
π₃ = 0.1π₁ + 0.3π₂ + 0.5π₃
π₁ + π₂ + π₃ = 1

Solution: .

Comparison:

State Model Probability Real Data (%)
Bullish 42.8% 40%
Stable 35.7% 35%
Bearish 21.4% 25%

Conclusion: The model is partially valid but underestimates bearish states. Adjust transition probabilities (e.g., increase Bearish→Bearish to 0.6).


Graph: Loss Function for Model Validation

Interpretation:

  • The MSE curve shows the validation error decreases until λ=15, then increases. This suggests λ=15 is the best parameter for the Pathao queueing model.
-1-0.8-0.6-0.4-0.20.20.40.60.810.10.20.30.40.50.6xyMean Squared Error (MSE)Optimal λ=0.1
Loss Function for Pathao Model Validation (MSE vs. λ)

Exam Tip

  1. Differentiate Verification and Validation:

    • Verification = "Are we building it right?" (e.g., code matches equations).
    • Validation = "Is it right for the purpose?" (e.g., model predicts real-world outcomes).
    • Exam Trick: Use analogies like "Verification is like proofreading a recipe; validation is like testing the cake."
  2. Techniques to Remember:

    • Verification: Face validation, tracing, unit testing.
    • Validation: Historical data, sensitivity analysis, expert opinion.
    • Always link techniques to real-world examples (e.g., "NTC uses historical call data for validation").
  3. Common Exam Questions:

    • "How would you verify a discrete-event simulation of a bank ATM queue?" → Answer: Use tracing (compare with analytical M/M/1 results) and animation checks.
    • "Validate a model of Kathmandu traffic using sensitivity analysis." → Answer: Vary parameters like traffic light timings and observe if congestion patterns match real data.
  4. Avoid These Mistakes:

    • Confusing verification with validation.
    • Forgetting to mention statistical tests (e.g., t-tests, chi-square) for validation.
    • Ignoring real-world constraints (e.g., "The model assumes Poisson arrivals, but real data shows bursts").
  5. Diagram Expectations:

    • Draw flowcharts for verification/validation processes.
    • Sketch state diagrams (e.g., Markov chains) and label transitions.
    • For queueing systems, show timelines with arrival/departure events.

Final Note: Always ask, "Does this model help solve a real problem?" If not, it fails validation. Use Nepalese examples (e.g., traffic, banking, e-commerce) to stand out in exams!

Based on the PU BE Computer (PU) syllabus for Simulation and Modeling (CMP338), unit 6.

Discussion

Loading…