Home / Architecture / Tool 04 Demo / Algorithm Detail

Tool 04 · Algorithm Deep Dive

Cost & Timeline Forecaster

XGBoost + SHAP + Monte Carlo Simulation

12.3%MAPE (P50 Cost)
88.7%P90 Coverage
10,000Simulations/Run
42Training Projects
Try Interactive Demo

🎯 Why This Algorithm

📋 Problem Statement

Single-number estimates lie. The Flaw of Averages: if you estimate 10 tasks at 10 days each, the project is NOT 100 days. Due to statistical dependency (one delay cascades), actual outcome is usually 140-160 days. Clients need P50 (median) and P90 (conservative) ranges to price in contingency correctly.

✅ Solution

Quantile LightGBM learns the full distribution of costs, not just the mean. Monte Carlo simulation (10,000 runs) propagates uncertainty through dependent workstreams. Bayesian updating pulls priors from similar historical projects, refining estimates with actual delivery data.

🧩 What It Comprises

📈 Quantile Regressors

4 LightGBM models trained for τ ∈ {0.25, 0.50, 0.75, 0.90}. Each predicts a specific percentile of the cost distribution.

🎲 Monte Carlo Engine

10,000-run simulation sampling from joint distribution of workstream costs. Gaussian copula models dependency structure.

🔁 Bayesian Updating

Prior from historical analogues (Tool 12) → Updated with project-specific features via Bayes' theorem.

📊 S-Curve Generator

Cumulative distribution function showing probability of completion at or below any cost level.

📥 Inputs & 📤 Outputs

📥 Inputs

  • Scope breadth (from Tools 02, 03)
  • Team seniority mix
  • Parallel workstreams count
  • Industry + region
  • Integration count
  • Historical analogues (Tool 12)

📤 Outputs

  • P25 / P50 / P75 / P90 cost (USD)
  • P25 / P50 / P75 / P90 timeline (months)
  • S-Curve of cumulative spend
  • Confidence intervals per workstream

🔄 How It Runs — Step by Step

