Simulation Reproducibility and Experimental Control Methods in Crowd Evacuation
Topic Description
In crowd evacuation simulation research, simulation reproducibility refers to the ability to obtain consistent results from multiple runs of a simulation program under identical initial conditions and parameter settings. Experimental control involves managing variables during the simulation process through systematic methods to ensure that result differences truly reflect the influence of the studied factors rather than random fluctuations. This knowledge point focuses on how to design controllable simulation experiments to ensure the scientific rigor of the research and the reliability of the conclusions.
Core Challenges
- Sources of Randomness: Randomness in individual behavior, random distribution of initial positions, probability of environmental event triggers, etc.
- Numerical Error Accumulation: Floating-point operation errors, differences in differential equation solving precision
- Parallel Computing Uncertainty: Non-deterministic execution order in multi-threaded/process computing
- External Dependency Variation: Random number generator seeds, third-party library version differences
Key Techniques for Achieving Reproducibility
Step One: Randomness Control
- Fixed Random Seed: Set a uniform initial seed value for all random number generators
import random random.seed(42) # Fix Python's built-in random generator import numpy as np np.random.seed(42) # Fix NumPy random generator - Layered Seed Management: Assign independent but traceable seeds to different random sources (e.g., movement decisions, event triggers)
- Random Sequence Recording: Save the random number sequence of each experiment for playback verification
Step Two: Initial Condition Standardization
- Spatial Initialization: Use deterministic algorithms to generate initial positions (e.g., grid-based placement instead of completely random distribution)
def deterministic_placement(agent_count, room_size): positions = [] grid_step = int(room_size[0] * room_size[1] / agent_count) ** 0.5 for i in range(agent_count): x = (i * grid_step) % room_size[0] y = ((i * grid_step) // room_size[0]) % room_size[1] positions.append((x + 0.5, y + 0.5)) # Grid center point return positions - Parameter Documentation: Use configuration files to record all parameters to avoid differences caused by hard-coding
Step Three: Numerical Stability Assurance
- Time Step Selection: Use adaptive time-step algorithms to ensure stability in solving differential equations
def adaptive_time_step(density, max_speed): # Dynamically adjust step size based on local density, satisfying the CFL condition base_dt = 0.01 safe_factor = 0.8 # Safety factor return safe_factor * base_dt / (density * max_speed + 1e-6) - Floating-Point Precision Unification: Clearly specify single-precision (float32) or double-precision (float64) calculation standards
Step Four: Parallel Computing Determinism
- Pseudo-Random Number Generator (PRNG) Design: Assign independent random streams to each thread to avoid cross-interference
from threading import Thread import numpy as np class ParallelRNG: def __init__(self, base_seed): self.base_seed = base_seed self.rngs = {} # Mapping from thread ID to RNG def get_rng(self): tid = threading.get_ident() if tid not in self.rngs: # Derive a new seed based on the base seed and thread ID self.rngs[tid] = np.random.RandomState(self.base_seed + tid) return self.rngs[tid] - Synchronization Point Setting: Insert synchronization barriers at key logical points (e.g., data collection moments)
Experimental Control Framework Design
1. Variable Classification Management
- Controlled Variables: Parameters kept fixed (e.g., spatial dimensions, total number of people)
- Manipulated Variables: Experimental factors actively adjusted (e.g., exit width, guidance strategy)
- Response Variables: Measured outcome metrics (e.g., evacuation time, congestion level)
- Confounding Variables: Irrelevant factors requiring statistical control (e.g., random seed batches)
2. Experimental Matrix Construction
Adopt orthogonal experimental design to systematically arrange parameter combinations:
Exp. ID | Exit Width | Crowd Density | Random Seed Batch | Repeats
-----------------------------------------------
1 | 2m | 1 person/㎡ | Batch A | 10 times
2 | 2m | 3 person/㎡ | Batch B | 10 times
3 | 4m | 1 person/㎡ | Batch B | 10 times
4 | 4m | 3 person/㎡ | Batch A | 10 times
3. Result Consistency Testing
- Statistical Testing: Perform analysis of variance (ANOVA) on repeated experimental results; within-group variance should be significantly smaller than between-group variance
- Convergence Judgment: Increase the number of repetitions until the half-width of the confidence interval for key metrics is below a preset threshold (e.g., ±2%)
Example Demonstration
Studying the impact of exit width on evacuation time:
- Control variables such as crowd density, individual movement speed, etc.
- Conduct 30 repeated experiments for each exit width (2m, 3m, 4m)
- Change the random seed for each batch, but ensure consistent seed distribution across all width conditions
- Calculate the average evacuation time and 95% confidence interval for each width
- If the confidence interval overlap is <5%, the results are considered reproducible
Through the above systematic control, it can be ensured that differences in simulation results truly reflect the impact of exit width, rather than random fluctuations, thereby supporting reliable scientific conclusions.