Analyze Parameter Sensitivity
This guide shows how to systematically explore how parameter changes affect simulation outcomes. Use these techniques to understand the design space, identify stable ranges, and validate theoretical predictions.
Prerequisites
Completed Quickstart
Basic understanding of Imperial Rent
Access to
misetask runner
Available Tools
Babylon provides two analysis modes via tools/parameter_analysis.py:
- Trace Mode
Run a single simulation and capture full time-series data. Useful for detailed analysis of one parameter configuration.
- Sweep Mode
Run multiple simulations varying one parameter. Useful for identifying thresholds and phase transitions.
Single-Run Trace Analysis
Capture complete state evolution for detailed analysis:
mise run analyze-trace
This creates results/trace.csv with columns:
Column |
Description |
|---|---|
|
Simulation tick number |
|
Periphery worker (C001) wealth |
|
P(S|A) - survival by acquiescence |
|
P(S|R) - survival by revolution |
|
Class consciousness level |
|
Tension on exploitation edge |
|
Imperial rent extracted this tick |
Custom Parameter Values
Override a specific parameter for the trace:
poetry run python tools/parameter_analysis.py trace \
--param economy.extraction_efficiency=0.1 \
--csv results/low_extraction_trace.csv
This runs with extraction efficiency at 10% instead of the default 80%.
Extended Runs
For longer simulations:
poetry run python tools/parameter_analysis.py trace \
--ticks 200 \
--csv results/extended_trace.csv
Parameter Sweep Analysis
Explore how outcomes change across a parameter range:
mise run analyze-sweep
Default sweep varies economy.extraction_efficiency from 0.05 to 0.50
in steps of 0.05. Output goes to results/sweep.csv.
Custom Sweeps
Sweep any GameDefines parameter:
poetry run python tools/parameter_analysis.py sweep \
--param consciousness.drift_sensitivity_k \
--start 0.1 \
--end 2.0 \
--step 0.1 \
--csv results/consciousness_sweep.csv
Sweep Output Columns
Column |
Description |
|---|---|
|
Parameter value tested |
|
How many ticks before death (or max) |
|
SURVIVED or DIED |
|
Worker wealth at simulation end |
|
Peak tension observed |
|
Tick when P(S|R) exceeded P(S|A) |
|
Total rent extracted across all ticks |
|
Maximum consciousness reached |
Interpreting Results
Identifying Thresholds
Look for parameter values where outcomes change dramatically:
- Death Threshold
The extraction efficiency where
ticks_surviveddrops sharply. Below this value, workers survive; above, they die quickly.- Crossover Point
The first
valuewherecrossover_tickbecomes non-null. This indicates when revolution becomes rational.- Consciousness Ceiling
Compare
peak_p_w_consciousnessacross values. Higher extraction may paradoxically increase consciousness before death.
Validating Theory
MLM-TW predicts specific relationships:
Higher extraction → faster death
ticks_survivedshould decrease asextraction_efficiencyincreases.Higher extraction → more rent
cumulative_rentshould increase with efficiency (until death).More tension → earlier crossover
crossover_tickshould be inversely related tomax_tension.
If your results contradict these predictions, either:
The parameter range is outside theoretical validity
There’s a bug in the simulation (see Debug Simulation Outcomes)
The theory needs refinement (document as discovery)
Visualizing Results
Import sweep CSV into your preferred analysis tool:
Python (pandas + matplotlib):
import pandas as pd
import matplotlib.pyplot as plt
df = pd.read_csv("results/sweep.csv")
fig, axes = plt.subplots(2, 2, figsize=(12, 10))
# Survival vs extraction
axes[0, 0].plot(df["value"], df["ticks_survived"])
axes[0, 0].set_xlabel("Extraction Efficiency")
axes[0, 0].set_ylabel("Ticks Survived")
axes[0, 0].set_title("Survival Time")
# Rent accumulation
axes[0, 1].plot(df["value"], df["cumulative_rent"])
axes[0, 1].set_xlabel("Extraction Efficiency")
axes[0, 1].set_ylabel("Cumulative Rent")
axes[0, 1].set_title("Total Extraction")
# Peak consciousness
axes[1, 0].plot(df["value"], df["peak_p_w_consciousness"])
axes[1, 0].set_xlabel("Extraction Efficiency")
axes[1, 0].set_ylabel("Peak Consciousness")
axes[1, 0].set_title("Consciousness Development")
# Crossover timing
crossover = df[df["crossover_tick"].notna()]
axes[1, 1].scatter(crossover["value"], crossover["crossover_tick"])
axes[1, 1].set_xlabel("Extraction Efficiency")
axes[1, 1].set_ylabel("Crossover Tick")
axes[1, 1].set_title("Revolution Threshold")
plt.tight_layout()
plt.savefig("results/sweep_analysis.png")
- Spreadsheet:
Import CSV, create line charts for each metric vs. parameter value.
Available Parameters
All parameters in GameDefines can be swept. Common ones:
- Economy:
economy.extraction_efficiency- How much rent extracted per tickeconomy.base_subsistence- Minimum wealth for survival
- Consciousness:
consciousness.drift_sensitivity_k- How fast consciousness changesconsciousness.agitation_accumulation_rate- Agitation buildup speed
- Solidarity:
solidarity.transmission_rate- How fast consciousness spreadssolidarity.decay_rate- How fast solidarity weakens
- Survival:
survival.loss_aversion_lambda- Kahneman-Tversky loss aversion
See Configuration System for the complete parameter list.
Best Practices
Start with wide sweeps, then narrow to interesting regions
Document your findings in
brainstorm/analysis/Compare against theory - unexpected results are discoveries
Use consistent tick counts for comparable results
Version your CSV outputs for reproducibility
See Also
Debug Simulation Outcomes - Diagnosing unexpected behavior
Tune Simulation Parameters - Manual parameter adjustment
Configuration System - GameDefines parameter reference
Survival Calculus - Theoretical foundation