Repository navigation
11 Monte Carlo Simulation
Monte Carlo simulation is a risk analysis tool that models project duration uncertainty through hundreds or thousands of random samples, answering questions like "what is the probability of completing the project before a given date."
Traditional deterministic scheduling (CPM) assumes each task's duration is fixed, but in reality:
- Task durations have uncertainty — optimistic 3 days, most likely 5 days, pessimistic 10 days
- Uncertainty accumulates and propagates — after stacking 10 tasks, the total duration uncertainty far exceeds that of any single task
- The critical path may change dynamically — in different sampling outcomes, different task chains may become the bottleneck
Monte Carlo simulation repeatedly runs the entire project (each time sampling from each task's uncertainty distribution) to obtain a probability distribution of project duration, rather than a single point estimate.
Click menu bar "Project" → "Monte Carlo Simulation", a drawer opens from the right side.
-
Iterations (default 1000)
- Number of simulation runs; more iterations = more accuracy, but takes longer
- Recommended: 100-500 for quick preview, 1000-5000 for formal analysis
-
Confidence Level (default 95%)
- Probability threshold for calculating confidence intervals
- 95% means "the true value has a 95% probability of falling within this interval"
Click the "Run Simulation" button:
- Simulation executes in a Web Worker, won't freeze the interface
- Button text changes to "Simulation running..." and becomes disabled
- You can close the drawer at any time to cancel the simulation
When simulation completes, the drawer displays a visualization dashboard with three sections:
- Mean Duration - Arithmetic average of all simulation runs
- Median Duration - 50th percentile (P50), half the results are shorter, half are longer
- Standard Deviation - Measures dispersion; higher values indicate greater uncertainty
- P10 (Optimistic) - 10th percentile, meaning "only 10% of cases will be shorter"
- P50 (Median) - Equivalent to the median
- P90 (Conservative) - 90th percentile, "90% of cases will be shorter, only 10% will be longer"
- X-axis: Project duration (days)
- Y-axis: Frequency (number of times this duration occurred)
- Hover tooltip: Shows precise duration and frequency values
- The histogram's shape reflects the distribution characteristics of uncertainty (symmetric / right-skewed / bimodal, etc.)
-
Min-Max Range
- The shortest and longest durations that appeared across all simulations
- These are theoretical extreme boundaries with very low actual probability
-
P10-P90 Range
- 80% of the time, project duration will fall within this interval
- This is a more practical "reasonable range" estimate
Each task's uncertainty is sampled from a Beta-PERT distribution, with parameters from:
-
Optimistic value (O) -
optimisticDuration -
Most likely value (M) -
duration(the value used in CPM scheduling) -
Pessimistic value (P) -
pessimisticDuration
Beta-PERT distribution characteristics:
- Has upper and lower bounds (O and P)
- Peak near the most likely value M
- Asymmetric - allows for realistic situations where "pessimistic value is farther from most likely than optimistic value"
- Standard deviation
σ ≈ (P - O) / 6
- Initialize - Obtain task list and dependencies from current project's CPM scheduling results
- Sample - For each task, sample a duration value from its Beta-PERT distribution
- Re-schedule - Re-run CPM solve with sampled durations to get this iteration's project duration
- Repeat N times (iteration count)
- Statistics - Calculate mean, percentiles, and histogram from all sampled results
To avoid blocking the UI thread (especially during thousands of iterations), the simulation engine runs in a separate Web Worker:
- Main thread sends configuration via
postMessage - Worker executes simulation and returns results via
postMessage - User can continue operating the interface or close the drawer to cancel simulation while it runs
- Project has high uncertainty tasks (e.g., R&D, creative work, external dependencies)
- Need to report risk to stakeholders ("70% probability of completion before June 1")
- Need to reserve buffer but unsure how much
- Have a hard deadline and want to know the probability of on-time completion
- Task durations are very certain (e.g., assembly line, standardized operations)
- Project scale is small (<10 tasks)
- Just want a quick look at scheduling, don't care about probabilities
- Most likely value (duration) - The value you're already using in CPM scheduling, keep it unchanged
- Optimistic value (optimisticDuration) - Shortest duration "when everything goes smoothly," not impossible, but low probability
- Pessimistic value (pessimisticDuration) - Longest duration "when encountering trouble but not catastrophic," also a low probability event
Common mistakes:
- ❌ Setting optimistic value to 0 or extremely small ("theoretically could finish in 1 hour")
- ❌ Setting pessimistic value to infinity or extreme cases ("if we rewrite everything, it'll take 1 year")
- ✅ All three values should be reasonable estimates at different probabilities, not "worst nightmare"
- Mean is rarely the most useful, as the distribution may be right-skewed (extreme long tail)
- Median (P50) is more robust, "half the cases will be shorter, half will be longer"
- P90 is a good choice for conservative estimates, "only 10% of cases will be longer"
-
Histogram shape tells you the nature of the risk:
- Narrow and tall → Low uncertainty, high probability within a certain range
- Wide and flat → High uncertainty, anything can happen
- Right-skewed (long tail to the right) → A few cases will be extremely delayed
- Resource constraints not considered - Current simulation only samples task durations, doesn't re-run resource leveling; if resources are heavily overloaded, actual duration may be longer
- Dependency changes not considered - Dependency relationships remain unchanged across all simulations; in real projects, tasks may be added or removed due to risks
- Assumes independence - Each task's uncertainty is sampled independently; in reality, multiple tasks may be affected by the same external factor (e.g., supplier delay)
- Requires estimate quality - Simulation accuracy completely depends on your estimates of optimistic/pessimistic values; garbage in → garbage out
- Tasks and Outline - How to edit task duration estimates
- Dependencies and Scheduling - CPM scheduling fundamentals
- Baselines and Earned Value - Progress tracking and risk response