Below is a compact, self-contained Python “playground” that lets you experiment with the three-step pipeline (Identify → Build → Earn) and the four build-selection strategies you requested.
You can copy-paste the whole thing into a Jupyter notebook or a single .py file and just press “Run”. After the code you’ll find a short “how-to-use” section. Feel free to tweak any default constant to match your own assumptions 🛠️
"""
Simple discrete–event simulation of an IT-improvement pipeline
(1) Identify processes
(2) Build services
(3) Earn value
Author: ChatGPT – 2024-06
"""
from __future__ import annotations
import random, math, collections, itertools
from dataclasses import dataclass, field
from typing import List, Dict, Callable, Optional
import pandas as pd
# -----------------------------------------------------------------------------
# CONFIGURATION – Change these to explore different worlds
# -----------------------------------------------------------------------------
N_PROCESSES = 5_000 # total things that *could* be improved
IDENTIFY_PER_DAY = 3 # 0‥5 according to the requirement
TEAM_SIZE = 20 # people available to “burn” build-days
SIM_DAYS = 4_000 # stop after this many days (or when all built)
STRATEGY = "tech_synergy" # random | highest_value | lowest_build | tech_synergy
RNG_SEED = 42 # reproducible runs
# Complexity buckets (days of work *before* any technology synergy)
COMPLEXITY_DISTRIBUTION = {
"low" : 30,
"medium": 120,
"high" : 600
}
TECH_POOL = ["SAP", "Salesforce", "Python", "RPA", "Snowflake"]
# After we have built at least X services with a technology we get a productivity multiplier
TECH_EXPERIENCE_THRESHOLDS = {
1 : 0.70, # after first service → 30 % faster
3 : 0.40, # after third → 60 % faster
7 : 0.10 # after seventh → 90 % faster
}
# -----------------------------------------------------------------------------
# ----- Helper: deterministic seed for reproducibility
random.seed(RNG_SEED)
# ----- Data structure representing one “process → service”
@dataclass
class Service:
pid: int
technology: str
base_effort: int # nominal days for build
est_value : float
real_value: float
identified_day: Optional[int] = None
start_day : Optional[int] = None
end_day : Optional[int] = None
# derived fields but we store them to avoid recomputation
effort_left: int = field(init=False)
def __post_init__(self):
self.effort_left = self.base_effort
# ---------------------------------------------------------------------------
# Step 0 – create the “universe” (we do *not* reveal it yet,
# because you only see estimates when you identify)
# ---------------------------------------------------------------------------
def generate_all_processes(n=N_PROCESSES) -> List[Service]:
processes = []
for pid in range(n):
tech = random.choice(TECH_POOL)
comp_name, comp_days = random.choice(list(COMPLEXITY_DISTRIBUTION.items()))
est_value = random.uniform(50_000, 500_000) # € per year (whatever unit)
# “Real” value is noisy: ±50 % log-normal
real_value = est_value * random.lognormvariate(mu=0, sigma=0.4)
processes.append(Service(pid, tech, comp_days, est_value, real_value))
return processes
# master list, untouched until identified
UNIDENTIFIED_BACKLOG = generate_all_processes()
# ---------------------------------------------------------------------------
# Simulation engine (very simple, discrete per day)
# ---------------------------------------------------------------------------
def pick_candidates(identified: List[Service],
experience: Dict[str,int],
strategy: str) -> List[Service]:
"""
Return the list of services we *should* start next,
ordered by chosen strategy
"""
if not identified: return []
if strategy == "random":
random.shuffle(identified)
return identified
if strategy == "highest_value":
return sorted(identified, key=lambda s: s.est_value, reverse=True)
if strategy == "lowest_build":
return sorted(identified, key=lambda s: s.base_effort)
if strategy == "tech_synergy":
# Give a score: 0.4 * value rank + 0.6 * (we-have-experience) flag
def score(s: Service) -> float:
tech_bonus = 1 if experience.get(s.technology,0) else 0
return (tech_bonus*10_000_000) + s.est_value # big bonus if we know tech
return sorted(identified, key=score, reverse=True)
raise ValueError(f"Unknown strategy {strategy}")
def technology_multiplier(count_built: int) -> float:
"""
How much faster once we have *count_built* services finished in this tech?
Smaller multiplier = faster
"""
multiplier = 1.0
for threshold, mult in sorted(TECH_EXPERIENCE_THRESHOLDS.items()):
if count_built >= threshold:
multiplier = mult
return multiplier
def run_simulation(strategy: str = STRATEGY,
max_days: int = SIM_DAYS,
identify_per_day: int = IDENTIFY_PER_DAY,
team_size: int = TEAM_SIZE):
"""
Core loop. Returns a DataFrame with the daily KPIs and the final
list of services for post-analysis
"""
day = 0
unidentified : List[Service] = UNIDENTIFIED_BACKLOG.copy()
identified : List[Service] = [] # discovered, waiting to start
in_progress : List[Service] = [] # currently building
finished : List[Service] = [] # earning value
# state used only for synergy logic
built_per_tech : Dict[str,int] = collections.Counter()
daily_report = [] # accumulate KPIs
# ---------------- main loop ----------------
while day < max_days and (unidentified or identified or in_progress):
# 1) IDENTIFY — reveal new items
n_to_id = min(identify_per_day, len(unidentified))
for _ in range(n_to_id):
service = unidentified.pop(0)
service.identified_day = day
identified.append(service)
# 2) FINISH work that ends *today*
just_finished = []
for service in list(in_progress):
service.effort_left -= team_size # one “team-day” eaten
if service.effort_left <= 0:
service.end_day = day
in_progress.remove(service)
finished.append(service)
just_finished.append(service)
built_per_tech[service.technology] += 1
# 3) START new services if we still have capacity (simplified: 1 at a time)
# Feel free to extend to any dispatching rule
if identified and not in_progress:
ordered = pick_candidates(identified, built_per_tech, strategy)
chosen = ordered[0]
identified.remove(chosen)
# apply synergy multipliers *before* pushing into progress
mult = technology_multiplier(built_per_tech[chosen.technology])
chosen.effort_left = math.ceil(chosen.base_effort * mult)
chosen.start_day = day
in_progress.append(chosen)
# 4) RECORD KPI for this day
cumulative_value = sum(s.real_value for s in finished)
daily_report.append({"day":day,
"running_services":len(finished),
"in_progress":len(in_progress),
"waiting":len(identified),
"value_generated":cumulative_value})
day += 1
df = pd.DataFrame(daily_report)
return df, finished
# ------------- RUN & Display results ----------------------------------------
if __name__ == "__main__":
df, finished_services = run_simulation(strategy=STRATEGY)
print("\n=== Simulation finished ===")
print(f"Days simulated : {df.day.max()}")
print(f"Services built & earning: {len(finished_services)}")
print(f" Total real value earned: "
f"{sum(s.real_value for s in finished_services):,.0f}")
# Show a small head of the daily KPI table
print("\nKPI sample:")
print(df.head(10).to_string(index=False))
# Show top 10 most valuable services built
top10 = sorted(finished_services, key=lambda s: s.real_value, reverse=True)[:10]
rec = [{"pid":s.pid,
"tech":s.technology,
"real_value":f"{s.real_value:,.0f}",
"start":s.start_day,
"end":s.end_day} for s in top10]
print("\nTop 10 services by realised value:")
print(pd.DataFrame(rec).to_string(index=False))