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.
This commit is contained in:
chrnx committed 2026-09-02 13:17:39 -05:00
commit 5da4b8efa5
47 files changed
+7498

No files matched your search

+147
View File
@@ -0,0 +1,147 @@
# Affective CPPN: Topological Generation under Psyche Modulation
> **Superseded (2026-09-01):** replaced by §3 of the general spec. Output is now a per-channel vector and ψ is a 2-axis input. See `AILED_General_Specification.md`.
## Technical Specification for the AILED Neuroevolutionary Core
**Project Context:** AILED Organism / RPN Architecture
**Focus:** Differential analysis, integration with RP, and affective weight-generation mathematics.
---
## 1. Concept Overview: The "DNA" of Connectivity
In standard Neuroevolution (like HyperNEAT), a **CPPN** acts as a function that maps spatial coordinates to connection weights. It provides the "blueprint" for the network. However, in standard implementations, once the CPPN is evolved, the resulting topology is **static**.
The **Affective CPPN** proposed for AILED introduces a fourth dimension to the mapping: the **Psyche ($\psi$)**. This transforms the CPPN from a static blueprint into a **dynamic generator** that can reshape the functional topology of the organism in response to emotional/environmental tension.
---
## 2. Comparative Analysis
| Feature | Standard CPPN (HyperNEAT) | Affective CPPN (AILED) |
| :--- | :--- | :--- |
| **Input Domain** | $\mathbb{R}^n$ (Spatial coordinates) | $\mathbb{R}^n \times \mathcal{K} \times \mathbb{R}$ (Spatial + Relation + $\psi$) |
| **Output** | Static weight $w$ | Dynamic weight $w(\psi)$ |
| **Topology** | Fixed after evolution | Reconfigurable/Modulated during inference |
| **Behavioral Goal** | Structural Symmetry | Functional Adaptability (Affective) |
| **Analogy** | A fixed skeleton. | A nervous system that tightens or relaxes. |
---
## 3. Integration with the Relational Perceptron (RP)
The CPPN and the RP form a symbiotic relationship. The RP provides the "muscle" (the execution of the interaction), while the CPPN provides the "nervous system" (the logic that defines how strong that interaction should be).
**The Feedback Loop:**
1. **Input:** The RP identifies a set of relations $\mathcal{R} = \{(\mathbf{r}_i, \text{id}_i)\}$.
2. **Modulation:** The CPPN receives these relations plus the current $\psi$.
3. **Generation:** The CPPN outputs a weight vector $\mathbf{W}$ that is structurally optimized for that specific $\psi$.
4. **Execution:** The RP applies $\mathbf{W}$ to the piece embeddings to produce the final activation.
**Mathematical Synergy:**
$$\text{RP\_Activation} = \sigma \left( \sum \underbrace{\text{CPPN}(\mathbf{r}_i, \text{id}_i, \psi)}_{\text{Topology}} \cdot \underbrace{\text{Embedding}(\mathbf{p}_i)}_{\text{Content}} \right)$$
---
## 4. Mathematical Formalism
The Affective CPPN is defined as a composition of periodic and radial basis functions, extended to include the $\psi$ manifold.
Let $\mathbf{z} = [x, y, \text{id}, \psi]^T$ be the augmented input vector.
The weight $w$ for a relation is:
$$w = \sum_{k=1}^{M} \alpha_k \cdot \phi_k(\mathbf{z})$$
Where $\phi_k$ are basis functions such as:
* **Periodic:** $\sin(\mathbf{k}_k \cdot \mathbf{z} + b_k)$
* **Radial:** $\exp(-\|\mathbf{z} - \mathbf{c}_k\|^2)$
* **Modulating:** $\text{tanh}(\psi \cdot \mathbf{s}_k)$
This allows the model to express complex behaviors like: *"If the pieces are in a diagonal relation AND the Psyche is low (stress), increase the weight of this connection."*
---
## 5. Minimal Implementation (Python + NumPy)
This implementation simulates an Affective CPPN that generates weights for a set of relations, demonstrating how $\psi$ shifts the weight distribution.
```python
import numpy as np
class AffectiveCPPN:
"""
A minimal implementation of an Affective CPPN.
Maps (x, y, relation_id, psyche) to a weight vector.
"""
def __init__(self, num_basis_functions: int = 8):
self.num_basis = num_basis_functions
# Coefficients learned through evolution (simulated here)
# Each basis function has coefficients for [x, y, id, psi]
self.coeffs = np.random.randn(num_basis_functions, 4)
# Frequencies for periodic functions
self.freqs = np.random.uniform(0.5, 2.0, (num_basis_functions, 4))
def generate_weights(self, relations: np.ndarray, rel_ids: np.ndarray, psyche: float) -> np.ndarray:
"""
Args:
relations: (N, 2) array of (dx, dy)
rel_ids: (N, 1) array of relation types (e.g., 0=attack, 1=defense)
psyche: float [-100, 100]
Returns:
weights: (N,) array of generated weights
"""
num_relations = relations.shape[0]
# 1. Construct Augmented Input Matrix Z: (N, 4) -> [x, y, id, psi]
psi_col = np.full((num_relations, 1), psyche)
z = np.hstack([relations, rel_ids, psi_col])
# 2. Compute Basis Functions (Periodic + Radial)
# We use a combination of Sine (for patterns) and Gaussian (for localization)
# Sine components: sin(z * freq + phase)
# We'll use a dot product to simulate the summation of basis functions
# Simplified basis calculation:
# We transform z into a higher dimensional space via basis functions
# In a real CPPN, this is a deep composition.
# Let's simulate: weights = sum(coeff * sin(z * freq))
# Using broadcasting to perform the sum over basis functions
# z shape: (N, 4), freqs shape: (B, 4), coeffs shape: (B, 4)
# Expanded z for broadcasting: (1, N, 4)
z_exp = z[np.newaxis, :, :]
# Expanded freqs: (B, 1, 4)
f_exp = self.freqs[np.newaxis, :, :]
# Basis: sin(z * freq) -> (B, N, 4)
basis_sine = np.sin(z_exp * f_exp)
# Weight calculation: Sum over basis (B) and features (4)
# We want one weight per relation (N)
# Weighted sum: Sum over B and 4: (B, N, 4) * (B, 1, 4) -> sum -> (N,)
weights = np.sum(basis_sine * self.coeffs[np.newaxis, :, :], axis=(0, 2))
return weights
# --- DEMO ---
if __name__ == "__main__":
cpnn = AffectiveCPPN(num_basis_functions=12)
# 3 relations: (dx, dy), relation_id (0=attack, 1=defense, 2=empty)
rel_coords = np.array([[1.0, 1.0], [0.0, 1.0], [-1.0, 0.0]])
rel_types = np.array([[0.0], [1.0], [2.0]])
print("--- Affective CPPN Simulation ---")
for p in [-80.0, 0.0, 80.0]:
w = cpnn.generate_weights(rel_coords, rel_types, p)
print(f"Psyche: {p:4.1f} | Generated Weights: {w}")
```
### Key Takeaways for Implementation:
1. **The $\psi$ Dimension:** Notice how $\psi$ is part of the input $\mathbf{z}$. This allows the "periodic" nature of the network to shift its phase or frequency based on emotion.
2. **Complexity:** The complexity is $O(N \cdot B)$, where $N$ is the number of relations and $B$ is the number of basis functions. This is extremely efficient and allows for real-time execution.
3. **Non-linearity:** The use of $\sin$ and $\tanh$ ensures that the topology can represent highly complex, non-linear spatial patterns.
```