babylon.engine.formula_registry
Formula registry for hot-swappable mathematical functions.
This module provides a FormulaRegistry class that stores named callables, enabling runtime replacement of formulas for testing and modding.
Sprint 3: Central Committee (Dependency Injection)
Classes
Registry for named mathematical formulas. |
- class babylon.engine.formula_registry.FormulaRegistry[source]
Bases:
objectRegistry for named mathematical formulas.
Provides a central lookup for all simulation formulas, enabling: - Hot-swapping formulas for testing with mocks - Modding support for custom formula implementations - Centralized formula management
Example
>>> registry = FormulaRegistry.default() >>> la = registry.get("labor_aristocracy_ratio") >>> result = la(core_wages=120.0, value_produced=100.0)
- classmethod default()[source]
Create a registry pre-populated with all standard formulas.
Registers formulas from babylon.formulas: - labor_aristocracy_ratio - is_labor_aristocracy - consciousness_drift - acquiescence_probability - revolution_probability - crossover_threshold - loss_aversion - exchange_ratio - exploitation_rate - value_transfer - prebisch_singer
- Return type:
- Returns:
FormulaRegistry with all standard formulas registered