┌─────────────────────────────────────────────────────────────────────────────────────────┐
│                      COST & TIMELINE FORECASTER PIPELINE                                   │
├─────────────────────────────────────────────────────────────────────────────────────────┤
│                                                                                           │
│   ┌─────────────────────────────────────────────────────────────────────────────────┐   │
│   │                              STEP 1: FEATURE ENGINEERING                          │   │
│   │                                                                                   │   │
│   │   Inputs from Tools 02, 03, 12:                                                   │   │
│   │   • Scope vector: [FI:23, CO:18, MM:31, SD:15, PP:8]                              │   │
│   │   • Team: [Sr:4, Mid:6, Jr:3]                                                     │   │
│   │   • Integrations: 7 interfaces                                                     │   │
│   │   • Industry: Pharma, Region: EU                                                   │   │
│   │   • Historical analogues: 5 similar projects                                       │   │
│   └─────────────────────────────────────────────────────────────────────────────────┘   │
│          │                                                                                 │
│          ▼                                                                                 │
│   ┌─────────────────────────────────────────────────────────────────────────────────┐   │
│   │                    STEP 2: QUANTILE LIGHTGBM PREDICTION                            │   │
│   │                                                                                   │   │
│   │   For each workstream (FI, CO, MM, SD, PP, Basis, Data):                          │   │
│   │                                                                                   │   │
│   │   ┌───────────────────────────────────────────────────────────────────────────┐  │   │
│   │   │  LightGBM Quantile Regressors (4 models per workstream)                     │  │   │
│   │   │                                                                            │  │   │
│   │   │  Input → [800 trees, max-depth=6] → Quantile Predictions                    │  │   │
│   │   │                                                                            │  │   │
│   │   │  τ=0.25  τ=0.50  τ=0.75  τ=0.90                                           │  │   │
│   │   │    ↓       ↓       ↓       ↓                                               │  │   │
│   │   │  $120k   $145k   $175k   $210k   (FI workstream example)                    │  │   │
│   │   │                                                                            │  │   │
│   │   │  Pinball Loss: L_τ(y,ŷ) = { τ(y-ŷ) if y≥ŷ; (1-τ)(ŷ-y) if y<ŷ }            │  │   │
│   │   └───────────────────────────────────────────────────────────────────────────┘  │   │
│   └─────────────────────────────────────────────────────────────────────────────────┘   │
│          │                                                                                 │
│          ▼                                                                                 │
│   ┌─────────────────────────────────────────────────────────────────────────────────┐   │
│   │                    STEP 3: BAYESIAN PRIOR UPDATING                                 │   │
│   │                                                                                   │   │
│   │   Prior Distribution from Historical Analogues (Tool 12):                          │   │
│   │   P(θ) ~ Weighted mixture of 5 most similar projects                               │   │
│   │                                                                                   │   │
│   │   Likelihood from LightGBM:                                                        │   │
│   │   P(Data | θ) ~ Quantile predictions transformed to distribution                   │   │
│   │                                                                                   │   │
│   │   Posterior (Bayes' Theorem):                                                      │   │
│   │   P(θ | Data) ∝ P(Data | θ) × P(θ)                                                │   │
│   │                                                                                   │   │
│   │   → Shrinks estimates toward historical outcomes when data is sparse               │   │
│   └─────────────────────────────────────────────────────────────────────────────────┘   │
│          │                                                                                 │
│          ▼                                                                                 │
│   ┌─────────────────────────────────────────────────────────────────────────────────┐   │
│   │                    STEP 4: MONTE CARLO SIMULATION (10,000 RUNS)                    │   │
│   │                                                                                   │   │
│   │   ┌─────────────────────────────────────────────────────────────────────────┐    │   │
│   │   │                         COPULA STRUCTURE                                   │    │   │
│   │   │                                                                          │    │   │
│   │   │            FI ──┐                                                         │    │   │
│   │   │                 │                                                         │    │   │
│   │   │            CO ──┼── Gaussian Copula (ρ = 0.72 correlation)                │    │   │
│   │   │                 │                                                         │    │   │
│   │   │            MM ──┤      → Joint distribution modeling                       │    │   │
│   │   │                 │        dependency between workstreams                    │    │   │
│   │   │            SD ──┤                                                         │    │   │
│   │   │                 │                                                         │    │   │
│   │   │           Data ─┘                                                         │    │   │
│   │   └─────────────────────────────────────────────────────────────────────────┘    │   │
│   │                                                                                   │   │
│   │   For run i = 1 to 10,000:                                                         │   │
│   │       1. Sample correlated uniforms from copula                                     │   │
│   │       2. Transform to workstream distributions (inverse CDF)                        │   │
│   │       3. Sum costs = Total_i                                                        │   │
│   │       4. Record Total_i                                                             │   │
│   │                                                                                   │   │
│   │   Results: 10,000 possible total project costs                                     │   │
│   └─────────────────────────────────────────────────────────────────────────────────┘   │
│          │                                                                                 │
│          ▼                                                                                 │
│   ┌─────────────────────────────────────────────────────────────────────────────────┐   │
│   │                    STEP 5: S-CURVE & OUTPUT                                        │   │
│   │                                                                                   │   │
│   │   Sort 10,000 totals → Cumulative Distribution Function                            │   │
│   │                                                                                   │   │
│   │   100% ┤                                 ╱──────────                               │   │
│   │        │                             ╱──                                           │   │
│   │    90% ┤                        ╱───                                               │   │
│   │        │                    ╱──                                                    │   │
│   │    75% ┤                ╱───                                                       │   │
│   │        │            ╱──                                                            │   │
│   │    50% ┤        ╱───          ← P50: $4.2M                                         │   │
│   │        │    ╱──                                                                    │   │
│   │    25% ┤ ╱──                                                                       │   │
│   │        ├──┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───                             │   │
│   │           $3.5M  $4.0M  $4.5M  $5.0M  $5.5M  $6.0M                                 │   │
│   │                              Project Cost                                           │   │
│   │                                                                                   │   │
│   │   Output: P50 = $4.2M, P90 = $5.8M, P75 = $4.9M                                   │   │
│   └─────────────────────────────────────────────────────────────────────────────────┘   │
│                                                                                           │
└─────────────────────────────────────────────────────────────────────────────────────────┘
                    

📈 S-Curve Visualization (Conceptual)

P50: $4.2M P90: $5.8M

Probability of completing at or below given cost

🏗️ Architecture & Integration

Where Cost Forecaster Sits in A²AI

🏷️ TOOL 02
Requirements
🧭 TOOL 03
Modules
🕰️ TOOL 12
Historical
💰 TOOL 04
Cost & Timeline Forecaster
Quantile LGBM + Monte Carlo
Executive Dashboard
S-Curve, P50/P90
SOW Generator
Pricing Table
Risk Mitigation
Contingency Planning

Tool 04 is the STAR TOOL — directly feeds executive decision-making and commercial pricing.

📐 Mathematical Explanation

Quantile Regression Loss (Pinball Loss):

L_τ(y, ŷ) = Σ_i { τ·(y_i - ŷ_i) if y_i ≥ ŷ_i; (1-τ)·(ŷ_i - y_i) if y_i < ŷ_i }

For τ=0.9, underestimation is penalized 9× more than overestimation.

LightGBM Gradient Boosting:

F_m(x) = F_{m-1}(x) + η · h_m(x)

Where h_m is the tree fitted to the negative gradient of the pinball loss.

Bayesian Updating:

P(θ | Data) = [P(Data | θ) × P(θ)] / P(Data)

Prior P(θ) from historical analogues (Tool 12).

Gaussian Copula (Dependency Modeling):

C(u₁,...,u_d) = Φ_Σ( Φ⁻¹(u₁), ..., Φ⁻¹(u_d) )

Where Φ_Σ is multivariate normal CDF with correlation matrix Σ learned from historical data.

Monte Carlo Estimate of P90:

P90 = inf{ c : (1/N) Σ_{i=1}^N 𝕀[Total_i ≤ c] ≥ 0.90 }

Where N = 10,000 simulation runs.

📊 Measured Performance

MetricValueBenchmark
MAPE (P50 Cost)12.3%42 delivered projects
P90 Coverage88.7%Actual cost ≤ P90 estimate
P75 Coverage76.2%Actual cost ≤ P75 estimate
P50 Coverage52.4%Actual cost ≤ P50 estimate (ideal: 50%)
Timeline MAPE14.8%Months duration
Simulation Time2.3s10,000 runs on CPU

📚 Training & Calibration Set

  • Projects: 42 delivered SAP engagements (2022–2025)
  • Size Range: $500K – $12M project value
  • Industries: Pharma, CPG, Manufacturing, Financial Services
  • Features: 47 engineered features per project
  • Validation: Leave-one-project-out cross-validation
  • Calibration: Isotonic regression on held-out predictions
  • Retrain Schedule: Quarterly as new projects complete

🎬 End-to-End Example

Scenario: $10M S/4HANA RFP Estimation

  1. Input: Scope from Tools 02/03 — 142 requirements across FI, CO, MM, SD, PP; 7 integrations; mid-senior team
  2. Quantile Predictions: LightGBM outputs per-workstream quantiles
  3. Historical Prior: Tool 12 finds 5 similar pharma projects; weighted prior = $4.5M P50
  4. Bayesian Update: Posterior shifts to $4.2M P50 based on current scope features
  5. Monte Carlo: 10,000 runs with correlation ρ=0.72 between workstreams
  6. Output: P50 = $4.2M, P75 = $4.9M, P90 = $5.8M
  7. Action: Commercial team prices at P75 ($4.9M) with contingency reserve for P90

Result: Project delivered at $5.1M — within P90 band. Margin protected.