Files
ailed-docs-rp/Metabolism_Specification.md
T
chrnx 5da4b8efa5 docs: design, plan, and the execution record
The thinking behind the organism, versioned alongside the three code repos rather than
living only on one machine.

- AILED_General_Specification.md, the authoritative design, and the implementation plan
  the code was built from
- AGENTS.md, the project-wide rules, including the two that were learned the hard way:
  this is not a performance benchmark, and a null recorded early beats a claim propped up
  later
- the nine superseded module specs, each carrying a banner naming what replaced it
- .sdd/, the execution ledger and every task brief and report: each ruling taken, what it
  would cost if wrong, every correction, and every number verified independently

The three code repos are siblings, each its own repository, and are git-ignored here so
nothing is nested.
2026-09-02 13:17:39 -05:00

140 lines
6.2 KiB
Markdown

# Metabolism: Complexity-Aware Regularization
> **Superseded (2026-09-01):** reduced to one row of §6 of the general spec. Defined, not built. See `AILED_General_Specification.md`.
## Technical Specification for Computational Resource Management
**Project Context:** AILED Organism
**Module Type:** Resource Regularizer / Complexity Controller
**Mathematical Focus:** Entropy-based regularization and Energy-Cost penalties.
---
## 1. Concept Overview: The "Energy Budget"
In biological organisms, every cognitive process has a metabolic cost (ATP consumption). An organism that uses maximum energy for every trivial task will quickly suffer from exhaustion or inefficiency.
In the **AILED Organism**, the **Metabolism Module** introduces a "cost of thinking". It prevents the model from over-complicating its decision-making process. It enforces a principle of **Parsimony**: the engine should seek the most efficient (simplest) path to a successful move.
This module acts as a regularizer on the move selection, penalizing moves that require high "neural activation" or represent excessive cognitive complexity.
---
## 2. Mathematical Formalism
The metabolism operates by modifying the utility of a move based on its **Metabolic Cost ($\mathcal{E}$)**.
### 2.1. The Metabolic Cost ($\mathcal{E}$)
The cost of a move $a$ is defined by the complexity of the activation required to "justify" that move. We estimate this using the complexity of the Relational Perceptron's output:
$$\mathcal{E}(a) = \text{Norm}(\text{Activation Magnitude}) \times \text{Entropy}(\text{Weight Distribution})$$
Where:
- **Activation Magnitude:** The L2 norm of the neuron activations required for move $a$. High magnitude implies a "high-effort" neural pattern.
- **Entropy:** The Shannon entropy of the weights involved in the decision. High entropy implies a "confused" or overly complex weight pattern.
### 2.2. The Damping Function
The final utility $U_{\text{met}}(a)$ is obtained by applying a "Metabolic Tax" to the original utility $U(a)$ provided by the Instinct module.
$$U_{\text{met}}(a) = \frac{U(a)}{1 + \gamma(\psi) \cdot \mathcal{E}(a)}$$
Where $\gamma(\psi)$ is the **Metabolic Sensitivity (The Hunger Factor)**:
- **High $\psi$ (Euphoria/Abundance):** $\gamma(\psi) \to 0$. The engine is "well-fed" and can afford to spend energy on complex, sophisticated, or "expensive" moves.
- **Low $\psi$ (Stress/Famine):** $\gamma(\psi) \to \text{max}$. The engine is "starving" and becomes extremely frugal, heavily penalizing any move that is computationally or structurally complex.
---
## 3. Comparison with Standard AI
| Feature | Standard AI (Brute Force) | AILED Metabolism |
| :--- | :--- | :--- |
| **Optimization Goal** | Maximize Win Probability. | Maximize Win Probability per unit of Energy. |
| **Complexity Handling** | Ignoes computational cost of the "thought". | Actively avoids "expensive" thoughts. |
| **Behavioral Variation** | Always uses maximum resources. | Fluctuates between "Lavish" and "Frugal" based on $\psi$. |
---
## 4. Minimal Implementation (Python + NumPy)
This implementation demonstrates how the metabolic tax is applied to a set of candidate moves.
```python
import numpy as np
class MetabolismModule:
"""
A minimal implementation of the Metabolism Module.
Applies a metabolic tax to move utilities based on complexity.
"""
def __init__(self):
pass
def calculate_complexity(self, activations: np.ndarray, weights: np.ndarray) -> float:
"""
Estimates the metabolic cost E(a).
"""
# Magnitude of activation
magnitude = np.linalg.norm(activations)
# Entropy of weights (simplified)
# We use the variance as a proxy for entropy/complexity here
complexity_proxy = np.var(weights)
return magnitude * complexity_complexity_proxy
def apply_tax(self, utilities: np.ndarray, costs: np.ndarray, psyche: float) -> np.ndarray:
"""
App Applies the metabolic tax to the utilities.
Args:
utilities: (N,) array of original move utilities.
costs: (N,) array of metabolic costs per move.
psyche: Float [-100, 100] modulating the tax intensity.
"""
# 1. Calculate Gamma (Hunger Factor)
# Low psi -> High gamma (starving/frugal)
# High psi -> Low gamma (well-fed/lavish)
gamma = (100.0 - psyche) / 200.0 # Range [0, 1]
# 2. Apply the tax formula: U_met = U / (1 + gamma * E)
metabolic_utilities = utilities / (1.0 + gamma * costs)
return metabolic_utilities
# --- DEMO ---
if __name__ == "__main__":
metabolism = MetabolismModule()
# 3 candidate moves
# move_utilities: [Move 0: High Value, Move 1: Mid Value, Move 2: Low Value]
move_utilities = np.array([1.0, 0.6, 0.3])
# move_costs: [Move 0: Highly Complex, Move 1: Moderate, Move 2: Very Simple]
move_costs = np.array([0.9, 0.4, 0.1])
print("--- Metabolism Simulation ---")
# Scenario A: High Psyche (Well-fed / Lavish)
print("\n[SCENARIO: HIGH PSYCHE - Lavish Behavior]")
res_lavish = metabolism.apply_tax(move_utilities, move_costs, psyche=90.0)
print(f"Original Utilities: {move_utilities}")
print(f"Metabolic Utilities: {res_lavish}")
print(f"Winner: Move {np.argmax(res_lavish)} (Likely the high-value complex move)")
# Scenario B: Low Psyche (Starving / Frugal)
print("\n[SCENARIO: LOW PSYCHE - Frugal Behavior]")
res_frugal = metabolism.apply_tax(move_utilities, move_costs, psyche=-80.0)
print(f"Original Utilities: {move_utilities}")
print(f"Metabolic Utilities: {res_frugal}")
print(f"Winner: Move {np.argmax(res_frugal)} (Likely the low-value simple move)")
```
---
## 5. Practical Implications
* **Complexity Control:** This module naturally prevents "overfitting" to complex, non-robust move patterns.
* **Emergent Simplicity:** It encourages the emergence of "elegant" strategies—moves that achieve high results with minimal structural change.
* **Adaptive Style:** It creates a fundamental difference in playstyle between a "confident" engine (which explores complex lines) and a "stressed" engine (which plays safe, simple, and robust moves).
```